EndFunc Posted February 19, 2009 Share Posted February 19, 2009 Can't seem to figure out how to clear an input field once you click on it to enter a value. Example if I have "Enter ID" in the input as a default value, I want it to clear the field when you click it to enter the field. Not as easy as I thought. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 19, 2009 Share Posted February 19, 2009 Can't seem to figure out how to clear an input field once you click on it to enter a value.Example if I have "Enter ID" in the input as a default value, I want it to clear the field when you click it to enter the field.Not as easy as I thought. You can watch with ControlGetFocus() until your input control comes up. There are also messages you could register, but that might be deeper in the rabbit hole than you want to go. 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 Link to comment Share on other sites More sharing options...
exodius Posted February 19, 2009 Share Posted February 19, 2009 How about using a variable to keep track of whether you've cleared it once, then clearing it everytime it gets focused, like this: #include <GUIConstants.au3> $Clear = 0 $Form1 = GUICreate("Form1", 242, 99) $Input1 = GUICtrlCreateInput("Enter ID", 40, 24, 121, 21) $btn1 = GUICtrlCreateButton ("Catches initial focus", 40, 70) GUICtrlSetState ($btn1, $GUI_Focus) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If _IsFocused ($Form1, $Input1) And $Clear = 0 Then GUICtrlSetData ($Input1, "") $Clear = 1 ElseIf $Clear = 1 And Not _IsFocused ($Form1, $Input1) Then $Clear = 0 EndIf WEnd Func _IsFocused($hWnd, $nCID) Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd)) EndFunc ;==>_IsFocused aptyp 1 Link to comment Share on other sites More sharing options...
EndFunc Posted February 19, 2009 Author Share Posted February 19, 2009 Thanks for the replies, gives me a direction to go. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
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