Terenz Posted May 31, 2013 Share Posted May 31, 2013 (edited) Hi, I want to make a func to clean one or more inputbox on click. My script: #include <GUIConstants.au3> $Form1 = GUICreate("Form1", 242, 99) $Input1 = GUICtrlCreateInput("Some text", 40, 24, 121, 21) $Input2 = GUICtrlCreateInput("", 40, 50, 121, 21) $btn1 = GUICtrlCreateButton("Initial focus", 180, 70) GUICtrlSetState($btn1, $GUI_Focus) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch _Focus($Form1, $Input1, "") WEnd Func _Focus($hHandle, $Control, $Data) If ControlGetHandle($hHandle, "", ControlGetFocus($hHandle)) = GUICtrlGetHandle($Control) Then If GUICtrlRead($Control) <> "" Then GUICtrlSetData($Control, $Data) Do Until ControlGetHandle($hHandle, "", ControlGetFocus($hHandle)) <> GUICtrlGetHandle($Control) EndIf EndIf EndFunc ;==>_Focus Work fine but has only one big problem, i can't close the GUI if the $Input1 is focused ( by Do Until ) How i can resolve? Thanks Edited May 31, 2013 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 31, 2013 Moderators Share Posted May 31, 2013 Terenz,What exactly do you want to happen? Saying "clean one or more inputbox on click" is extremely vague - which input and what click where? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Terenz Posted May 31, 2013 Author Share Posted May 31, 2013 Click "inside" a inputbox and if the inputbox has some text delete it Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 31, 2013 Moderators Share Posted May 31, 2013 (edited) Terenz,Understood. Is this a "prompt" text to suggest what needs to be entered there or any old text that was already entered? M23 Edited May 31, 2013 by Melba23 Typo Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Terenz Posted May 31, 2013 Author Share Posted May 31, 2013 Any old text. I'll set an "default" text to the inputbox, if user click on inputbox it will automatically delete, then the user write something and click on another thing, if click again on inputbox the txt will be automaticcally delete etc. Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted May 31, 2013 Moderators Solution Share Posted May 31, 2013 Terenz, Perhaps like this: #include <GUIConstantsEx.au3> #include <WinAPI.au3> Global $aInput[2] $hGUI = GUICreate("Test", 500, 500) $aInput[0] = GUICtrlCreateInput("Some text 1", 10, 10, 200, 20) $aInput[1] = GUICtrlCreateInput("Some text 2", 10, 40, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYUP For $i = 0 To UBound($aInput) - 1 If _WinAPI_GetFocus() = GUICtrlGetHandle($aInput[$i]) Then GUICtrlSetData($aInput[$i], "") ExitLoop EndIf Next EndSwitch WEnd Any use? M23 PlayHD 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted June 1, 2013 Share Posted June 1, 2013 (edited) Was just doing something like this, when I found this post. Thought I'd add an alternative. #include <GUIConstantsEx.au3> $hGUI = GUICreate("GUI", 220, 100) $iInput1 = GUICtrlCreateInput("Default", 10, 10, 200, 20) $iInput2 = GUICtrlCreateInput("Default", 10, 40, 200, 20) $iButton = GUICtrlCreateButton("OK",100,70) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYUP $aInfo = GUIGetCursorInfo() _ClearData($aInfo[4]) ; Pass control ID to function Case $iButton _ResetData() EndSwitch WEnd Func _ClearData(Const $Ctrl) If Not $Ctrl Or $Ctrl = $iButton Then ; Return if it's a control we do not want cleared Return EndIf GUICtrlSetData($Ctrl, "") EndFunc Func _ResetData() GUICtrlSetData($iInput1, "Input 1") GUICtrlSetData($iInput2, "Input 2") EndFunc Edited June 1, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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