Jump to content

Recommended Posts

Posted (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 by queensoft
  • Moderators
Posted

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.

Expand  

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:

  Reveal hidden contents

 

Posted

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.

Expand  

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.

Posted
  On 2/23/2023 at 3: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 ;) 

Expand  

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.

Posted
  On 2/24/2023 at 12: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.

Expand  

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.

  • 2 weeks later...
Posted
  On 2/27/2023 at 11:52 AM, queensoft said:
  On 2/23/2023 at 3: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 ;) 

Expand  

I'm not sure I understand.

Expand  

The point was that you register one function and launch the second function in it with the first line.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...