Sign in to follow this  
Followers 0
randy17

Sub execution on ANY key and/or mouse action

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Not sure if pushing is allowed. I'll just do it >_

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

helpfile: _WinAPI_SetWindowsHookEx

wow, a lot of code for this simple objective but it will do

dank u wel >_<

Share this post


Link to post
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
Sign in to follow this  
Followers 0