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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Apple ID does not have to equal iCloud e-mail philipk iCloud and Apple Services 6 Nov 19, 2011 12:03 PM
Shapewriter for dragging your finger to type, does iphone have it? theLemur iPhone 8 Feb 10, 2011 11:42 PM
(applescript) is there a "vardump" command? vrillusions Mac Programming 1 Jan 26, 2011 04:48 PM
Does anyone have trouble with bootup commands using the aluminum keyboard? afultz075 iMac 13 Jun 10, 2009 05:58 AM
Applescript return argument given in command line qpple Mac Programming 3 Sep 11, 2007 09:28 AM


All times are GMT -5. The time now is 04:29 PM.

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

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