Sign in to follow this  
Followers 0
nonplayablecharacter

need more input help for gui

4 posts in this topic

#1 ·  Posted (edited)

i've been trying to get a msg box to pop up when the input box for a gui is clicked i've spent about the past half hour trying to do it...can someone give me some guidance i've been trying to do it with GUICtrlGetState but no success...basically i want the input to act like a button that will deactivate if its not $GUI_FOCUS

CODE
#include <GUIConstants.au3>

GUICreate("GUI",320,120)

GUICtrlCreateInput ( "", 10, 5, 300, 20)

GUISetState ()

While 1

$msg = GUIGetMsg()

Switch $msg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

Wend

Edited by nonplayablecharacter

You can always count on me for the dumb questions ;)My Scripts:Rikku

Share this post


Link to post
Share on other sites



i've been trying to get a msg box to pop up when the input box for a gui is clicked i've spent about the past half hour trying to do it...can someone give me some guidance i've been trying to do it with GUICtrlGetState but no success...basically i want the input to act like a button that will deactivate if its not $GUI_FOCUS

#include <GUIConstants.au3>

GUICreate("GUI",320,120)
GUICtrlCreateInput ( "", 10, 5, 300, 20)

GUISetState () 

While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Wend
I don't see an event for clicking on an input control, but there is one if you hit enter and there are any changes to the input. Demo used GuiOnEventMode:
#include <GuiConstants.au3>

Opt("GuiOnEventMode", 1)

Global $hGUI = GUICreate("Test", 500, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUICtrlCreateLabel("Type something and hit enter:", 10, 10, 480, 20)
Global $ctrlInput = GUICtrlCreateInput("", 10, 40, 480, 20)
GUICtrlSetOnEvent(-1, "_InputBox")
GUICtrlCreateButton("Enable", 100, 250, 100, 30)
GUICtrlSetOnEvent(-1, "_ButtonHit")
GUICtrlCreateButton("Disable", 300, 250, 100, 30)
GUICtrlSetOnEvent(-1, "_ButtonHit")

GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

Func _InputBox()
    ConsoleWrite("Text = " & ControlGetText(@GUI_WinHandle, "", @GUI_CtrlHandle) & @LF)
EndFunc

Func _ButtonHit()
    Switch ControlGetText(@GUI_WinHandle, "", @GUI_CtrlHandle)
        Case "Enable"
            ControlEnable(@GUI_WinHandle, "", $ctrlInput)
            ControlFocus(@GUI_WinHandle, "", $ctrlInput)
        Case "Disable"
            ControlDisable(@GUI_WinHandle, "", $ctrlInput)
    EndSwitch
EndFunc

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I don't see an event for clicking on an input control

yea thats my problem...is there way to make an invisible button that i can put on top of an input? (Sorry but the code you posted is not much help) or anyone else can answer that question

Edited by nonplayablecharacter

You can always count on me for the dumb questions ;)My Scripts:Rikku

Share this post


Link to post
Share on other sites

yea thats my problem...is there way to make an invisible button that i can put on top of an input? (Sorry but the code you posted is not much help) or anyone else can answer that question

The problem is, input controls use mouse clicks internally (i.e. to change cursor position) so they don't pass the message to the GUI. Consider this version of the demo:
#include <GuiConstants.au3>

Global Const $WM_LBUTTONDOWN = 0x0201 

Opt("GuiOnEventMode", 1)

Global $hGUI = GUICreate("Test", 500, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUICtrlCreateLabel("Type something and hit enter:", 10, 10, 480, 20)
Global $ctrlInput = GUICtrlCreateInput("", 10, 40, 480, 20)
GUICtrlSetOnEvent(-1, "_InputBox")
GUICtrlCreateButton("Enable", 100, 250, 100, 30)
GUICtrlSetOnEvent(-1, "_ButtonHit")
GUICtrlCreateButton("Disable", 300, 250, 100, 30)
GUICtrlSetOnEvent(-1, "_ButtonHit")

GUIRegisterMsg($WM_LBUTTONDOWN, "_Mouse_L_Button")

GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

Func _InputBox()
    ConsoleWrite("Text = " & ControlGetText(@GUI_WinHandle, "", @GUI_CtrlHandle) & @LF)
EndFunc

Func _ButtonHit()
    Switch ControlGetText(@GUI_WinHandle, "", @GUI_CtrlHandle)
        Case "Enable"
            ControlEnable(@GUI_WinHandle, "", $ctrlInput)
            ControlFocus(@GUI_WinHandle, "", $ctrlInput)
        Case "Disable"
            ControlDisable(@GUI_WinHandle, "", $ctrlInput)
    EndSwitch
EndFunc

Func _Mouse_L_Button($hWnd, $Msg, $wParam, $lParam)
    If $hWnd = $hGUI Then ConsoleWrite("Focus = " & ControlGetFocus($hWnd) & @LF)
EndFunc

You only get a response from the $WM_LBUTTONDOWN message when you click outside the input control.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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