• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Send keystroke to terminal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Send keystroke to terminal


  • Subject: Send keystroke to terminal
  • From: John Masters <email@hidden>
  • Date: Sun, 11 Jul 2010 13:04:58 +0100

Hi,

I need to regularly send a keystroke to a program running in the terminal. So far I have got it to save the frontmost app to a variable, switch to the terminal, send the keystroke and then switch back. This works but causes a momentary 'blink' in the frontmost app. Is there any way to send a keystroke to a terminal application without bringing the terminal to the foreground? Basic code is as follows.

tell application "System Events"
	set frontProc to name of the first process whose frontmost is true
	set theproc to do shell script "ps ux | awk '/slrn/ &&!/awk/ {print $2}' &"
	if theproc is not equal to "" then
		tell application "Terminal" to activate
		keystroke "G" using shift down
	end if
	set frontmost of process frontProc to true
end tell

--
Regards, John K Masters
email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Scripting a Sys Pref
  • Next by Date: Re: floating onscreen clock
  • Previous by thread: RE: Scripting a Sys Pref
  • Next by thread: Re: AppleScript-Users Digest, Vol 7, Issue 357
  • Index(es):
    • Date
    • Thread