cserrins Posted July 14, 2011 Share Posted July 14, 2011 I am trying to build a GUI that will show a checkbox if a particular file exists. If the file does not exist, the checkbox is hidden. The code below sort of works. This is stripped down from a much larger project. When I run this if a file named test.txt is not on the desktop, no checkbox. If the file is there, then the checkbox appears. However, the checkbox disappears for good as soon as I move my mouse over it or on the same horizontal plane as the checkbox. Hoping someone can help. expandcollapse popup;-----------------------------INCLUDES---------------------------------------------------------- #include <GUIConstants.au3> #include <GUIConstantsEx.au3> ;------------------------------VARIABLES-------------------------------------------------------- Dim $extrabutton, $adsi, $main, $add_adsi, $select, $msg ;------------------------------MAIN-------------------------------------------------------- Opt('MustDeclareVars', 1) $main = GUICreate("Purpose", 380, 270) GUICtrlCreateLabel("Identify the reason", 55, 10) $select = GUICtrlCreateButton("Select", 145, 230, 90) $adsi = GUICtrlCreateCheckbox("Enable ADSI",15,190,375) $extrabutton = GUICtrlCreateCheckbox("Enable sweetness",100,190,375) GUICtrlSetState($extrabutton,$gui_hide) If FileExists(@DesktopDir & '\test.txt') Then GUICtrlSetState($extrabutton,$gui_show) EndIf GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() ExitLoop Case $msg = $select And GUICtrlRead($adsi) = $GUI_CHECKED $add_adsi = True ContinueCase EndSelect WEnd Link to comment Share on other sites More sharing options...
guinness Posted July 14, 2011 Share Posted July 14, 2011 (edited) Something like this?#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> Global $iButton, $iExtra = -1 ; Make sure you set the variable to negative else GUIGetMsg() will fail since it's always returning 0 if no activity. GUICreate("Purpose", 380, 270) GUICtrlCreateLabel("Identify the reason.", 5, 10) $iButton = GUICtrlCreateButton("Select", 145, 230, 90) GUICtrlCreateCheckbox("Enable ADSI", 15, 190) If FileExists(@DesktopDir & '\Test.txt') Then $iExtra = GUICtrlCreateCheckbox("Enable Sweetness", 100, 190) EndIf GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() ExitLoop Case $iButton If _IsChecked($iExtra) Then MsgBox(64, "Checked!", "Example.") EndIf EndSwitch WEnd Func _IsChecked($iControlID) Return GUICtrlRead($iControlID) = $GUI_CHECKED EndFunc ;==>_IsCheckedAnd I would recommend using Local & Global deceleration in the future, so for Global you would use if the Variable is required elsewhere & Local if only required in the Function.Edit: Removed Width! Edited July 14, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Syed23 Posted July 14, 2011 Share Posted July 14, 2011 you are correct cserrins! The checkbox get disappers when i move the cusrso. when i searched in forum i got a look on below link. Will it be happening? i am using Autoit 3.3.6.1 version. Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] Link to comment Share on other sites More sharing options...
cserrins Posted July 14, 2011 Author Share Posted July 14, 2011 I am using version 3.3.7.14. The issue is not blinking, the first time I move my mouse onto (near) the checkbox it disappears forever. Thank you guinness for your code, but I have the same exact result. Link to comment Share on other sites More sharing options...
guinness Posted July 14, 2011 Share Posted July 14, 2011 (edited) Whoops, I was being an idiot >> I removed the Width. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> Global $iButton, $iExtra = -1 ; Make sure you set the variable to negative else GUIGetMsg() will fail since it's always returning 0 if no activity. GUICreate("Purpose", 380, 270) GUICtrlCreateLabel("Identify the reason.", 5, 10) $iButton = GUICtrlCreateButton("Select", 145, 230, 90) GUICtrlCreateCheckbox("Enable ADSI", 15, 190) If FileExists(@DesktopDir & '\Test.txt') Then $iExtra = GUICtrlCreateCheckbox("Enable Sweetness", 100, 190) EndIf GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() ExitLoop Case $iButton If _IsChecked($iExtra) Then MsgBox(64, "Checked!", "Example.") EndIf EndSwitch WEnd Func _IsChecked($iControlID) Return GUICtrlRead($iControlID) = $GUI_CHECKED EndFunc ;==>_IsChecked OR reduce the Width to something like 100. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> Global $iButton, $iExtra = -1 ; Make sure you set the variable to negative else GUIGetMsg() will fail since it's always returning 0 if no activity. GUICreate("Purpose", 380, 270) GUICtrlCreateLabel("Identify the reason.", 5, 10) $iButton = GUICtrlCreateButton("Select", 145, 230, 90) GUICtrlCreateCheckbox("Enable ADSI", 15, 190, 100) If FileExists(@DesktopDir & '\Test.txt') = 0 Then $iExtra = GUICtrlCreateCheckbox("Enable Sweetness", 100, 190, 100) EndIf GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() ExitLoop Case $iButton If _IsChecked($iExtra) Then MsgBox(64, "Checked!", "Example.") EndIf EndSwitch WEnd Func _IsChecked($iControlID) Return GUICtrlRead($iControlID) = $GUI_CHECKED EndFunc ;==>_IsChecked Edited July 14, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
cserrins Posted July 14, 2011 Author Share Posted July 14, 2011 guinness Thank you, so I went back to my original code, which worked, it was simply removing that width. That was killing me. Thank you so much. I have changed to Global 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