Complete noob looking for some help!

Hey all, I’m new to the mac world (just got a macbook pro) and I am looking for a bit of help on using a simple script. I play World of Warcraft and on my PC I used to use AutoHotkey to spam my number “4” button repeatedly (eliminates human error in game, yada yada). What I am looking for is a way to spam my same number 4 with WoW open on my mac. I have been scouring forum after forum looking for ways to do it and I have found a few things, but my problem is that frankly I don’t even know how to run the script…

Here is what I used for AutoHotkey:

#ifWinActive World of Warcraft
{
$4::
Loop
{
If not GetKetState(“4”, “P”)
break
Send 4
sleep 1
}
return
}

And here is what I found for use with applescript:

on idle
	tell application "System Events"
		tell application "Automator" to activate
		set CAPS to (get value of checkbox "⇪" of window 1 of application process "KeyboardViewerServer") as number
		if CAPS is 1 then
			tell application "World of Warcraft" to activate
			repeat until CAPS is 0
				set CAPS to (get value of checkbox "⇪" of window 1 of application process "KeyboardViewerServer") as number
				keystroke "4"
			end repeat
		end if
		return 1
	end tell
end idle

The problem is that I bring up the script editor tool and put the script in, I save it as an application script with the “always on” box checked, and then leave it running the background. When I first saved the script, it asked me to define Keyboard Viewer Server, whatever that is, and I told it automator because it was the only thing I recognized…

Now I saved it, and I have no idea how to run it. I go to wow, hit the caps lock, hit the number 4, and it doesnt spam the button. In fact, nothing happens at all. I try it without caps lock on, still nothing. I have no idea how to run this I guess, nor what else to do. Any help would be great, thank you so much in advance.

So I’ve been looking around a bit more and I found a different script to try out (and I think that I figured out sorta how to run them, but still not 100% sure).

tell application "System Events"
tell application "World of Warcraft" to activate
repeat
keystroke "1"
end repeat
end tell

However, when I save this as an application thing and run it, it freezes my computer…any ideas?

I would separate the tell blocks so that tell application “World of Warcraft” isn’t inside the tell application “System Events”. I’d also put a delay statement to duplicate your sleep statement, and limit the number of iterations:

tell application "World of Warcraft" to activate
tell application "System Events"
	repeat 100 times
		keystroke "1"
		delay 1
	end repeat
end tell

I tried this script out, and maybe I am not running it correctly, but it doesn’t seem to be allowing me to simply hold down my 1 key and have it spam that key…again I’m not sure if I even have it running properly.

I would recognise that script any where, Its one of mine.

You need to select the KeyboardViewerServer.app, instead of automator.
The below script may help you.
Otherwise if it asks for KeyboardViewerServer
The KeyboardViewerServer.app can be found at:

/System/Library/Components/KeyboardViewer.component/Contents/SharedSupport/

on idle
	tell application "System Events"
		tell application "/System/Library/Components/KeyboardViewer.component/Contents/SharedSupport/KeyboardViewerServer.app" to activate
		set CAPS to (get value of checkbox "⇪" of window 1 of application process "KeyboardViewerServer") as number
		if CAPS is 1 then
			tell application "World of Warcraft" to activate
			repeat until CAPS is 0
				set CAPS to (get value of checkbox "⇪" of window 1 of application process "KeyboardViewerServer") as number
				keystroke "4"
			end repeat
		end if
		return 1
	end tell
end idle

When the save script (app) is running, if the CAPS lock is down then 4’s are repeated.

The original post is here

cool Ill give this a shot in a bit, and yes it is your script :wink: I think you very much for your help!

When I double click “keyboardviewer.component” it says that there is nothing specified to open that with…am I missing something?

Sorry for late reply,
Have not logged in for a while.

Double clicking will not work.

If you want to go inside the “keyboardviewer.component” then select it, and control click it.
You will see the option to :Show Package Contents.