Jump to content

_IsPressed


w0uter
 Share

Recommended Posts

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

Link to comment
Share on other sites

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