eyegeegeewhy Posted October 15, 2007 Share Posted October 15, 2007 I have made a small application that check for the existance of some files(pdfs and Xml). One of the buttons just does a one time check and this works fine. I want the other button however to keep doing the same check every say 30 seconds. The problem is once this loop starts I cant get out out as none of the other buttons are responsive. Below is just the while loop for the GUI. This is the one without my attempts at escaping it i just want it to sleep for 30 seconds or until someone hits exit. expandcollapse popupWhile 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE GUIDelete() ;Exit the script Exit Case $nMsg = $Button1 If GUICtrlRead($Combo1)="" then MsgBox(0,0,"You must enter a Book from the drop down list") Else $BOOK=GUICtrlRead($Combo1) $START_PAGE=GUICtrlRead($Input1) $END_PAGE=GUICtrlRead($Input2) $TOTAL_FILES_REQUIRED=$END_PAGE - $START_PAGE Call("FOUND_LIST_XML") Call("FOUND_LIST_PDF") Call("NUMBER_MISSING_FILES") Call("LIST_MISSING_FILES_PDF") Call("LIST_MISSING_FILES_XML") EndIf Case $nMsg = $Button2 If GUICtrlRead($Combo1)="" then MsgBox(0,0,"You must enter a Book from the drop down list") Else $BOOK=GUICtrlRead($Combo1) $START_PAGE=GUICtrlRead($Input1) $END_PAGE=GUICtrlRead($Input2) $TOTAL_FILES_REQUIRED=$END_PAGE - $START_PAGE Call("FOUND_LIST_XML") Call("FOUND_LIST_PDF") Call("NUMBER_MISSING_FILES") Call("LIST_MISSING_FILES_PDF") Call("LIST_MISSING_FILES_XML") EndIf EndSelect WEnd Link to comment Share on other sites More sharing options...
Valuater Posted October 15, 2007 Share Posted October 15, 2007 mAYBE... expandcollapse popup$Adlib = 0 While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE GUIDelete() ;Exit the script Exit Case $nMsg = $Button1 If GUICtrlRead($Combo1) = "" Then MsgBox(0, 0, "You must enter a Book from the drop down list") Else MyFunction() EndIf Case $nMsg = $Button2 If GUICtrlRead($Combo1) = "" Then MsgBox(0, 0, "You must enter a Book from the drop down list") Else If $Adlib = 0 Then AdlibEnable("MyFunction", (30 * 1000)) ; adlib 30 SECONDS ******* $Adlib = 1 Else AdlibDisable() $Adlib = 0 EndIf EndIf EndSelect WEnd Func MyFunction() $BOOK = GUICtrlRead($Combo1) $START_PAGE = GUICtrlRead($Input1) $END_PAGE = GUICtrlRead($Input2) $TOTAL_FILES_REQUIRED = $END_PAGE - $START_PAGE FOUND_LIST_XML() FOUND_LIST_PDF() CNUMBER_MISSING_FILES() LIST_MISSING_FILES_PDF() LIST_MISSING_FILES_XML() EndFunc ;==>MyFunction 8) Link to comment Share on other sites More sharing options...
eyegeegeewhy Posted October 15, 2007 Author Share Posted October 15, 2007 (edited) Ill try that, Why do you need to turn adlib on and off. Excuse me if thats a stupid question ive never seen this adlib stuff before Also I want it to keep doing it again and again every 30 seconds until the user kills it. Is that what this will do? Edited October 15, 2007 by eyegeegeewhy Link to comment Share on other sites More sharing options...
Valuater Posted October 15, 2007 Share Posted October 15, 2007 yes 8) Link to comment Share on other sites More sharing options...
eyegeegeewhy Posted October 16, 2007 Author Share Posted October 16, 2007 I couldnt get this to work. Do I need a beta version maybe. Link to comment Share on other sites More sharing options...
Valuater Posted October 16, 2007 Share Posted October 16, 2007 I couldnt get this to work. Do I need a beta version maybe.Post the "complete" code for us to test8) Link to comment Share on other sites More sharing options...
eyegeegeewhy Posted October 16, 2007 Author Share Posted October 16, 2007 (edited) Im know that this code will not be the best way of doing things but it is just a first draft (well thats my excuse anyways) You will need to drop two files into the test folder one called C:\temp\sample_data\224Y07P_classified_0032.pdf and another called C:\temp\sample_data\224Y07P_classified_0032.xml That sould allow the gui to run This is the code after I cahnged it back to get it to work expandcollapse popup#cs ---------------------------------------------------------------------------- Script Function: Monitor folder for files. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> #Include <GuiList.au3> $file_location="C:\temp\sample_data\" ;Dim some stuff Dim $FOUND_PDF , $FOUND_XML , $MISSING , $FileList_XML , $FileList_PDF ;layout the GUI $Form1 = GUICreate("eDirectories monitor", 397, 223, 291, 145) $Combo1 = GUICtrlCreateCombo("", 8, 8, 170, 30) $Input1 = GUICtrlCreateInput("32", 8, 55, 49, 21) $Input2 = GUICtrlCreateInput("1000", 120, 55, 49, 21) $Button1 = GUICtrlCreateButton("Go", 304, 192, 81, 25, 0) $Button2 = GUICtrlCreateButton("Auto Refresh", 200, 192, 65, 25, 0) $Group1 = GUICtrlCreateGroup("XML", 200, 104, 185, 81) $Input5 = GUICtrlCreateInput("", 288, 120, 81, 21) $Input6 = GUICtrlCreateInput("", 288, 152, 81, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("PDF", 200, 14, 185, 81) $Input3 = GUICtrlCreateInput("", 288, 32, 81, 21) $Input4 = GUICtrlCreateInput("", 288, 64, 81, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label1 = GUICtrlCreateLabel("FOUND", 208, 124, 42, 17) $Label2 = GUICtrlCreateLabel("MISSING", 208, 156, 49, 17) $Label3 = GUICtrlCreateLabel("MISSING", 210, 68, 49, 17) $Label4 = GUICtrlCreateLabel("FOUND", 210, 36, 42, 17) $Label7 = GUICtrlCreateLabel("Missing Items", 8, 90, 170, 17) $List1 = GUICtrlCreateList("", 8, 110, 170, 110, BitOR($LBS_SORT,$LBS_DISABLENOSCROLL,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER)) $Label5 = GUICtrlCreateLabel("First Page", 8, 38, 51, 17) $Label6 = GUICtrlCreateLabel("Last Page", 120, 38, 52, 17) ;Call sub to find what books are in the folder Call("LIST_BOOKS") ;Show the GUI GUISetState(@SW_SHOW) ;set the adlib mode if the user wants to use the refresh button $Adlib = 0 While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE GUIDelete() ;Exit the script Exit Case $nMsg = $Button1 If GUICtrlRead($Combo1)="" then MsgBox(0,0,"You must enter a Book from the drop down list") Else $BOOK=GUICtrlRead($Combo1) $START_PAGE=GUICtrlRead($Input1) $END_PAGE=GUICtrlRead($Input2) $TOTAL_FILES_REQUIRED=$END_PAGE - $START_PAGE Call("FOUND_LIST_XML") Call("FOUND_LIST_PDF") Call("NUMBER_MISSING_FILES") Call("LIST_MISSING_FILES_PDF") Call("LIST_MISSING_FILES_XML") EndIf Case $nMsg = $Button2 If GUICtrlRead($Combo1) = "" Then MsgBox(0, 0, "You must enter a Book from the drop down list") Else $BOOK=GUICtrlRead($Combo1) $START_PAGE=GUICtrlRead($Input1) $END_PAGE=GUICtrlRead($Input2) $TOTAL_FILES_REQUIRED=$END_PAGE - $START_PAGE Call("FOUND_LIST_XML") Call("FOUND_LIST_PDF") Call("NUMBER_MISSING_FILES") Call("LIST_MISSING_FILES_PDF") Call("LIST_MISSING_FILES_XML") EndIf EndSelect WEnd Func LIST_BOOKS() $FileList_XML=_FileListToArray($file_location,"???????_classified_*.xml",1) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf $BOOK_CODES=_ArrayTrim ( $FileList_XML,20,1) $UNIQ_BOOKCODES=_ArrayUnique($BOOK_CODES) GUICtrlSetData($Combo1,_ArrayToString( $UNIQ_BOOKCODES,"|",1)) EndFunc Func _ArrayUnique(ByRef $results, $vDelim = '', $iBase = 1, $iUnique = 1) If $vDelim = '' Then $vDelim = Chr(01) Local $sHold For $iCC = $iBase To UBound($results) - 1 If Not StringInStr($vDelim & $sHold & $vDelim, $results[$iCC] & $vDelim, $iUnique) Then _ $sHold &= $results[$iCC] & $vDelim Next Return StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim) EndFunc Func FOUND_LIST_XML() $FileList_XML=_FileListToArray($file_location,$BOOK & "_classified_*.xml",1) $FOUND_XML=$FileList_XML[0] _ArrayDisplay($FileList_XML) GUICtrlSetData($Input5,$FOUND_XML) EndFunc Func FOUND_LIST_PDF() $FileList_PDF=_FileListToArray($file_location,$BOOK & "_classified_*.pdf",1) $FOUND_PDF=$FileList_PDF[0] GUICtrlSetData($Input3,$FOUND_PDF) EndFunc Func NUMBER_MISSING_FILES() GUICtrlSetData($Input6,$TOTAL_FILES_REQUIRED-$FOUND_XML+1) GUICtrlSetData($Input4,$TOTAL_FILES_REQUIRED-$FOUND_PDF+1) EndFunc Func LIST_MISSING_FILES_PDF() ;clear the list box ready for new data _GUICtrlListClear($List1) ;Check each file exists if it does not add it to the list box For $i = $START_PAGE To $END_PAGE If FileExists($file_location&$BOOK&"_classified_"& StringFormat("%04d", $i) & ".pdf") Then $somethingpointless=1 Else _GUICtrlListAddItem ( $List1, $BOOK&"_classified_"& StringFormat("%04d", $i) & ".pdf" ) EndIf Next EndFunc Func LIST_MISSING_FILES_XML() ;Check each file exists if it does not add it to the list box For $i = $START_PAGE To $END_PAGE If FileExists($file_location&$BOOK&"_classified_"& StringFormat("%04d", $i) & ".xml") Then $somethingpointless=1 Else _GUICtrlListAddItem ( $List1, $BOOK&"_classified_"& StringFormat("%04d", $i) & ".xml" ) EndIf Next EndFunc Edited October 16, 2007 by eyegeegeewhy Link to comment Share on other sites More sharing options...
Valuater Posted October 16, 2007 Share Posted October 16, 2007 I did not use the files, however I did test this script expandcollapse popup#cs ---------------------------------------------------------------------------- Script Function: Monitor folder for files. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> #Include <GuiList.au3> $file_location="C:\temp\sample_data\" ;Dim some stuff Dim $FOUND_PDF , $FOUND_XML , $MISSING , $FileList_XML , $FileList_PDF Dim $Adlib = 0, $BOOK, $TOTAL_FILES_REQUIRED, $START_PAGE, $END_PAGE, $Count ;layout the GUI $Form1 = GUICreate("eDirectories monitor", 397, 223, 291, 145) $Combo1 = GUICtrlCreateCombo("", 8, 8, 170, 30) $Input1 = GUICtrlCreateInput("32", 8, 55, 49, 21) $Input2 = GUICtrlCreateInput("1000", 120, 55, 49, 21) $Button1 = GUICtrlCreateButton("Go", 304, 192, 81, 25, 0) $Button2 = GUICtrlCreateButton("Auto Refresh", 200, 192, 81, 25, 0) $Group1 = GUICtrlCreateGroup("XML", 200, 104, 185, 81) $Input5 = GUICtrlCreateInput("", 288, 120, 81, 21) $Input6 = GUICtrlCreateInput("", 288, 152, 81, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("PDF", 200, 14, 185, 81) $Input3 = GUICtrlCreateInput("", 288, 32, 81, 21) $Input4 = GUICtrlCreateInput("", 288, 64, 81, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label1 = GUICtrlCreateLabel("FOUND", 208, 124, 42, 17) $Label2 = GUICtrlCreateLabel("MISSING", 208, 156, 49, 17) $Label3 = GUICtrlCreateLabel("MISSING", 210, 68, 49, 17) $Label4 = GUICtrlCreateLabel("FOUND", 210, 36, 42, 17) $Label7 = GUICtrlCreateLabel("Missing Items", 8, 90, 170, 17) $List1 = GUICtrlCreateList("", 8, 110, 170, 110, BitOR($LBS_SORT,$LBS_DISABLENOSCROLL,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER)) $Label5 = GUICtrlCreateLabel("First Page", 8, 38, 51, 17) $Label6 = GUICtrlCreateLabel("Last Page", 120, 38, 52, 17) ;Call sub to find what books are in the folder Call("LIST_BOOKS") ;Show the GUI GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE GUIDelete() ;Exit the script Exit Case $nMsg = $Button1 If GUICtrlRead($Combo1) = "" Then MsgBox(0, "Read error #2", "You must enter a Book from the drop down list ", 3) Else MyFunction() EndIf Case $nMsg = $Button2 If GUICtrlRead($Combo1) = "" Then MsgBox(0, "Read error #3", "You must enter a Book from the drop down list ", 3) Else If $Adlib = 0 Then AdlibEnable("MyFunction", (30 * 1000)) ; adlib 30 SECONDS ******* $Adlib = 1 $Count = 0 Else AdlibDisable() $Adlib = 0 $Count = 0 ToolTip("") EndIf EndIf EndSelect WEnd Func MyFunction() $Count += 1 If $Adlib Then ToolTip("Refresh count = " & $Count, 20, 20, "Auto Refresh", 1) $BOOK = GUICtrlRead($Combo1) $START_PAGE = GUICtrlRead($Input1) $END_PAGE = GUICtrlRead($Input2) $TOTAL_FILES_REQUIRED = $END_PAGE - $START_PAGE FOUND_LIST_XML() FOUND_LIST_PDF() NUMBER_MISSING_FILES() LIST_MISSING_FILES_PDF() LIST_MISSING_FILES_XML() EndFunc ;==>MyFunction Func LIST_BOOKS() $FileList_XML=_FileListToArray($file_location,"???????_classified_*.xml",1) If @Error=1 Then MsgBox (0,"File Error #1A","No Files\Folders Found.", 5) Return EndIf $BOOK_CODES=_ArrayTrim ( $FileList_XML,20,1) $UNIQ_BOOKCODES=_ArrayUnique($BOOK_CODES) GUICtrlSetData($Combo1,_ArrayToString( $UNIQ_BOOKCODES,"|",1)) EndFunc Func _ArrayUnique(ByRef $results, $vDelim = '', $iBase = 1, $iUnique = 1) If $vDelim = '' Then $vDelim = Chr(01) Local $sHold For $iCC = $iBase To UBound($results) - 1 If Not StringInStr($vDelim & $sHold & $vDelim, $results[$iCC] & $vDelim, $iUnique) Then _ $sHold &= $results[$iCC] & $vDelim Next Return StringSplit(StringTrimRight($sHold, StringLen($vDelim)), $vDelim) EndFunc Func FOUND_LIST_XML() $FileList_XML=_FileListToArray($file_location,$BOOK & "_classified_*.xml",1) If @Error=1 Then MsgBox (0,"File Error #1B","No Files\Folders Found.", 5) Return EndIf $FOUND_XML=$FileList_XML[0] _ArrayDisplay($FileList_XML) GUICtrlSetData($Input5,$FOUND_XML) EndFunc Func FOUND_LIST_PDF() $FileList_PDF=_FileListToArray($file_location,$BOOK & "_classified_*.pdf",1) If @Error=1 Then MsgBox (0,"File Error #1C","No Files\Folders Found.", 5) Return EndIf $FOUND_PDF=$FileList_PDF[0] GUICtrlSetData($Input3,$FOUND_PDF) EndFunc Func NUMBER_MISSING_FILES() GUICtrlSetData($Input6,$TOTAL_FILES_REQUIRED-$FOUND_XML+1) GUICtrlSetData($Input4,$TOTAL_FILES_REQUIRED-$FOUND_PDF+1) EndFunc Func LIST_MISSING_FILES_PDF() ;clear the list box ready for new data _GUICtrlListClear($List1) ;Check each file exists if it does not add it to the list box For $i = $START_PAGE To $END_PAGE If FileExists($file_location&$BOOK&"_classified_"& StringFormat("%04d", $i) & ".pdf") Then $somethingpointless=1 Else _GUICtrlListAddItem ( $List1, $BOOK&"_classified_"& StringFormat("%04d", $i) & ".pdf" ) EndIf Next EndFunc Func LIST_MISSING_FILES_XML() ;Check each file exists if it does not add it to the list box For $i = $START_PAGE To $END_PAGE If FileExists($file_location&$BOOK&"_classified_"& StringFormat("%04d", $i) & ".xml") Then $somethingpointless=1 Else _GUICtrlListAddItem ( $List1, $BOOK&"_classified_"& StringFormat("%04d", $i) & ".xml" ) EndIf Next EndFunc 8) 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