Sandi's Additions I/O trouble

Well, as the title suggests, I’m having problems using Sandi’s Additions. Specifically, my script seems to fail when ClickMouse is called. Script Editor passed the syntax, but I assume I’m doing something wrong. Here’s the code:


	tell application "Diablo II (Carbon)"
		display dialog "Hot IP Address:" default answer ""
		set desiredIP to (text returned of result)
		set theNum to 1
		repeat
			try
				with timeout of 3600 seconds
					MouseClick at {540, 280} --click 'create game'
					TypeText("dclonebot" & theNum & tab & "soj") --game name and pass
					MouseClick at {882, 369} --set difficulty to hell
					MouseClick at {787, 320} --hit okay
					delay 20
					set ctIP to (do shell script "netstat")
					set IPchar1 to (character 162 of ctIP) as string
					set IPchar2 to (character 163 of ctIP) as string
					if (character 164 of ctIP) is not "." then set IPchar3 to (character 164 of ctIP) as string
					if (IPchar1 & IPchar2 & IPchar3) is equal to desiredIP then (beep) and (delay 999999)
					TypeText(esc) --bring up menu 
					delay 1
					TypeText((ASCII character 3)) --exit game
					theNum = (theNum + 1) --increment game number
				end timeout
			end try
		end repeat
	end tell

The script should create a game on Battle.net, check the server IP address, and, if it matches the one that I wish, beep and stay in the game.

Sandi’s is not OS X compatible. You may try XTools’ “move mouse” then “mouse click”:
http://www.osaxen.com/xtool.html

oh okay thx a lot lol

Er, is there any way I can insert the text then? Or does Sandi’s typing extension work for OS X?

If you use Panther, you can use “System Events” (already in your system) – just search this subforum for “keystroke” (you can use it also for “click” functions)
(There is also a beta version of “System Events” for Jaguar)
Or use Extra Suites, at http://www.kanzu.com/

I’m not running Panther, I’m on OS X.2, so I tried Extra Suites – the script idles for a while, then throws the error: ‘Apple Events timed out.’


tell application "Diablo II (Carbon)"
	activate
	display dialog "Hot IP Address:" default answer ""
	set desiredIP to (text returned of the result)
	set theNum to 1
	tell application "Extra Suites"
		repeat
			ES select menu item "Toggle Screen Mode" from menu "Game"
			ES move mouse {585, 265} --click 'create game'
			ES click mouse
			ES type string ("dclonebot" & theNum & tab & "soj") --game name and pass
			ES move mouse {707, 349} --set difficulty to hell
			ES click mouse
			ES move mouse {682, 305} --hit okay
			ES click mouse
			delay 20
			set ctIP to (do shell script "netstat")
			set IPchar1 to (character 162 of ctIP) as string
			set IPchar2 to (character 163 of ctIP) as string
			if (character 164 of ctIP) is not "." then set IPchar3 to (character 164 of ctIP) as string
			if (IPchar1 & IPchar2 & IPchar3) is equal to desiredIP then (beep) and (delay 999999)
			ES type string (esc) --bring up menu 
			delay 1
			ES type string ((ASCII character 3)) --exit game
			theNum = (theNum + 1) --increment game number
		end repeat
	end tell
end tell

Thanks in advance for your help. =]

Hmmm… Do you know where the script stops? You can open the apple-events log window and add some log commands to see what’s going on (or just use some display-dialogs).

do thing 1
log "thing 1 is done"
do thing 2
log "thing 2 is done"
... and so on

Wow, you’re fast.

Anyway, I’m having a totally different (and easier) problem now. I found out that Diablo II was being a jerk and not telling ES to do anything. Hence the timeout, I guess.

So, I just took the ES tell block out of Diablo II’s, and it’s pretty much working. I just need to know one more thing – how I might be able to get ES to hit the ESC key?

Thx again.

I think you’re looking for:

ES type key "escape"

That simple? =[