Jump to content

bobomb

Active Members
  • Posts

    92
  • Joined

  • Last visited

Community Answers

  1. bobomb's post in Auto refresh label in GUI was marked as the answer   
    This is ugly but it works, I have the INI file set in the same dir as the au3
    #RequireAdmin #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <File.au3> #include <TrayConstants.au3> #include <ColorConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1_1 = GUICreate("PROGRAM INSTALLER", 1300, 637, -1, -1) Global $Button1 = GUICtrlCreateButton("INSTALL SELECTED", 16, 476, 155, 25) Global $Form1_1_AccelTable[2][2] = [["^+{NUM 5}"]] GUISetAccelerators($Form1_1_AccelTable) GUISetState(@SW_SHOW) ; PROGRAMS TO SELECT FROM Global $Checkbox101 = GUICtrlCreateCheckbox("Program 1", 16, 80, 105, 17) ; TEXT IN THE TOP LEFT CORNER TO BE AUTO-REFRESHED. TO TELL IF THE USER HAS ACCESS TO A SPECIFIC FOLDER - BY READING AN INI-FILE IN THAT FOLDER! Global $AccessKnown = 0, $iniValue, $Label21 = GUICtrlCreateLabel("Access", 50, 10, 275, 20) GUICtrlSetData($Label21, "Access missing") #EndRegion ### END Koda GUI section ### While 1 If $AccessKnown = 0 Then $iniValue = IniRead(@WorkingDir & '\file.ini', 'Access', 'Connection', 'No') If Not ($iniValue = 'No') Then GUICtrlSetData($Label21, "Access Granted") $AccessKnown = 1 EndIf EndIf If $AccessKnown = 1 Then $iniValue = IniRead(@WorkingDir & '\file.ini', 'Access', 'Connection', 'No') If $iniValue = 'No' Then GUICtrlSetData($Label21, "Access Missing") $AccessKnown = 0 EndIf EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; INSTALL PROGRAM 1 If GUICtrlRead ($Checkbox101) = 1 Then RunWait ('msiexec.exe /i "C:\Setup 203.msi" /passive') EndIf EndSwitch WEnd Test INI File Is called File.ini and contains:
    [Access] Connection=Yes If you rename the file to something else while the script is running you will "lose access" also if you change the value inside to "No" you will lose access, if you rename it back you will "gain access" the value inside can be anything other than the string "No" as long as it exists even an empty string (e.g. Connection=) <== Would have access too.
    Like I said, I am new to AutoIT3 so I am sure this is probably not the best way.. And the others might be able to explain why..
    You can even add counters $a=$a +1 and when a hits 1000 or whatever you can run the IniRead if you dont want to hit the system with all those reads.. I would say my way is probably a last resort though but I'll wait to see what the experts say  I am also just noticing that this is nearly identical to what @ad777 previously posted for you but it looks like he was trying to avoid the loop probably because its bad form.
×
×
  • Create New...