queensoft Posted February 23, 2023 Share Posted February 23, 2023 (edited) I have a script that contains 2 GUIRegisterMsg, both with $WM_COMMAND parameter. First one is Hide edit scroll bars if not used - February 25, 2012 message: Second one is: Func _HotString_GUIKeyProc($hWnd, $Msg, $wParam, $lParam) $aRet = DllCall('user32.dll', 'int', 'GetKeyNameText', 'int', $lParam, 'str', "", 'int', 256) $sKeyName = $aRet[2] If $sKeyName Then _HotString_EvaluateKey($sKeyName) EndIf Return 0 ; EndFunc ;==>_HotString_GUIKeyProc I cannot post entire script. Yes, I understand there's a missing function (_HotString_EvaluateKey) and also a few others missing. You can replace _HotString_EvaluateKey with empty line, doesn't matter. The problem is: whichever GUIRegisterMsg is executed last - that one works and the other one doesn't work. Like this = scroll works, hotkeys probably don't work: GUIRegisterMsg($WM_COMMAND, "_HotString_GUIKeyProc") OnAutoItExitRegister("_HotString_OnAutoItExit") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Like this = scroll doesn't work, hotkeys probably work: GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_COMMAND, "_HotString_GUIKeyProc") OnAutoItExitRegister("_HotString_OnAutoItExit") How do I combine or execute both functions at the same time, each one as needed, of course ? Edited February 23, 2023 by queensoft Link to comment Share on other sites More sharing options...
argumentum Posted February 23, 2023 Share Posted February 23, 2023 Func _HotString_GUIKeyProc($hWnd, $Msg, $wParam, $lParam) _the_other($hWnd, $Msg, $wParam, $lParam) _the_next($hWnd, $Msg, $wParam, $lParam) Just like that. Daisy Chain them Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2023 Moderators Share Posted February 23, 2023 Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mistersquirrle Posted February 24, 2023 Share Posted February 24, 2023 Let me ask this, if you completely ignore the code from/relating to "Hide edit scroll bars if not used", does your GUIRegisterMsg($WM_COMMAND, "_HotString_GUIKeyProc") even work? Because doing a test, it does not seem to work for me... maybe I'm missing a key component in the function you excluded, _HotString_EvaluateKey(), but with what you've provided, your hotkey functionality does not work. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ScrollBarConstants.au3> #include <GuiScrollBars.au3> #include <GuiEdit.au3> #include <WinAPIConv.au3> Global $hGui Global $idLabel, $idEdit $hGui = GUICreate("Edit", 400, 400, 590, 200) $idLabel = GUICtrlCreateLabel('', 0, 0, 400, 20) $idEdit = GUICtrlCreateEdit('', 10, 10, 380, 380) GUIRegisterMsg($WM_COMMAND, "_HotString_GUIKeyProc") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _HotString_GUIKeyProc($hWnd, $Msg, $wParam, $lParam) ConsoleWrite('_HotString_GUIKeyProc' & @CRLF) Local $aRet Local $sKeyName ConsoleWrite('$hWnd: ' & $hWnd & ', $Msg: ' & $Msg & ', $wParam: ' & $wParam & ', $lParam: ' & $lParam & @CRLF) $aRet = DllCall('user32.dll', 'int', 'GetKeyNameText', 'int', $lParam, 'str', "", 'int', 256) $sKeyName = $aRet[2] If $sKeyName Then For $iIndex = 0 To UBound($aRet) - 1 ConsoleWrite('$aRet[' & $iIndex & ']: ' & $aRet[$iIndex] & @CRLF) Next ConsoleWrite('$lParam: ' & $sKeyName & @CRLF) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_HotString_GUIKeyProc Let me be clear, I don't do GUI stuff that often, and I certainly don't do GUIRegisterMsg much when I do. But looking at the data that's returned, it doesn't matter what I press, $lParam is always the same data. Besides that, I do not think that WM_COMMAND is what you want, I think what you want is WM_KEYDOWN, WM_CHAR and/or WM_NCLBUTTONDOWN. However, there's a problem with those, from the help file for GUIRegisterMsg: Quote Some controls consume internally specific Windows Message ID, so registering them will have no effect, e.g; WM_CHAR, WM_KEYDOWN, WM_KEYUP are consumed by an edit control. I would also recommend checking out and testing the code in this thread: Finally, do you actually want GUISetAccelerators? I think that this may be better for what you're looking for, though with the details provided it's hard to know what you're trying to accomplish. We ought not to misbehave, but we should look as though we could. Link to comment Share on other sites More sharing options...
paw Posted February 24, 2023 Share Posted February 24, 2023 Take a look at Link to comment Share on other sites More sharing options...
queensoft Posted February 27, 2023 Author Share Posted February 27, 2023 On 2/23/2023 at 5:35 PM, argumentum said: Func _HotString_GUIKeyProc($hWnd, $Msg, $wParam, $lParam) _the_other($hWnd, $Msg, $wParam, $lParam) _the_next($hWnd, $Msg, $wParam, $lParam) Just like that. Daisy Chain them I'm not sure I understand. But it's definetely not working for me. If I do this, first one is working (scroll bars OK). GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_COMMAND, "_HotString_GUIKeyProc") If I reverse the 2 commands, scroll bars stop working. Link to comment Share on other sites More sharing options...
queensoft Posted February 27, 2023 Author Share Posted February 27, 2023 On 2/24/2023 at 2:42 AM, mistersquirrle said: Let me ask this, if you completely ignore the code from/relating to "Hide edit scroll bars if not used", does your GUIRegisterMsg($WM_COMMAND, "_HotString_GUIKeyProc") even work? Because doing a test, it does not seem to work for me... maybe I'm missing a key component in the function you excluded, _HotString_EvaluateKey(), but with what you've provided, your hotkey functionality does not work. I also cannot fully test _HotString_GUIKeyProc function. It is not my script, I'm also missing lots of other components. I tried to strip everything extra, but cannot do that without breaking the entire script. Main problem is the order of the commands, please check above reply. Link to comment Share on other sites More sharing options...
queensoft Posted February 27, 2023 Author Share Posted February 27, 2023 On 2/24/2023 at 11:31 AM, paw said: Take a look at Looks promising. First quick test was OK. Sent script to client, waiting for reply. Link to comment Share on other sites More sharing options...
Lion66 Posted March 14, 2023 Share Posted March 14, 2023 On 2/27/2023 at 1:52 PM, queensoft said: On 2/23/2023 at 5:35 PM, argumentum said: Func _HotString_GUIKeyProc($hWnd, $Msg, $wParam, $lParam) _the_other($hWnd, $Msg, $wParam, $lParam) _the_next($hWnd, $Msg, $wParam, $lParam) Just like that. Daisy Chain them I'm not sure I understand. The point was that you register one function and launch the second function in it with the first line. argumentum 1 Link to comment Share on other sites More sharing options...
queensoft Posted March 14, 2023 Author Share Posted March 14, 2023 Sorry for the delay. Client never got back to me, but that is good news, means it's working! :) Thank you all, as always, very helpful. argumentum 1 Link to comment Share on other sites More sharing options...
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