Jump to content

A better way to write the following script


Recommended Posts

I was going to suggest some indexing earlier, and then someone else did.

Why not take the subscripting a little farther?

;----- Choose HotKeys here -----
; Change the hotkeys to whatever you want them to be (see helpfile)
Global $aHotKeys[9][3] = [ _
    ["{F1}", "y@ "      , ", Please watch your language on our servers. Thanks."], _;AbuseLang
    ["{F2}", "y@ "      , ", Please keep inappropiate content off of our servers. Thank you."], _;FoulLang
    ["{F3}", "y@ "      , ", Please do not spray your spray again in our servers. Thank you."], _;BadSpray
    ["{F4}", "y@ "      , ", Please change your name, as <these words> are not allowed on our servers. Thank you."], _;BadName
    ["{F5}", "sm_kick " , " Repeated use of foul/abusive language"], _;AbuseKick
    ["{F6}", "sm_kick " , " Repeated use of inappropiate language"], _;FoulKick
    ["{F7}", "sm_kick " , " Inappropiate spray"], _;SprayKick
    ["{F8}", "sm_kick " , " Inappropiate name"]];NameKick
Global $aSize = (UBound($aHotKeys) - 1)
    
;----- Assign HotKeys -----
For $i = 1 to $aSize
    HotKeySet($aHotKeys[$i][0],"HotKeyPressed")
Next

;===== LOOP =====
While 1
    Sleep(100)
WEnd

;----- Commands to send after HotKey pressed -----
Func HotKeyPressed()
    
    If winactive("YoureApp", "") Then
        For $i = 1 to $aSize
            If @HotKeyPressed = $aHotKeys[$i][0] Then
                Send($aHotKeys[$i][1] & ClipGet() & $aHotKeys[$i][2])
                ExitLoop
            EndIf
        Next
    Else
        HotKeySet(@HotKeyPressed)
        Send(@HotKeyPressed) 
        HotKeySet(@HotKeyPressed,"HotKeyPressed")
    EndIf
EndFunc
Edited by Spiff59
Link to comment
Share on other sites

  • Replies 65
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

But the game I am using doesn't recognize hotkeys set by other applications, and it only seems to work with IsPressed().

Ok, here it is hammering _Ispressed 80 times per second.

#include <Misc.au3>

;----- Choose HotKeys here -----
; Change the hotkeys to whatever you wantthem to be (see helpfile)
Global $aHotKeys[9]
$aHotKeys[1] = 70;AbuseLang F1
$aHotKeys[2] = 71;FoulLang F2
$aHotKeys[3] = 72;BadSpray F3
$aHotKeys[4] = 73;BadName F4

$aHotKeys[5] = 74;AbuseKick F5
$aHotKeys[6] = 75;FoulKick F6
$aHotKeys[7] = 76;SpayKick F7
$aHotKeys[8] = 77;NameKick F8

;----- open dll -----
$dll = DllOpen("user32.dll")

;===== LOOP =====
While 1
    Sleep(100)
;----- loop through keys -----
    For $i = 1 to (UBound($aHotKeys) - 1)
        If _IsPressed($aHotKeys[$i],$dll) Then HotKeyPressed($aHotKeys[$i])
    Next
WEnd

;----- Commands to send after HotKey pressed -----
Func HotKeyPressed($Key)
    
    Local $sPlayerName = ClipGet()
    
    Switch $key
        Case $aHotKeys[1];AbuseLang
            Send('y@ ' & $sPlayerName & ', Please watch your language on our servers. Thanks.', 1)
        Case $aHotKeys[2];FoulLang
            Send('y@ ' & $sPlayerName & ', Please keep inappropiate content off of our servers. Thank you.', 1)
        Case $aHotKeys[3];BadSpray
            Send('y@ ' & $sPlayerName & ', Please do not spray your spray again in our servers. Thank you.', 1)
        Case $aHotKeys[4];BadName
            Send('y@ ' & $sPlayerName & ', Please change your name, as <these words> are not allowed on our servers. Thank you.', 1)
            
        Case $aHotKeys[5];AbuseKick
            Send('sm_kick ' & $sPlayerName & ' "Repeated use of foul/abusive language"', 1)
        Case $aHotKeys[6];FoulKick
            Send('sm_kick ' & $sPlayerName & ' "Repeated use of inappropiate language"', 1)
        Case $aHotKeys[7];SpayKick
            Send('sm_kick ' & $sPlayerName & ' "Inappropiate spray"', 1)
        Case $aHotKeys[8];NameKick
            Send('sm_kick ' & $sPlayerName & ' "Inappropiate name"', 1)
    EndSwitch

EndFunc

Note, there is another way to do this without using IsPressed, but it the code could very easily be used to key-log, so I'm not going to post it. See the helpfile if you find your cpu is melting from the above script. :)

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Cannot use the hotkeyset so that script is ruled out. But the 3rd example has no pauses, so the CPU is going to get hammered to detect a keypress.

10 seconds is a long time for a pause, but I figure anywhere from 20 to 200 milliseconds is a okay amount.

the 10 second pause was just to illustrate the point; I had not considered CPU usage, thanks for making me open my mind :D

what is another method, without posting the offending code, to capture a keystroke? I was under the impression (albeit without the proper knowledge) that hotkeyset and ispressed were the only methods to capture the users input... I'm not making a keylogger, but need to know when a user sends specific keys to the AS400 emulator so I know to poll the AS400 emulator for screen changes. I tried hotkeyset with passthroughs to the program, but it was not reliable as I am (or rather I was) using some of the keys depending upon what is displayed and what function keys are available by the parent app at that time. I ended up using hotkeyset bound to keys the emulator does not use and removing the automatic user prompts I had hoped to include in my app. :o I won't be able to (entirely too many changes now) use it in my app, but for future reference it would be nice to know.

sorry to hijiack, but only a simple response is expected :)

Link to comment
Share on other sites

Note, there is another way to do this without using IsPressed, but it the code could very easily be used to key-log, so I'm not going to post it. See the helpfile if you find your cpu is melting from the above script. :)

*COUGH* SetWindowsHookEx */COUGH*

If you would have never said anything about keyloggers it would have never crossed my mind. So doesn't that defeat the purpose?

Anyways I want the subject changed no more talk about malicious intentions.

Edited by AgentSmith15
Link to comment
Share on other sites

According to this thread of the fastest ways to write things For/Next are faster than While?

http://www.autoitscript.com/forum/index.php?showtopic=51604

So to make a infinite loop with a For Loop would I do this?

For $i = 1 to 2 Step 0

I have a feeling this is breaking rules, but I gotta go to bed. I will test in the morning...

Link to comment
Share on other sites

According to this thread of the fastest ways to write things For/Next are faster than While?

http://www.autoitscript.com/forum/index.php?showtopic=51604

So to make a infinite loop with a For Loop would I do this?

For $i = 1 to 2 Step 0
Interesting!

A quick test...

$TestLength = 10000000

$i = 0
$timer = TimerInit()
While 1
    $i += 1
    If $i = $TestLength Then 
        ConsoleWrite(TimerDiff($timer) & @CRLF)
        ExitLoop
    EndIf
WEnd


$i = 0
$timer = TimerInit()
For $t = 1 to 2 Step 0
    $i += 1
    If $i = $TestLength Then 
        ConsoleWrite(TimerDiff($timer) & @CRLF)
        ExitLoop
    EndIf
Next

For 10 million loops,

WHILE LOOP = 36.2 seconds

FOR LOOP = 32.1 seconds

Not much in it, but if you're going for pure speed, why not?!? :)

Note - this won't speed up the _IsPressed functions!

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

So I hacked up a script, but I am having some problems with a few keys.

I'm trying to figure out why the Scroll Key and the Pause Key are not getting recognized by my script. I must be getting the key code wrong :/

Also I am I unregistering User32 properly?

Does anyone know a good way to organize this script into a neater format?

Global Const $WH_KEYBOARD_LL = 13
Global Const $KEY = 257

Global Const $SCROLL = 91
Global Const $PAUSE = 19
Global Const $INSERT = 45
Global Const $DELETE = 46
Global Const $HOME = 36
Global Const $PAGEUP = 33
Global Const $PAGEDOWN = 34
Global Const $END = 35
ClipPut("")

Global $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)

Global $hHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", _
        "int", $WH_KEYBOARD_LL, _
        "ptr", DllCallbackGetPtr($pStub_KeyProc), _
        "hwnd", $hmod[0], _
        "dword", 0)
$hHook = $hHook[0]

While 1
    Sleep(10)
WEnd

Func _KeyProc($nCode, $wParam, $lParam)
    If $nCode < 0 Then
        Local $aRet = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hHook, "int", $nCode, "wparam", $wParam, _
                "lparam", $lParam)
        Return $aRet[0]
    EndIf

    Local $KBDLLHOOKSTRUCT = DllStructCreate("dword vkCode;dword scanCode;dword flags;dword time;ptr dwExtraInfo", $lParam)

    Local $vkCode = DllStructGetData($KBDLLHOOKSTRUCT, "vkCode")
    Local $iFlag = DllStructGetData($KBDLLHOOKSTRUCT, "flags")

    While $iFlag = 1
        Switch $vkCode
            Case $SCROLL
                Call("AbuseLang")
            Case $PAUSE
                Call("FoulLang")
            Case $INSERT
                Call("BadSpray")
            Case $DELETE
                Call("BadName")
            Case $HOME
                Call("AbuseKick")
            Case $PAGEUP
                Call("FoulKick")
            Case $PAGEDOWN
                Call("SprayKick")
            Case $END
                Call("NameKick")
        EndSwitch
    WEnd
EndFunc   ;==>_KeyProc

;Warnings Below
Func AbuseLang()
    $PlayerName = ClipGet()
    Send('y@ ' & $PlayerName & ', Please watch your language on our servers. Thanks.', 1)
EndFunc   ;==>AbuseLang

Func FoulLang()
    $PlayerName = ClipGet()
    Send('y@ ' & $PlayerName & ', Please keep inappropiate content off of our servers. Thank you.', 1)
EndFunc   ;==>FoulLang

Func BadSpray()
    $PlayerName = ClipGet()
    Send('y@@ ' & $PlayerName & ', Please do not spray your spray again in our servers. Thank you.', 1)
EndFunc   ;==>BadSpray

Func BadName()
    $PlayerName = ClipGet()
    Send('y@@ ' & $PlayerName & ', Please change your name, as <these words> are not allowed on our servers. Thank you.', 1)
EndFunc   ;==>BadName

;Kicks Below
Func AbuseKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Repeated use of foul/abusive language"', 1)
EndFunc   ;==>AbuseKick

Func FoulKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Repeated use of inappropiate language"', 1)
EndFunc   ;==>FoulKick

Func SprayKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Inappropiate spray"', 1)
EndFunc   ;==>SprayKick

Func NameKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Inappropiate name"', 1)
EndFunc   ;==>NameKick

Func OnAutoItExit()
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hHook)
    DllCallbackFree($pStub_KeyProc)
EndFunc   ;==>OnAutoItExit
Edited by AgentSmith15
Link to comment
Share on other sites

I searched for the function which pointed me to this:

http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx

It appears you have to return 0. It works without high CPU, so I'm happy :)

And as I said before, no need to use call.

Check this out:

Global Const $WH_KEYBOARD_LL = 13
Global Const $KEY = 257

Global Const $SCROLL = 91
Global Const $PAUSE = 19
Global Const $INSERT = 45
Global Const $DELETE = 46
Global Const $HOME = 36
Global Const $PAGEUP = 33
Global Const $PAGEDOWN = 34
Global Const $END = 35
ClipPut("")

Global $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)

Global $hHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", _
        "int", $WH_KEYBOARD_LL, _
        "ptr", DllCallbackGetPtr($pStub_KeyProc), _
        "hwnd", $hmod[0], _
        "dword", 0)
$hHook = $hHook[0]

While 1
    Sleep(20)
WEnd

Func _KeyProc($nCode, $wParam, $lParam)
    If $nCode < 0 Then
        Local $aRet = DllCall ("user32.dll", "long", "CallNextHookEx", "hwnd", $hHook, "int", $nCode, "wparam", $wParam, _
                "lparam", $lParam)
        Return $aRet[0]
    EndIf

    Local $KBDLLHOOKSTRUCT = DllStructCreate("dword vkCode;dword scanCode;dword flags;dword time;ptr dwExtraInfo", $lParam)

    Local $vkCode = DllStructGetData($KBDLLHOOKSTRUCT, "vkCode")
    Local $iFlag = DllStructGetData($KBDLLHOOKSTRUCT, "flags")
    While $iFlag = 1
        Switch $vkCode
            Case $SCROLL
                AbuseLang ()
                Return 0
            Case $PAUSE
                FoulLang ()
                Return 0
            Case $INSERT
                BadSpray ()
                Return 0
            Case $DELETE
                BadName ()
                Return 0
            Case $HOME
                AbuseKick ()
                Return 0
            Case $PAGEUP
                FoulKick ()
                Return 0
            Case $PAGEDOWN
                SprayKick ()
                Return 0
            Case $END
                NameKick ()
                Return 0
        EndSwitch
    WEnd
EndFunc  ;==>_KeyProc

;Warnings Below
Func AbuseLang()
    $PlayerName = ClipGet()
    Send('y@ ' & $PlayerName & ', Please watch your language on our servers. Thanks.', 1)
EndFunc  ;==>AbuseLang

Func FoulLang()
    $PlayerName = ClipGet()
    Send('y@ ' & $PlayerName & ', Please keep inappropiate content off of our servers. Thank you.', 1)
EndFunc  ;==>FoulLang

Func BadSpray()
    $PlayerName = ClipGet()
    Send('y@@ ' & $PlayerName & ', Please do not spray your spray again in our servers. Thank you.', 1)
EndFunc  ;==>BadSpray

Func BadName()
    $PlayerName = ClipGet()
    Send('y@@ ' & $PlayerName & ', Please change your name, as <these words> are not allowed on our servers. Thank you.', 1)
EndFunc  ;==>BadName

;Kicks Below
Func AbuseKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Repeated use of foul/abusive language"', 1)
EndFunc  ;==>AbuseKick

Func FoulKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Repeated use of inappropiate language"', 1)
EndFunc  ;==>FoulKick

Func SprayKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Inappropiate spray"', 1)
EndFunc  ;==>SprayKick

Func NameKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Inappropiate name"', 1)
EndFunc  ;==>NameKick

Func OnAutoItExit()
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hHook)
    DllCallbackFree($pStub_KeyProc)
EndFunc  ;==>OnAutoItExit

Cheers,

Brett

Link to comment
Share on other sites

I searched for the function which pointed me to this:

http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx

It appears you have to return 0. It works without high CPU, so I'm happy :)

And as I said before, no need to use call.

Check this out:

Global Const $WH_KEYBOARD_LL = 13
Global Const $KEY = 257

Global Const $SCROLL = 91
Global Const $PAUSE = 19
Global Const $INSERT = 45
Global Const $DELETE = 46
Global Const $HOME = 36
Global Const $PAGEUP = 33
Global Const $PAGEDOWN = 34
Global Const $END = 35
ClipPut("")

Global $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)

Global $hHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", _
        "int", $WH_KEYBOARD_LL, _
        "ptr", DllCallbackGetPtr($pStub_KeyProc), _
        "hwnd", $hmod[0], _
        "dword", 0)
$hHook = $hHook[0]

While 1
    Sleep(20)
WEnd

Func _KeyProc($nCode, $wParam, $lParam)
    If $nCode < 0 Then
        Local $aRet = DllCall ("user32.dll", "long", "CallNextHookEx", "hwnd", $hHook, "int", $nCode, "wparam", $wParam, _
                "lparam", $lParam)
        Return $aRet[0]
    EndIf

    Local $KBDLLHOOKSTRUCT = DllStructCreate("dword vkCode;dword scanCode;dword flags;dword time;ptr dwExtraInfo", $lParam)

    Local $vkCode = DllStructGetData($KBDLLHOOKSTRUCT, "vkCode")
    Local $iFlag = DllStructGetData($KBDLLHOOKSTRUCT, "flags")
    While $iFlag = 1
        Switch $vkCode
            Case $SCROLL
                AbuseLang ()
                Return 0
            Case $PAUSE
                FoulLang ()
                Return 0
            Case $INSERT
                BadSpray ()
                Return 0
            Case $DELETE
                BadName ()
                Return 0
            Case $HOME
                AbuseKick ()
                Return 0
            Case $PAGEUP
                FoulKick ()
                Return 0
            Case $PAGEDOWN
                SprayKick ()
                Return 0
            Case $END
                NameKick ()
                Return 0
        EndSwitch
    WEnd
EndFunc ;==>_KeyProc

;Warnings Below
Func AbuseLang()
    $PlayerName = ClipGet()
    Send('y@ ' & $PlayerName & ', Please watch your language on our servers. Thanks.', 1)
EndFunc ;==>AbuseLang

Func FoulLang()
    $PlayerName = ClipGet()
    Send('y@ ' & $PlayerName & ', Please keep inappropiate content off of our servers. Thank you.', 1)
EndFunc ;==>FoulLang

Func BadSpray()
    $PlayerName = ClipGet()
    Send('y@@ ' & $PlayerName & ', Please do not spray your spray again in our servers. Thank you.', 1)
EndFunc ;==>BadSpray

Func BadName()
    $PlayerName = ClipGet()
    Send('y@@ ' & $PlayerName & ', Please change your name, as <these words> are not allowed on our servers. Thank you.', 1)
EndFunc ;==>BadName

;Kicks Below
Func AbuseKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Repeated use of foul/abusive language"', 1)
EndFunc ;==>AbuseKick

Func FoulKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Repeated use of inappropiate language"', 1)
EndFunc ;==>FoulKick

Func SprayKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Inappropiate spray"', 1)
EndFunc ;==>SprayKick

Func NameKick()
    $PlayerName = ClipGet()
    Send('sm_kick ' & $PlayerName & ' "Inappropiate name"', 1)
EndFunc ;==>NameKick

Func OnAutoItExit()
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hHook)
    DllCallbackFree($pStub_KeyProc)
EndFunc ;==>OnAutoItExit

Cheers,

Brett

Works great, but still I am not able to get the Scroll and Pause hotkeys to work. I double checked the virtual key codes and also checked that it was converted into decimal correctly as well.

Does anyone have any ideas why IsPressed works, and SetWindows doesn't?

Link to comment
Share on other sites

Does anyone know a good way to organize this script into a neater format?

Array make prettier. Me like.

Global Const $WH_KEYBOARD_LL = 13
Global Const $KEY = 257

Global $AllKeys[256][3]
Local $UsedKeys[8][3] = [ _
    [91, "y@"     , "Please watch your language on our servers. Thanks."], _; SCROLL
    [19, "y@"     , "msg2"], _; PAUSE
    [45, "y@"     , "msg3"], _; INSERT
    [46, "y@"     , "msg4"], _; DELETE
    [36, "sm_kick", "msg5"], _; HOME
    [33, "sm_kick", "msg6"], _; PAGEUP
    [34, "sm_kick", "msg7"], _; PAGEDOWN
    [35, "sm_kick", "msg8"]]; END
For $i = 0 to 7
    $AllKeys[$UsedKeys[$i][0]][0] = 1
    $AllKeys[$UsedKeys[$i][0]][1] = $UsedKeys[$i][1]
    $AllKeys[$UsedKeys[$i][0]][2] = $UsedKeys[$i][2]
Next    
    
ClipPut("")

Global $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)

Global $hHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", _
        "int", $WH_KEYBOARD_LL, _
        "ptr", DllCallbackGetPtr($pStub_KeyProc), _
        "hwnd", $hmod[0], _
        "dword", 0)
$hHook = $hHook[0]

While 1
    Sleep(20)
WEnd

Func _KeyProc($nCode, $wParam, $lParam)
    If $nCode < 0 Then
        Local $aRet = DllCall ("user32.dll", "long", "CallNextHookEx", "hwnd", $hHook, "int", $nCode, "wparam", $wParam, _
                "lparam", $lParam)
        Return $aRet[0]
    EndIf

    Local $KBDLLHOOKSTRUCT = DllStructCreate("dword vkCode;dword scanCode;dword flags;dword time;ptr dwExtraInfo", $lParam)

    Local $vkCode = DllStructGetData($KBDLLHOOKSTRUCT, "vkCode")
    Local $iFlag = DllStructGetData($KBDLLHOOKSTRUCT, "flags")
    While $iFlag = 1
        If $AllKeys[$vkCode][0] Then 
            Send($AllKeys[$vkCode][1] & ClipGet() & $AllKeys[$vkCode][2], 1)
            ExitLoop
        EndIf
    WEnd
EndFunc ;==>_KeyProc

Func OnAutoItExit()
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hHook)
    DllCallbackFree($pStub_KeyProc)
EndFunc ;==>OnAutoItExit

(Pardon, I was too lazy to cut-and-paste all the exact messages from the procs into the array)

Link to comment
Share on other sites

According to:

http://delphi.about.com/od/objectpascalide/l/blvkc.htm

some of your hexadecimal values for keys such as Insert and Scroll are wrong..

VK_INSERT 2D INS key as opposed to the 45 you had

VK_PAUSE 13 PAUSE key as opposed to 19 you had

Some of your others appear wrong and some others appear right..

I'm not exactly sure. I always used the VKC's from that list and my scripts using IsPressed() have always worked with the correct corresponding keys..

Link to comment
Share on other sites

It always accepts them for me.

I'll go check some of my scripts a second..

EDIT:

It appears I always declared them as a string (the hexadecimals) as opposed to an integer which is how your consts are set up.. such as

If _IsPressed("2D", $dll) Then

Although that is with _IsPressed.. but IDK

Edited by Arakard
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...