Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Tray menu exit not working

$
0
0

Sorry to be a bother. This code seems to be working as I want to except that the exit option on the tray menu doesn't do anything.

AutoIt         
#NoTrayIcon #include <File.au3> #include <MsgBoxConstants.au3> #include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant. #include <funcs.au3> Global $aFileArray Global $mFile = "c:\print\print.txt" _FileWriteLog(@ScriptDir & "\Example.log", "Program Started, lets rock!") Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.     Local $idExit = TrayCreateItem("Exit")     Global $isOpen = 0     TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.     While 1       Switch TrayGetMsg()          Case $idExit ; Exit the loop.          Exit       EndSwitch       Local $checkFile = _FileInUse($mFile)       If $checkFile == 1 Then          $isOpen = 1          sleep(1000)       Elseif $checkfile == 0 Then          $isOpen = 0          sleep(1000)       EndIf       If $isOpen == 0 Then             If Not FileExists($mFile) Then                ;file no exist do nothing             Else                ;check if file is in use one more Time                Local $checkAgain = _FileInUse($mFile)                if $checkAgain == 1 Then                   ; file still open lets sleep for a bit and go again                   Sleep(10000)                Else                   ;print the file                   If FileExists("c:\print\print.txt") Then                      If Not _FileReadToArray("c:\print\print.txt", $aFileArray) Then                         _FileWriteLog(@ScriptDir & "\Example.log", "Read print.txt failed with error code" & @error & ". Program halted.")                         Exit                      Else                         _FileWriteLog(@ScriptDir & "\Example.log", "Read print.txt successful, moving on")                      EndIf                      Global $aStart                      If Not $aStart = _ArrayFindAll($aFileArray , "SEVEN UP" , '' , '' , '' , 1) Then                         _FileWriteLog(@ScriptDir & "\Example.log", "Failed to find Sevenup name. Error " & @error & ". Program halted.")                         Exit                      Else                         _FileWriteLog(@ScriptDir & "\Example.log", "Find Sevenup name, succesful, moving on")                         $aStart = _ArrayFindAll($aFileArray , "SEVEN UP" , '' , '' , '' , 1)                      EndIf                      for $i = 0 to ubound($aStart) - 1                         If $i = ubound($aStart) - 1 Then                              _FileWriteFromArray("c:\print\OUTPUT_" & $i & ".txt" , $aFileArray , $aStart[$i] , $aFileArray[0])                              _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " created")                              ;_FileWriteLine_top("c:\print\OUTPUT_" & $i & ".txt", @CRLF)                              _FilePrint("c:\print\OUTPUT_" & $i & ".txt")                              _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " printed")                               Sleep(500)                               FileDelete("c:\print\OUTPUT_" & $i & ".txt")                               _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " deleted")                         Else                              $next = $i + 1                              _FileWriteFromArray("c:\print\OUTPUT_" & $i & ".txt" , $aFileArray , $aStart[$i] , $aStart[$next] - 1)                              _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " created")                             ; _FileWriteLine_top("c:\print\OUTPUT_" & $i & ".txt", @CR)                              _FilePrint("c:\print\OUTPUT_" & $i & ".txt")                              _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " printed")                               Sleep(500)                               FileDelete("c:\print\OUTPUT_" & $i & ".txt")                               _FileWriteLog(@ScriptDir & "\Example.log", "Split file " & $i & " deleted")                         EndIf                      next                      FileDelete("c:\print\print.txt")                   EndIf                EndIf             EndIf       Elseif $isOpen == 1 Then             If Not FileExists($mFile) Then                ;do nothing             Else                Local $check = _FileInUse($mFile)                If $check == 1 Then                   ; file in use drop out and check again                Elseif $check == 0 Then                   ; file is free, check $isOpen to 0                   $isOpen = 0                EndIf             EndIf       Endif WEnd

Thanks for your help. I appreciate it.


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>