DarkBoost Posted January 21, 2009 Share Posted January 21, 2009 Trying to update the button after being pressed. Would I need to recall the AdlibEnable and if so how can I do this within the Loop? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Test GUI",180,50) GUICtrlCreateLabel("Desktop -> data.txt",10,15) $a=GUICtrlCreateButton("Delete",120,10) GUICtrlSetState($a,$GUI_DISABLE) GUISetState(@SW_SHOW) AdlibEnable("Btn",200) While 1 $msg = GUIGetMsg() Switch $msg Case $a FileDelete(@DesktopDir&"\data.txt") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Btn() If FileExists(@DesktopDir&"\data.txt") Then GUICtrlSetState($a,$GUI_ENABLE) Else GUISetState($a,$GUI_DISABLE) EndIf EndFunc Link to comment Share on other sites More sharing options...
pintas Posted January 21, 2009 Share Posted January 21, 2009 I've never used Adlib, so i'm not sure this is what you're looking for: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Test GUI",180,50) GUICtrlCreateLabel("Desktop -> data.txt",10,15) $a=GUICtrlCreateButton("Delete",120,10) GUICtrlSetState($a,$GUI_ENABLE) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $a FileDelete(@DesktopDir&"\data.txt") GUICtrlSetState($a,$GUI_DISABLE) Sleep(1000) If FileExists(@DesktopDir&"\data.txt") Then GUICtrlSetState($a,$GUI_ENABLE) Else GUISetState($a,$GUI_DISABLE) EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
DarkBoost Posted January 21, 2009 Author Share Posted January 21, 2009 From what I understand the AdlibEnable is looping the Func throughout the script, however in my case it appears to stop looping after the button is pressed. Your example is a manual process which is not updating realtime eg. whilst the script is running I manually create/delete the file and the button is not updating. Link to comment Share on other sites More sharing options...
BrettF Posted January 21, 2009 Share Posted January 21, 2009 What do you want to do? With something like just checking a file, you can shove it in the main message loop. I'm still not 100% sure what you want to achieve... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
DarkBoost Posted January 21, 2009 Author Share Posted January 21, 2009 My apologizes, I will try my best to more clear and precise to avoid reader confusion. 1.) Create a simple GUI with a button named (delete) -> done 2.) Script button to delete a file on the desktop called (data.txt) when clicked -> done 3.) Enable/Disable the button if the file does/doesn't exist realtime eg. I start the script and then create the file, button should automatically update etc. -> need help! I am attempting to use the AdlibEnable feature as advised in another thread however I am open to all suggestions. Link to comment Share on other sites More sharing options...
BrettF Posted January 21, 2009 Share Posted January 21, 2009 Look at your AdLib loop very closely... Spot the difference between mine and yours... Func Btn() If FileExists(@DesktopDir&"\data.txt") Then GUICtrlSetState($a,$GUI_ENABLE) Else GUICtrlSetState($a,$GUI_DISABLE) EndIf EndFunc Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
DarkBoost Posted January 21, 2009 Author Share Posted January 21, 2009 Retard => Me... Cheers buddy!!! 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