Sign in to follow this  
Followers 0
w0uter

_IsPressed

2 posts in this topic

Just a small rewrite to make it faster and use a bit less memory.

Note it is not compatible with the old one but can easely be modified to. just ad a '0x' & like the old one has.

But its verry silly to have a func that FORCES you to input in hex if the dllcall accepts decimal too.

Anyways have fun.

$val = 100000

$t = TimerInit()
For $i = 0 To $val
    _IsPressed(1)
Next
ConsoleWrite(TimerDiff($t) & @LF)

$t = TimerInit()
For $i = 0 To $val
    __sPressed(1)
Next
ConsoleWrite(TimerDiff($t) & @LF)


Func _IsPressed($v_R, $v_dll = 'user32.dll')
    $v_R = DllCall($v_dll, 'int', 'GetAsyncKeyState', 'int', $v_R)
    Return (Not @error And BitAND($v_R[0], 0x8000) = 0x8000) * 1
EndFunc   ;==>_IsPressed

Func __sPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc   ;==>__sPressed

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What about this?

Func _IsPressed( $key )
    Local $aR = DllCall('user32.dll', 'int', 'GetAsyncKeyState', 'int', $key)
    Return $aR[0] = -32767
EndFunc

EDIT:

make it faster and use a bit less memory

okay, nevermind. Edited by erifash

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