Jump to content

Multiple GUIRegisterMsg($WM_COMMAND - (Moved)


 Share

Recommended Posts

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 by queensoft
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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.

#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

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

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

  • 2 weeks later...
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.

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