vocoder Posted November 5, 2006 Share Posted November 5, 2006 expandcollapse popup#Include <Constants.au3> #Include <_XMLDomWrapper.au3> #include <Array.au3> #include <GuiConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) While 1 ;Waiting for the file Sleep(1000) ;wait this amount of time $location = IniRead("my.ini", "files", "location", "NotFound") $logo = IniRead("my.ini", "files", "logo", "NotFound") Local $sFile = $location If FileExists($sFile) Then $ret = _XMLFileOpen ($sFile) if $ret =0 then Exit GuiCreate("CONTROL", 430, 500,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ; form GUI $header = _XMLGetValue ("/control/header") $sent = _XMLGetValue ("/control/sent") FileDelete($sFile) ; delete the file $header1 = GuiCtrlCreateLabel("Headline:", 10, 110, 150, 20) $sent1 = GuiCtrlCreateLabel("Sent:", 10, 140, 150, 20) GUISetState (@SW_HIDE) $Input_headline = GuiCtrlCreateInput("" & $headline[1], 120, 110, 280, 20) $Input_sent = GuiCtrlCreateInput("" & $sent[1], 120, 140, 280, 20) GUISetState (@SW_HIDE) TraySetState() $Show= TrayCreateItem("Show Program") $spacer1 = TrayCreateItem("") $Hide= TrayCreateItem("Hide Program") $spacer2 = TrayCreateItem("") $about = TrayCreateItem("About Program") $spacer3 = TrayCreateItem("") $exit = TrayCreateItem("Exit") $spacer4 = TrayCreateItem("") ; ; While 1 $msg = TrayGetMsg() $xmsg = GUIGetMsg() Select Case $xmsg = $sent1 WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $Show WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $Hide WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $about MsgBox(64, "about:", "Program version 1.0") Case $msg = $exit ExitLoop TrayItemDelete($Show) TrayItemDelete($spacer1) TrayItemDelete($about) TrayItemDelete($spacer2) TrayItemDelete($Hide) TrayItemDelete($spacer3) TrayItemDelete($exit) TrayItemDelete($spacer4) GUIDelete() Exit Case $xmsg = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE) Case $xmsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) Case $msg = $TRAY_EVENT_PRIMARYDOUBLE GUISetState(@SW_SHOW) EndSelect WEnd EndIf WEnd Exit this code works if the file is found....but if it is not found, nothing displays. i think i found the problem with that - the endif needs to be moved up and some of the body of the GUI recreated if the file isn't found...correct? but the main problem i'm having is...lets say the file is found...i delete it - then i want the program to keep running and to keep checking for the file every x amount of time. if the file is found again, it would pop open the gui window. what am i doing wrong? logic? Link to comment Share on other sites More sharing options...
_Kurt Posted November 5, 2006 Share Posted November 5, 2006 (edited) While 1 $search1 = FileFindFirstFile("File") If $search1 = -1 Then GUISetState(@SW_HIDE) EndIf WEnd UNTESTED Is this what you're looking for? Try adding this in. Kurt Edited November 5, 2006 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
vocoder Posted November 5, 2006 Author Share Posted November 5, 2006 hmm, not sure. where would i put that in the file? I tried putting it right before the if fileexists part and it crashed. said the maximum number of open files has been exceeded Link to comment Share on other sites More sharing options...
_Kurt Posted November 5, 2006 Share Posted November 5, 2006 Okay, I've cleaned up the script a little, this should work. If this isn't what you want, should have given me more details and the Include <_XMLDomWrapper.au3>. Tell me if this is what you wanted: expandcollapse popup#Include <Constants.au3> #Include <_XMLDomWrapper.au3> #include <Array.au3> #include <GuiConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) ;-- Ini Reads -- $location = IniRead("my.ini", "files", "location", "NotFound") $logo = IniRead("my.ini", "files", "logo", "NotFound") ;-- Create GUI and components - GuiCreate("CONTROL", 430, 500,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $header = _XMLGetValue ("/control/header") $sent = _XMLGetValue ("/control/sent") $header1 = GuiCtrlCreateLabel("Headline:", 10, 110, 150, 20) $sent1 = GuiCtrlCreateLabel("Sent:", 10, 140, 150, 20) $Input_headline = GuiCtrlCreateInput("" & $headline[1], 120, 110, 280, 20) $Input_sent = GuiCtrlCreateInput("" & $sent[1], 120, 140, 280, 20) GUISetState() ;-- Tray Menu Items -- $Show = TrayCreateItem("Show Program") $spacer1 = TrayCreateItem("") $Hide = TrayCreateItem("Hide Program") $spacer2 = TrayCreateItem("") $about = TrayCreateItem("About Program") $spacer3 = TrayCreateItem("") $exit = TrayCreateItem("Exit") $spacer4 = TrayCreateItem("") TraySetState() ;-- While the Program is running, do the following -- While 1 $search1 = FileFindFirstFile("File") If $search1 = -1 Then GUISetState(@SW_HIDE) Else GUISetState(@SW_SHOW) EndIf $msg = TrayGetMsg() $xmsg = GUIGetMsg() Select Case $xmsg = $sent1 WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $Show WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $Hide WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $about MsgBox(64, "about:", "Program version 1.0") Case $msg = $exit Exit Case $xmsg = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE) Case $xmsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) Case $msg = $TRAY_EVENT_PRIMARYDOUBLE GUISetState(@SW_SHOW) EndSelect WEnd Exit Hopefully that helped Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
vocoder Posted November 5, 2006 Author Share Posted November 5, 2006 (edited) thanks, but that doesn't seem to work at all. I modified it a bit to add $ret = _XMLFileOpen($sFile) because it needs to open the xml file. but then it just opens once, pops up the window, then exits with an error : Unable to open file, the maximum number of open files has been exceeded.: $search1 = FileFindFirstFile($location) basically this is how i want the app to function: xml file is created in a folder (which i read from ini file) every so often when the xml file is created, i want a window to pop up notifying the user and displaying the xml file contents (i have this working). i then delete the file. the app would never stop running - after it displays the user the contents of the file, the user can click the x (close) or minimize button on the notification window, but the app still sits int he system tray (like how the time works or sound tray icon, etc) while sitting in the tray, it continues to scan for this file, whenever it is found, it always pops up the notification window to the user, then deletes the file. the first script i posted works, but only once...it doesn't loop after the file is found to continue searching for the file again. the xml include just allows me to read the xml file and put the contents of the tags into a variable (so i can display them to the user) edit: i attached the xmldomwrapper to this msg Edited November 5, 2006 by vocoder Link to comment Share on other sites More sharing options...
vocoder Posted November 6, 2006 Author Share Posted November 6, 2006 (edited) i modified the while statement to be While 1 If FileExists($sFile) Then GUISetState(@SW_SHOW) FileDelete($sFile) Else GUISetState(@SW_HIDE) EndIf $msg = TrayGetMsg() $xmsg = GUIGetMsg() Select Case $xmsg = $sent1 WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $Show WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $Hide WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $about MsgBox(64, "about:", "Program version 1.0") Case $msg = $exit Exit Case $xmsg = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE) Case $xmsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) Case $msg = $TRAY_EVENT_PRIMARYDOUBLE GUISetState(@SW_SHOW) EndSelect WEnd now the problem seems to be, as soon as i delete the message, the window disappears. i still want the window to stay on the screen until the user exits by pressing the minimize button or close button.....after i have already deleted the file. help? thanks! edit: i think i fixed the problem. I just moved most of the gui creation to inside of the while statement, it appears to be working correctly now. thanks for the help! Edited November 6, 2006 by vocoder 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