Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 17, 2008, 07:26 PM   #1
techmonkey
macrumors 6502a
 
Join Date: Jun 2007
Does Applescript have a "SendKey" type command?

Coming from the Windows world, Im use to having a SendKey command in VB/VBA in programming. Is there something similar in Applescript?

What I am trying to do is run some keys whenever a specified window pops-up.
__________________
MacBook Pro 2.2GHz SR
4GB-RAM,120GB-HDD,128MB NVIDIA 8600M GT
techmonkey is offline   0 Reply With Quote
Old Feb 17, 2008, 07:59 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
You can use the keystroke command:

Code:
tell application "System Events"
	keystroke "#" using {command down, shift down}
end tell
(takes a screen shot)
kainjow is offline   0 Reply With Quote
Old Feb 17, 2008, 08:44 PM   #3
techmonkey
Thread Starter
macrumors 6502a
 
Join Date: Jun 2007
thanks. Thats whats I was looking for.
Question though.

How can I send a Command + F in TextEdit?

So far I have this

Code:
activate application "TextEdit"

tell application "System Events"
	keystroke "F"
end tell
__________________
MacBook Pro 2.2GHz SR
4GB-RAM,120GB-HDD,128MB NVIDIA 8600M GT
techmonkey is offline   0 Reply With Quote
Old Feb 17, 2008, 08:49 PM   #4
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Try
Code:
tell application "TextEdit"
	activate
	
	tell application "System Events"
		keystroke "f" using {command down}
	end tell
end tell
You might want to learn GUI scripting with AppleScript, which lets you control parts of an application that aren't normally scriptable.
kainjow is offline   0 Reply With Quote
Old Feb 17, 2008, 09:02 PM   #5
techmonkey
Thread Starter
macrumors 6502a
 
Join Date: Jun 2007
Quote:
Originally Posted by kainjow View Post
Try
Code:
tell application "TextEdit"
	activate
	
	tell application "System Events"
		keystroke "f" using {command down}
	end tell
end tell
You might want to learn GUI scripting with AppleScript, which lets you control parts of an application that aren't normally scriptable.

Thanks.

Hmm... How come it says Command Down for the command key? Whats the down for?

Do you have a good resouce for GUI scripting with Applescript?
__________________
MacBook Pro 2.2GHz SR
4GB-RAM,120GB-HDD,128MB NVIDIA 8600M GT
techmonkey is offline   0 Reply With Quote
Old Feb 17, 2008, 09:08 PM   #6
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Quote:
Originally Posted by techmonkey View Post
How come it says Command Down for the command key? Whats the down for?
It's the name of the parameter to the keystroke command. In Script Editor, go to File > Open Dictionary, select System Events, then search for "keystroke" and you'll see the other options.

Quote:
Do you have a good resouce for GUI scripting with Applescript?
Apple's site is a good starter: http://www.apple.com/applescript/uiscripting/
kainjow is offline   1 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
General: iOS7 command line... Equivalent of "say" command? RobertoG Jailbreaks and iOS Hacks 0 Jan 19, 2014 05:05 PM
"Applications" menu command - "item cannot be found" - owner/permissions? (10.6.8) MacOSExustio OS X 2 Jul 20, 2013 05:05 AM
OS X: CS:GO "command" + "left mouse click" causes "right mouse click" Whats wrong? oeppel Mac and PC Games 1 Apr 6, 2013 03:12 AM
Trying to extract .cab files. "-bash: unshield: command not found" matto200 OS X 0 Mar 17, 2013 03:04 PM
"Boot failed! Press any key to enter command line." Ravich Windows, Linux & Others on the Mac 0 Jun 6, 2012 06:51 PM

Forum Jump

All times are GMT -5. The time now is 06:26 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC