Sign in to follow this  
Followers 0
E1M1

How to detect if input box is clicked?

9 posts in this topic

#1 ·  Posted (edited)

I am trying to make script detect if input box is clicked, but I cant find out how. I have tried using WM_MOUSEFIRST and WM_NOTIFY, but they dont work.

Also If GUIGetMsg() = $input Then MsgBox(0,0,"clicked") doesn't help me.

$WM_MOUSEFIRST =  0x0200

$hGui = GUICreate("click on input", 75, 20)
$input = GUICtrlCreateInput("click me", 0, 0, 75, 20)
GUIRegisterMsg($WM_MOUSEFIRST, "WM_MOUSEFIRST")
GUISetState()

While True
    if GUIGetMsg() = -3 Then Exit
WEnd

Func WM_MOUSEFIRST($hWnd, $iMsg, $iWparam, $iLparam)
    #forceref $hWnd, $iMsg, $iWparam
    Local $hWndFrom, $tNMHDR
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Switch $hWndFrom
        Case $input
            MsgBox(0, 0, "clicked")
    EndSwitch
    Return
EndFunc   ;==>WM_NOTIFY
Edited by E1M1

edited

Share this post


Link to post
Share on other sites



E1M1,

Is the "primary" button x01 or x02?

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Not exactly sure but I guess x01. How can this help?


edited

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

E1M1,

You are registering message x02. If the primary mouse click generates x01 nothing will ever happen. Have you tried it with x01?

kylomas

edit: addition - guigetmsg has some symbolics defined for events, particularly $gui_event_primarydown

also: you want to detect if the input area is clicked, regardless of whether or not it contains data?

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Try this:

$WM_MOUSEFIRST =  0x0200
$WM_SETCURSOR = 0x0020
$hGui = GUICreate("click on input", 75, 20)
$input = GUICtrlCreateInput("click me", 0, 0, 75, 20)

GUIRegisterMsg($WM_SETCURSOR, "WM_MOUSEFIRST")
GUISetState()

While True
    if GUIGetMsg() = -3 Then Exit
WEnd

Func WM_MOUSEFIRST($hWnd, $iMsg, $iWparam, $iLparam)
    #forceref $hWnd, $iMsg, $iWparam
    If BitAND($iLparam, 0x00010000) Then MsgBox(0, 0, "clicked")
    Return
EndFunc

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Than you UEZ. How do I detect what control received that message?

I tried following but it doesnt work. No compiler errors but program just crashes when it happens to receive that signal.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>

$WM_MOUSEFIRST =  0x0200
;~ $WM_SETCURSOR = 0x0020
$hGui = GUICreate("click on input", 750, 20)
$input = GUICtrlCreateInput("click me", 0, 0, 75, 20)

GUIRegisterMsg($WM_SETCURSOR, "WM_MOUSEFIRST")
GUISetState()

While True
    if GUIGetMsg() = -3 Then Exit
WEnd

Func WM_MOUSEFIRST($hWnd, $iMsg, $iWparam, $iLparam)
    #forceref $hWnd, $iMsg, $iWparam
    Local $hWndFrom, $iCode, $tNMHDR, $tEnLink, $cpMin, $cpMax, $tMsgFilter
    $tNMHDR = DllStructCreate($tagNMHDR, $iLparam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Switch $hWndFrom
        Case $input
            MsgBox(0,0,0)

    EndSwitch
;~     Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by E1M1

edited

Share this post


Link to post
Share on other sites

By trying some Message Codes and see what happens when clicking into the input control but I don't know whether it is working properly for more complex GUIs, e.g. another input control.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

E1M1,

Sorry, confused vl value for $wm_keyfirst. You asked for an expert therefore I'll stay out of it.

kylomas

you have to uncomment $wm_s4etcursor in your previous code.

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

E1M1,

How about the @gui_ctrlhandle or @gui_ctrlid macros?

kylomas

sorry, none worked, I promise I'll but out now.

@UEZ - this is from the MS doc "WM_SETCURSOR Message

Sent to a window if the mouse causes the cursor to move within a window and mouse input is not captured."

What does "and mouse input is not captured" mean?

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
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
Sign in to follow this  
Followers 0