AgentSmith15 Posted January 17, 2009 Author Posted January 17, 2009 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 Well, Converting the keys over to decimal isn't a problem. It's the first 2 keys out of 8 that are not responding to key presses. [center][/center]
AgentSmith15 Posted January 18, 2009 Author Posted January 18, 2009 Can anyone verify that the keys Scroll and Pause are not working? I'm don't have another computer handy, and I want to rule out the computer. [center][/center]
FireFox Posted January 18, 2009 Posted January 18, 2009 @AgentSmith15 Works great with _IsPressed just take a look to my UDF (see my signature) Cheers, FireFox.
Spiff59 Posted January 19, 2009 Posted January 19, 2009 (edited) I stuck in a GUI so banging on keys would stop modifying the test code showing in the active SciTE window. I changed your "send" to a "tooltip", since sending text to SciTE was also counterproductive to running your script in a test mode. Changing the return codes for Scroll and Pause to 145 and 19, instead of 91 and 19, and then loosening up your test on $iFlag (as the keydown hook seems to return a 0 value for both Scroll and Pause) seems to have things working. The following runs fine on my PC: expandcollapse popupGlobal Const $WH_KEYBOARD_LL = 13 Global $AllKeys[256][3] Local $UsedKeys[8][3] = [ _ [145, "y@ " , "scroll Please watch your language on our servers. Thanks."], _; SCROLL [19, "y@ " , " pause msg"], _; PAUSE [45, "y@ " , " insert msg"], _; INSERT [46, "y@ " , " delete msg"], _; DELETE [36, "sm_kick ", " home msg"], _; HOME [33, "sm_kick ", " pageup msg"], _; PAGEUP [34, "sm_kick ", " pagedown msg"], _; PAGEDOWN [35, "sm_kick ", " end msg"]]; 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] $hGUI = GUICreate("Test", 400, 300) GUISetState() 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") ; MsgBox(1,"",$iFlag & " " & $vkCode & " " & $lParam & " " & $wParam) If $iFlag < 2 Then If $AllKeys[$vkCode][0] Then ; $PlayerName= ClipGet() $PlayerName= "<playername>" ToolTip($AllKeys[$vkCode][1] & $PlayerName & $AllKeys[$vkCode][2], 1) EndIf EndIf EndFunc;==>_KeyProc Func OnAutoItExit() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hHook) DllCallbackFree($pStub_KeyProc) EndFunc;==>OnAutoItExit EDIT: Trashed the "While $iFlag" in Favor of an "If..." PS - I don't know if you've officially adopted this Array-heavy approach, but I think it makes a lot of sense. It requires a bit more memory, and adds some one-time initialization processing up front. But plugging your used keys into an empty 256-element key-table simplifies your main processing loop greatly and butchers out a ton of tedious code. The meat-and-potatos part of the script ought to run pretty smooth. You could also add a trap for a 9th key in like 10 seconds, just by adding an entry to the used-keys table. Edited January 19, 2009 by Spiff59
AgentSmith15 Posted January 19, 2009 Author Posted January 19, 2009 (edited) Wow, that works great :/ So you changed the $iFlag < 1 to $iFlag < 2 . I'm am curious was there any other modification to make the script start working? Does trashing the while loop make things cleaner? [EDIT] Thank You x 500 !!! Ingenious idea to make a window so the script doesn't suddenly start writing all over the source. It's happened numerous times and yet you are the first to to think of such a ingenious solution. [/EDIT] Edited January 19, 2009 by AgentSmith15 [center][/center]
Spiff59 Posted January 19, 2009 Posted January 19, 2009 (edited) Wow, that works great :/ So you changed the $iFlag < 1 to $iFlag < 2 . I'm am curious was there any other modification to make the script start working? Does trashing the while loop make things cleaner? [EDIT] Thank You x 500 !!! Ingenious idea to make a window so the script doesn't suddenly start writing all over the source. It's happened numerous times and yet you are the first to to think of such a ingenious solution. [/EDIT] I changed $iFlag = 1 to < 2 to allow keys that return zero in that field (scroll and pause). I haven't researched exactly what keys return a 1 (or now, 0 or 1) for the downkey event in iFlag, but if there's a key that does, and you haven't selected to process it via the used-key array, then the while statement would get you stuck in an infinite loop. You don't need to set up a loop there, as there is no chance that the value of $iFlag can change inside the loop, it was basically acting like an "If", but with the potential to cause a lockup. EDIT: Did a little testing and I think I'd remove the "If $iFlag" statement altogether. It looks like about every key returns either a 0 or 1. The one exception I encountered was "ALT" which returns a 32. The unique vkcode for ALT won't get a hit on the keys array anyway, so you're testing iFlag over and over for no real benefit. Edited January 19, 2009 by Spiff59
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now