awesome Posted April 20, 2006 Share Posted April 20, 2006 I have a game I want to automate. The executable loads up a Main Menu and to play the game you have to type ALT+P to play the game which is then executed. To exit the game you press the ESC key. So I have the script running find to do a wait for name and then send("!P") to play the game and its window comes up fine. Can someone please tell me how I can get autoit to loop and look for the ESC key to be pressed and then do a send("!X") to have the game menu Exit with a ALT-X? Curt Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted April 20, 2006 Share Posted April 20, 2006 download beta and check out _ispressed Link to comment Share on other sites More sharing options...
neogia Posted April 20, 2006 Share Posted April 20, 2006 Or you can use HotKeySet("{ESC}", "_ExitGame") Func _ExitGame() Send("!x") EndFunc [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia Link to comment Share on other sites More sharing options...
awesome Posted April 20, 2006 Author Share Posted April 20, 2006 I'll try this out today and let you know, thank you for the quick reply and help. Curt Or you can use HotKeySet("{ESC}", "_ExitGame") Func _ExitGame() Send("!x") EndFunc Link to comment Share on other sites More sharing options...
awesome Posted April 20, 2006 Author Share Posted April 20, 2006 okay, did some tweaking and tested out, this execute the Midway Arcade game execute, loads its menu to screen, sends the ALT+P to autoplay the game, once the ESC key is pressed the game exits, goes back to the Main Menu, autoit then sends the ALT-X to exit the menu and close it, then the script Exits. Works like a charm:; Load Game Menu, Execute Game Play,Press Esc to terminate scriptHotKeySet("{ESC}", "Terminate");;;; Load Menu and Execute Game ;;;;; Run DefenderRun("game.exe"); Wait for the Defender become active - it is titled "Defender" on English systemsWinWaitActive("Defender"); Now that the Defender window is active type ALT-P (Alt is !)Send("!P")While 1 Sleep(100)WEnd;;;;;;;; Hotkey Function - look for Esc, close game and Menu, Exit ScriptFunc Terminate() Send("!x") Exit 0EndFuncCurtI'll try this out today and let you know, thank you for the quick reply and help.Curt Link to comment Share on other sites More sharing options...
awesome Posted April 20, 2006 Author Share Posted April 20, 2006 (edited) Addition Question - Is there a way to have NUMLOCK turned on within the script and then turn it OFF when exiting the Script? Edited - Nevermind, simply tried Send("{NUMLOCK ON}") and then on exit - Send("{NUMLOCK OFF"}) Curt Edited April 20, 2006 by awesome Link to comment Share on other sites More sharing options...
GaryFrost Posted April 20, 2006 Share Posted April 20, 2006 Addition Question -Is there a way to have NUMLOCK turned on within the script and then turn it OFF when exiting the Script?CurtLook at the Send commandSend("{NUMLOCK on}") ; NUMLOCK (on/off/toggle) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now