Page 1 of 1

Scripting help

Posted: March 7th, 2005, 1:08 am
by tault_ngm1
I am so noob to scripting within ACtool and auto it. But I chose actool for the script I am making but having a problem activateing it in game.

My question is this. I attempting to write a script to activate the script and another key to deactivate it.

So something like this if your following:

Code: Select all

SetActiveWindow Program

->KeyDown {DEL} Starts/Stops script
Loop 10
keydown e 1 sec
End

OR

SetActiveWindow Program

KeyDown `
Then 
Start/Stop
Loop 10
keydown e 1 sec
End


Posted: March 7th, 2005, 1:46 am
by tault_pickled
Wow someone decided to make their own script!

Ok here is some help and idea structure to achieve your goal.

Using Auto IT, I dont like ACTools that much :)

Example.au3

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Basic Auto IT Structure for HotKey Activate'a'Function ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Set partial Window title to use the Actions on!
$programTitle = "EverQuest II"

;Sets the activate Script Key -> DEL key
HotKeySet("{DEL}", "StartMyScript")

;Sets the pause Script Key -> END key
HotKeySet("{END}", "StopMyScript")

;Define what we want to do when script starts -> DEL pressed
Func StartMyScript()
	WinActivate($programTitle)
	For $i = 1 To 10 Step 1
		;For Loop, does this action below 10 times any time Del is pressed!
		Send("e")
		Sleep(1000)
	Next
EndFunc

;Define what we want to do when script is paused -> END pressed
Func StopMyScript()
	WinActivate($programTitle)
	While 1
		;Script is now paused forever until Del is pressed
		Sleep(2000)
	Wend	
EndFunc

MsgBox(0, "Begin", "Ready to begin Script?")


;Initiates Script, loops forever waiting for keys to be pressed.
While 1
	Sleep(1000)
Wend

Posted: March 7th, 2005, 2:03 am
by tault_ngm1
wow! thats more then I was looking for. :)

I will give this a shot and see how it works with the app. I'll let ya know either way ;)

Posted: March 7th, 2005, 2:31 am
by tault_ngm1
Ok, I am back after some testing. With your default config the program will open, as intended, but the toon would sit and jerk in place for about 5 seconds then stop.

I attempted to change the Hotkeys around thinking something could be conflicting, no change :/ So, I opened up textpad and tested there.... it works. But something is fobard.

Now, question I have about "Sleep", I assume this may be the same as "delay". So if I am right Send(w) will send a command for w to be pressed and held or pressed and lifted each time every 10 seconds?


(ps. I can move in game with the script I noted at first but I have to alt-tab out to activate it.)

Posted: March 7th, 2005, 3:03 am
by tault_pickled
The basic program above:

Press-> DEL -> it select's EQ2 Window, and presses E every second.

To press and HOLD E DOWN, is something that would need to be changed to suit.

like so

Code: Select all

  Send("{e down}")
  Sleep (5000) ;Wait 5 seconds whilst HOLDING down 'e' key.
  Send("{e up}") ;Release 'e' key
Good Luck!

Posted: March 7th, 2005, 3:34 am
by tault_ngm1
pickled wrote: Press-> DEL -> it select's EQ2 Window, and presses E every second.
Well, i'm not mechanically illiterate :D

Which I changed $programtitle = textpad to see if it's sending an output. It was. But for some reason the game app did not recognize it.

Code: Select all

  Send("{e down}") 
  Sleep (5000) ;Wait 5 seconds whilst HOLDING down 'e' key. 
  Send("{e up}") ;Release 'e' key
Works perfect now! almost... upon further testing {DEL} nor {END} work while the game app is active. However, if you alt-tab out to another app then select {DEL} or {END} it calls the program back and stops or runs the script again.

I am looking at the script, with what knowledge I have about scripting, I am unable to define the issue why it only activates when the app is inactive.

Posted: March 7th, 2005, 4:08 am
by tault_pickled
I just tested it with and it seemed to work fine however I think I know why it's having trouble with EQ2, is that its trying to access EQ2 to fast (depends on computer processor speed).

Anyway here is the remedy.

Add this:
Sleep(2500)

After each:
WinActivate($pr...

Q. What does this do? (for the mechanically illiterate):
A. It waits an extra 2.5secs for the EQ2 application to become 'active' on the desktop before sending keys E (when del is pressed to start it).

Posted: March 7th, 2005, 5:10 am
by tault_pickled
Oh yeh!, you might wanna UN-ASSIGN del and end in EQ2 :P

Posted: March 7th, 2005, 5:34 am
by tault_ngm1
I just want to make a quick note before proceeding, I appreciate the help you have provided so far. :)

I attempted to add the additional line but did not work for me. As far as computer processor speed.. not sure that would be my specific problem since I paid over 5k for the main components inside the box.

Step by step process. I start eqii and login as usual. Once I am in the game I launch the script, using it as an auto run for testing purposes.

I minimize eq before calling {DEL}. After calling {DEL} eq becomes active as expected and runs the script for 10seconds. After which call {DEL} again and run for another 10 seconds. Now, during the time I am running I call {END}, expecting to halt, but the toon continues to run... run.. run.. ok runs for over a minute. After which I attempt to call {DEL} again and nothing happens. It seems that it is paused until I exit autoit.

I also attempted this script on my server running BF1942/MOH/DOD to auto run, but what happens here is entirely different. After starting the script it activates the specified application and I am able to run for 10 seconds, but can not stop using {END} I need to wait it out. Once I have stoped moving I call the {DEL} function again, but will not run. So I alt-tab out into another application and call the {DEL} function again, now the character is auto-running again, if I alt-tab out again into another application while running and call the {END} function I am able to stop running.

hope I did not loose you there..

Posted: March 7th, 2005, 5:53 am
by tault_pickled
Hmm try chaging the Sleep(2000) in StopScript to (100), otherwise I have absolutely no idea, works ok for me when I tested it with notepad and doom III.

If you want the char to stop running when you press end you need to make the appropriate actions in Stop section.