ttleser Posted January 30, 2012 Share Posted January 30, 2012 In the sample script below, I want to be able to have the $Radio_SearchEntireDrive radio button always disabled. However, I want to setup the script so that once someone begins typing in the $ComputerName input that the EntireDrive radio button gets enabled. Of course I want it disabled if the user deleted anything in the $ComputerName input. The below script works, but only if I click off the $ComputerName field, which isn't what I'm looking. Anyone have any thoughts? #include <GUIConstants.au3> #include <WindowsConstants.au3> GUICreate("test",400,300) GuiCtrlCreateLabel("UserName",10,10,110,20) $UserName = GUICtrlCreateInput("",130,10,100,20) GuiCtrlCreateLabel("ComputerName",10,50,110,20) $ComputerName = GUICtrlCreateInput("",130,50,100,20) $Radio_SearchProfileOnly = GUICtrlCreateRadio("User Profile Only?",250,10,100,20) GUICtrlSetResizing(-1,$GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE) GuiCtrlSetState(-1,$GUI_CHECKED) $Radio_SearchEntireDrive = GUICtrlCreateRadio("Entire Drive?",250,50,100,20) GuiCtrlSetState(-1,$GUI_DISABLE) GUISetState(@SW_SHOW) While 1 Sleep(50) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $ComputerName GuiCtrlSetState($Radio_SearchEntireDrive,$GUI_ENABLE) EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 30, 2012 Moderators Share Posted January 30, 2012 ttleser,Best way is to look for changes to the input content and then en/disable the radio like this: expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> GUICreate("test", 400, 300) GUICtrlCreateLabel("UserName", 10, 10, 110, 20) $UserName = GUICtrlCreateInput("", 130, 10, 100, 20) GUICtrlCreateLabel("ComputerName", 10, 50, 110, 20) $ComputerName = GUICtrlCreateInput("", 130, 50, 100, 20) $Radio_SearchProfileOnly = GUICtrlCreateRadio("User Profile Only?", 250, 10, 100, 20) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE) GUICtrlSetState(-1, $GUI_CHECKED) $Radio_SearchEntireDrive = GUICtrlCreateRadio("Entire Drive?", 250, 50, 100, 20) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 ; Sleep(50) ; Not needed as there is a GUIGetMsg in the loop $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $ComputerName GUICtrlSetState($Radio_SearchEntireDrive, $GUI_ENABLE) EndSelect WEnd Func _WM_COMMAND($hWHnd, $iMsg, $wParam, $lParam) ; If it was an update message from the correct input If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $ComputerName Then If GUICtrlRead($ComputerName) = "" Then GUICtrlSetState($Radio_SearchEntireDrive, $GUI_DISABLE) Else GUICtrlSetState($Radio_SearchEntireDrive, $GUI_ENABLE) EndIf EndIf EndFunc ;==>_WM_COMMANDIf you are not used to GUIRegisterMsg, then I recommend the GUIRegisterMsg tutorial in the Wiki. M23 footswitch 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...
Guest Posted January 30, 2012 Share Posted January 30, 2012 Give this Code a try, works fine. #include <GUIConstants.au3> #include <WindowsConstants.au3> GUICreate("test",400,300) GuiCtrlCreateLabel("UserName",10,10,110,20) $UserName = GUICtrlCreateInput("",130,10,100,20) GuiCtrlCreateLabel("ComputerName",10,50,110,20) $ComputerName = GUICtrlCreateInput("",130,50,100,20) $Radio_SearchProfileOnly = GUICtrlCreateRadio("User Profile Only?",250,10,100,20) GUICtrlSetResizing(-1,$GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE) GuiCtrlSetState(-1,$GUI_CHECKED) $Radio_SearchEntireDrive = GUICtrlCreateRadio("Entire Drive?",250,50,100,20) GuiCtrlSetState(-1,$GUI_DISABLE) GUISetState(@SW_SHOW) While 1 Sleep(50) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $ComputerName EndSelect If GUICtrlRead($ComputerName) = "" then If GUICtrlGetState($Radio_SearchEntireDrive) <> 144 Then GuiCtrlSetState($Radio_SearchEntireDrive,$GUI_DISABLE) EndIf Else If GUICtrlGetState($Radio_SearchEntireDrive) <> 80 Then GuiCtrlSetState($Radio_SearchEntireDrive,$GUI_ENABLE) EndIf EndIf ;MsgBox(0,0,GUICtrlRead($ComputerName,1)) WEnd Link to comment Share on other sites More sharing options...
ttleser Posted February 3, 2012 Author Share Posted February 3, 2012 @Aipion Thanks. Works like a champ. @Melba23 I will go look up the Tutorial, thanks.! 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