**Use caution when writing Apple Scripts**
They can be helpful, or harmful, like any tool.
I used this to simulate clicking on the screen for an idle game played in a website using Safari. It does work even on a MacBook with no numeric keypad. The script emulates the key code that would correspond to the numeric keypad '5', even if there is no physical key. You can use the keyboard shortcut 'alt/option' 5 times to turn Mouse Keys on or off. When off, key code 87 triggers the unicode for the number five. When on, key code 87 triggers a mouse button press/release cycle.
Yay, it worked!
Now, instead of one click per second how about 10, or 100 clicks per second... that idle game won't know what hit it!
...but wait
There's that little voice again saying 'hold on now'...
*** CAUTION ***
This became uncontrollable for me. My computer was clicking on whatever the mouse was over once per second (I changed the time in the above script from 10 to 1). Turning off Mouse Keys helped. Now instead of clicking, my computer was typing the number '5' repeatedly. Trouble is I couldn't stop it, or log off, or change user. Upon hard power down and restart the script was still there typing away.
While waiting on hold for Apple tech support I figured out I could Quit the Apple Script. If you follow the above instructions the script is an application. It is running in the dock. If you turn off Mouse Keys (alt 5 times) you at least have control of your mouse even though the computer is typing the number '5' repeatedly. Look in the dock for the script icon and quit it by one of two means:
- command / right click then quit
- select icon to make it the active application, command Q to quit
Happy scripting, and please don't be me. Read up on Apple's website (and other's are helpful) to learn a bit about Apple Scripts before you blindly cut and paste!