Jump to content

Sub execution on ANY key and/or mouse action


Recommended Posts

Hi all,

hope there is a answer to my problem >_<

I'm writing a bot for a game (in fact the bot is finished)

The bot controls mouse and keyboard, works flawless. BUT:

From time to time i want to interact with the game myself.

Atm i stop the bot, do what i need and restart it afterwards.

A much more elegant version would be, if i had something

like the old basic "anykey". Something like

hotkeyset ("anykey", _sleep2seconds()) ;go to sleep for 2 secs if any key is pressed

Of course i have to make sure it doesn't get nested. np

If there would be something like "anymouse" it would be like heaven :(

Any ideas?

Edited by randy17
Link to comment
Share on other sites

Hi all,

hope there is a answer to my problem >_<

I'm writing a bot for a game (in fact the bot is finished)

The bot controls mouse and keyboard, works flawless. BUT:

From time to time i want to interact with the game myself.

Atm i stop the bot, do what i need and restart it afterwards.

A much more elegant version would be, if i had something

like the old basic "anykey". Something like

hotkeyset ("anykey", _sleep2seconds()) ;go to sleep for 2 secs if any key is pressed

Of course i have to make sure it doesn't get nested. np

If there would be something like "anymouse" it would be like heaven :(

Any ideas?

There is a Pause button on the system tray.

Link to comment
Share on other sites

There is a Pause button on the system tray.

Not elegant >_<

Game window loses focus and i have to use the mouse (and aim exactly). Worse than it is now

Atm: esc (closes script) - do what i want - doubleclick on script (gives focus back to game automaticly)

I could think of writing a gui for my script just to have a pause button

but imho thats overkill (and not much better than close/open)

Some kind of "on anykey" would simply be the most charming

Link to comment
Share on other sites

Try to play with this.

#Include <WinAPIEx.au3>

Global $Time, $pTime = _WinAPI_GetIdleTime()

While 1
    Sleep(10)
    $Time = _WinAPI_GetIdleTime()
        ConsoleWrite('Active' & @CR)
    EndIf
    $pTime = $Time
WEnd

WinAPIEx.au3

Edited by Yashied
Link to comment
Share on other sites

All you need to do is look at the example in the HotKeySet() function in the helpfile. It has a Pause ability. The only other thing to worry about is if you want the script to continue where it left off, or to restart at the beginning.

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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...