Sign in to follow this  
Followers 0
thc

GetAsyncKeyState help

3 posts in this topic

I'm having trouble interpreting the return value. When I run this bit of script:

;2E DEL key

$result = DllCall("user32.dll", "int", "GetAsyncKeyState", "int", 0x2E)

MsgBox(0,"",$result[0])

With the del key down, I get -32767. Without the del key down, I get 0.

Now, according to the MSDN, there are 2 bits. If the MSB is set then the key is down. But what is the MSB when the result is -32767???

Share this post


Link to post
Share on other sites



http://msdn.microsoft.com/en-us/library/ms646293%28VS.85%29.aspx

That's the function on MSDN, and it says that if the value is 0, then basically somethings wrong.

Why don't you just use _IsPressed()?


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok, thanks. I didn't know of the _isPressed function. But it still doesn't seem to be able to do what I want to do. Basically, I want to set a hotkey so that when I press it down, it does a MouseDown, and when I release the hotkey, it does a MouseUp. If anyone has any insights or code examples, I'd very much appreciate it. Thanks :D

Edit: Ah, nevermind, I got it to work (code below). Thanks again :huggles:

#include <misc.au3>
;                  2D INS key
;                  2E DEL key

hotkeyset("{ins}","null")

While(1)
    sleep(100)
    if(_isPressed("2D")) then
        MouseDown("left")
        _clickhold()
    EndIf
WEnd

func _clickhold()
    while(_isPressed("2D"))
        sleep(100)
    WEnd
    MouseUp("left")
EndFunc

func null()
EndFunc
Edited by thc

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