Sign in to follow this  
Followers 0
Dart

To wait for a keystroke?

6 posts in this topic

I'm trying to make my script continue on a keystroke. I understand the hotkeys, but that's not what i'm trying to use.

I'd like my script to wait at a certain point and then once the left mouse button is pressed, i'd like it to continue.

I've been searching for a while on how to intercept the left mouse button click.

The closest thing i found was under _IsPressed custom function. Is this the only option?

I would basically be doing something like this...

while 1
  sleep(100)
  if mouse-button-pressed then
      exit loop
WEnd

Seems basic but i can't find any documentation on it after searching/reading the help files and searching the forums.

I'm looking for something very basic for which i don't have to scan dll files or add libraries if possible.

Share this post


Link to post
Share on other sites



You probably should have changed the title of this thread to 'mouse click' instead of keystroke.

Anyway, for mouse clicks, you can use the _MouseSetOnEvent() UDF

Share this post


Link to post
Share on other sites

#include <Misc.au3>

$dll = DllOpen("user32.dll")

Do
    Sleep ( 250 )
Until _IsPressed("01", $dll)
DllClose($dll)


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Yea i guess i was thinking about keystrokes but for user-friendliness toward my ultimate goal it would be better to wait for a mouse click. A keystroke would be fine too though, just not as user-friendly.

The link you provided me with seems nice, but it is overly complex. Is there really no simple or built-in function or variable that tells you what the last button/keystroke clicked is?

Share this post


Link to post
Share on other sites

#include <Misc.au3>

$dll = DllOpen("user32.dll")

Do
    Sleep ( 250 )
Until _IsPressed("01", $dll)
DllClose($dll)

Thanks for your quick reply. Yea, i found this under the help page included in the editor...

I'm sure it would work fine but i was looking for something with which i wouldn't have to get into dll files or include libraries.

I guess that since two experienced coders have not offered a simpler solution, this must be the most simple currently available.

Thank you both for your help,

regards,

Dart

Share this post


Link to post
Share on other sites

That's what's nice about the UDf, the DLL work is already done for you so you don't have to worry about it.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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