Jump to content

Active Control in GUI


Go to solution Solved by Nine,

Recommended Posts

Posted (edited)

is there some other way to detect Active Control in GUI that I'm missing?

; https://www.autoitscript.com/forum/topic/212043-active-control-in-gui/?do=findComment&comment=1535173

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $Form1 = GUICreate("Form1", 286, 165, 853, 226)
Local $Input1 = GUICtrlCreateInput("Input1", 10, 10, 121, 21)
Local $Input2 = GUICtrlCreateInput("Input2", 10, 40, 121, 21)
Local $Input3 = GUICtrlCreateInput("Input3", 10, 70, 121, 21)
Local $Input4 = GUICtrlCreateInput("Input4", 10, 100, 121, 21)
Local $Input5 = GUICtrlCreateInput("Input5", 10, 130, 121, 21)
Local $Input6 = GUICtrlCreateInput("Input6", 140, 10, 121, 21)
Local $Input7 = GUICtrlCreateInput("Input7", 140, 40, 121, 21)
Local $Input8 = GUICtrlCreateInput("Input8", 140, 70, 121, 21)
Local $Input9 = GUICtrlCreateInput("Input9", 140, 100, 121, 21)
Local $Input10 = GUICtrlCreateInput("Input10", 140, 130, 121, 21)
GUISetState(@SW_SHOW)

Local $n = Random(0, 9, 1)
Send("{TAB " & $n & "}")

Local $id = GetActiveCtrl($Form1)
Local $cInputData = GUICtrlRead($id)
ConsoleWrite("ActiveCtrl=" & $cInputData & @CRLF)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func GetActiveCtrl($hGUI)
    Local $ActiveCtrl = ControlGetFocus($hGUI)
    ConsoleWrite("$ActiveCtrl=" & $ActiveCtrl & @CRLF)

    Local $hControl = ControlGetHandle($hGUI, "", $ActiveCtrl)
    ConsoleWrite("$hControl=" & $hControl & @CRLF)

    Local $hCtrl
    For $i = 3 To 100
        $hCtrl = GUICtrlGetHandle($i)
        If @error Then ExitLoop
        If $hCtrl = $hControl Then Return $i
    Next
    Return SetError(1, 0, -1)
EndFunc   ;==>GetActiveCtrl

Every comment is appreciated!
Thank you very much  :)

 

Edited by ioa747
correction

I know that I know nothing

Link to comment
Share on other sites

  • Solution

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