Jump to content

Non Gui Input Loop


Recommended Posts

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

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 script

HotKeySet("{ESC}", "Terminate")

;;;; Load Menu and Execute Game ;;;;

; Run Defender

Run("game.exe")

; Wait for the Defender become active - it is titled "Defender" on English systems

WinWaitActive("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 Script

Func Terminate()

Send("!x")

Exit 0

EndFunc

Curt

I'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

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 by awesome
Link to comment
Share on other sites

Addition Question -

Is there a way to have NUMLOCK turned on within the script and then turn it OFF when exiting the Script?

Curt

Look at the Send command

Send("{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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...