nonplayablecharacter Posted August 19, 2008 Posted August 19, 2008 (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 August 19, 2008 by nonplayablecharacter You can always count on me for the dumb questions ;)My Scripts:Rikku
PsaltyDS Posted August 19, 2008 Posted August 19, 2008 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: expandcollapse popup#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
nonplayablecharacter Posted August 20, 2008 Author Posted August 20, 2008 (edited) I don't see an event for clicking on an input controlyea 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 August 20, 2008 by nonplayablecharacter You can always count on me for the dumb questions ;)My Scripts:Rikku
PsaltyDS Posted August 20, 2008 Posted August 20, 2008 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: expandcollapse popup#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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now