PDA

View Full Version : Help!




PBLRDom
Apr 3, 2012, 04:16 AM
I need to write a script that will execute some really basic stuff and I can't figure out how.

All i need is for my X key and my spacebar key to be pushed 2 times each every 5 minutes.
literally.... xx then two spacebar pushes
I would like the duration of the keystrokes to be 1 second long.

Is this possible?



kryten2
Apr 3, 2012, 06:47 PM
In order for the "System Events" application to use the key code or keystroke commands, you have to enable Mac OS X's accessibility frameworks."System Events" will send a key code or a keystroke to the frontmost application.

Paste code in scripteditor :

tell application "System Events"
repeat
keystroke "x"
keystroke "x"
keystroke space
keystroke space
--change delay 10 to delay 300 for 5 minutes delay
delay 10
end repeat
end tell


Don't know if the duration of the keystrokes can be 1 second long.
Will result in this as the frontmost application is scripteditor :

PBLRDom
Apr 3, 2012, 07:05 PM
Ok that works awesome! TY!
Now how do i get it to run within an application?

----------

also how does the delay work/. i see that it says 5 mins, but it runs much faster. I want it to continually run until i turn it off.

kryten2
Apr 3, 2012, 07:20 PM
What do you mean by :

Now how do i get it to run within an application?

Do you want to send your keystroke to some application? Please specify.

Also how does the delay work

I thought this line explains what you must change :
--change delay 10 to delay 300 for 5 minutes delay
Change delay 10 to delay 300 for a 5 minutes delay. Delay is in seconds so
60x5=300 seconds = 5 minutes.

The script will continue to run untill you click stop in scripteditor