Jump to content

[Solved] How do I detect click on an input control?


CYCho
 Share

Recommended Posts

The following code does not work.

#include <GUIConstantsEx.au3>

GUICreate(" My GUI input control", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1)
Local $idInput = GUICtrlCreateInput("", 10, 5, 300, 20)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idInput
            MsgBox(0, "", "Input control was clicked")
    EndSwitch
WEnd

Having not found a handy way to make it work, I created a label control beneath the input control and it simulates detection of click on input control.

#include <GUIConstantsEx.au3>

GUICreate(" My GUI input control", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1)
Local $idLabel = GUICtrlCreateLabel("", 10, 5, 300, 20)
Local $idInput = GUICtrlCreateInput("", 10, 5, 300, 20)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idLabel
            MsgBox(0, "", "Input control was clicked")
    EndSwitch
WEnd

Is this a viable way? Or is there a better way to make this happen?

Edited by CYCho
Link to comment
Share on other sites

Message hook will let you do it :

#include <WinAPI.au3>
#include <GUIConstants.au3>

GUICreate(" My GUI input control", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1)
Local $idInput = GUICtrlCreateInput("", 10, 5, 300, 20)
$wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam")
$wProcOld = _WinAPI_SetWindowLong(GUICtrlGetHandle($idInput), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))

GUISetState(@SW_SHOW)

While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
  EndSwitch
WEnd

DllCallbackFree($wProcHandle)

Func _WindowProc($hWnd, $Msg, $wParam, $lParam)
  If $hWnd = GUICtrlGetHandle($idInput) And $Msg = $WM_LBUTTONDOWN Then
    ConsoleWrite("-> Left mouse simple click" & @LF)
  EndIf
  Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam)
EndFunc   ;==>_WindowProc

 

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>

Local $GUI = GUICreate(" My GUI input control", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1)
Local $idInput = GUICtrlCreateInput("", 10, 5, 300, 20)
Local $CurInfo

GUISetState(@SW_SHOW)

While 1
    $CurInfo = GUIGetCursorInfo($GUI)
    If $CurInfo[4] = $idInput And $CurInfo[2] = 1 Then
        MsgBox(64 + 262144, '', '')
    EndIf
    ;=============================================================================
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    Sleep(100)
WEnd

Or like this

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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