Jump to content
Sign in to follow this  

Ibeam Cursor in Input box....Get Vars

Recommended Posts

is it possible to to get the variable of what input box your cursor is in??

say my input box are these

$R1I1 = GUICtrlCreateInput ($VR1I1, 90, 20, $Box_XL, 20)
    $R1I2 = GUICtrlCreateInput ($VR1I2, 140, 20, $Box_XL, 20)
    $R1I3 = GUICtrlCreateInput ($VR1I3, 190, 20, $Box_XL, 20)

i put my cursor in $R1I1 can i get it to show what input box my cursor is in as the variable ($R1I1)??

Share this post

Link to post
Share on other sites

with slight modification yep.

#include <GuiConstants.au3>

; comment out the following 4 lines if using beta or above
Global Const $WM_COMMAND = 0x0111
Global Const $EN_CHANGE = 0x300
Global Const $EN_SETFOCUS = 0x100
Global Const $EN_KILLFOCUS = 0x200

Global Const $DebugIt = 1

Global $DEFAULTINPUTDATA = "Click and type something here..."
Global $NONEAACTIVECOLOR = 0x989898
Global $Input


Func _Main()
    Local $GUI, $ExitButton, $y = 20
    $GUI = GUICreate("Check Inputs Demo", 280, 150)

    For $x = 0 To 2
        If IsArray($Input) Then
            ReDim $Input[UBound($Input) + 1]
            Dim $Input[1]
        $Input[UBound($Input) - 1] = GUICtrlCreateInput($DEFAULTINPUTDATA, 15, $y, 250, 20)
        GUICtrlSetColor(-1, $NONEAACTIVECOLOR)
        $y += 40

    $ExitButton = GUICtrlCreateButton("Exit", 110, 125, 60, 20)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)

    ControlFocus($GUI, "", $ExitButton)


    While 1
        Switch GUIGetMsg()
            Case $ExitButton, $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

Func _Input_Changed($hControl)
    If $DebugIt Then _DebugPrint("Input Changed:" & GUICtrlRead($hControl))
EndFunc   ;==>_Input_Changed

Func _Input_SetFocus($hControl)
    If $DebugIt Then _DebugPrint("Input SetFocus")
    If GUICtrlRead($hControl) = $DEFAULTINPUTDATA Then GUICtrlSetData($hControl, "")
    GUICtrlSetColor($hControl, 0x000000)
EndFunc   ;==>_Input_SetFocus

Func _Input_KillFocus($hControl)
    If $DebugIt Then _DebugPrint("Input KillFocus")
    If Not StringLen(GUICtrlRead($hControl)) Then GUICtrlSetData($hControl, $DEFAULTINPUTDATA)
    GUICtrlSetColor($hControl, $NONEAACTIVECOLOR)
EndFunc   ;==>_Input_KillFocus

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16) ; high word
    Local $nID = BitAND($wParam, 0xFFFF) ; low word
    Local $hCtrl = $lParam
    For $x = 0 To UBound($Input) - 1
        Switch $nID
            Case $Input[$x]
                Switch $nNotifyCode
                    Case $EN_CHANGE
                    Case $EN_SETFOCUS
                    Case $EN_KILLFOCUS
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
EndFunc   ;==>MY_WM_COMMAND

Func _DebugPrint($s_Text, $line = @ScriptLineNumber, $file = @ScriptName)
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+======================================================" & @LF & _
            "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_Text & @LF & _
            "+======================================================" & @LF)
EndFunc   ;==>_DebugPrint

SciTE for AutoItDirections for Submitting Standard UDFs


Don't argue with an idiot; people watching may not be able to tell the difference.


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...