vocoder Posted November 2, 2006 Posted November 2, 2006 (edited) I have most of my app up and running but have come to a roadblock. I am creating an application that I would like to sit in the system stray with other apps (virus scanner, steam, mail notification, soundicon, etc). when a file is created in a certain directory, it would pop up a window with the contents of the file in it. almost like Msgbox does but with the nice layout of the guicreate stuff. Here is my code so far 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) $location = IniRead("my.ini", "files", "location", "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)) ; $sent = _XMLGetValue ("/info/sent") $headline = _XMLGetValue ("/info/headline") $header1 = GuiCtrlCreateLabel("Headline:", 10, 110, 150, 20) $sent1 = GuiCtrlCreateLabel("Sent:", 10, 140, 150, 20) GUISetState (@SW_SHOW) $Input_headline = GuiCtrlCreateInput("" & $headline[1], 120, 110, 280, 20) $Input_sent = GuiCtrlCreateInput("" & $sent[1], 120, 140, 280, 20) GUISetState (@SW_SHOW) $Show= TrayCreateItem("Show MyProgram") TrayCreateItem("") $about = TrayCreateItem("About MyProgramr") TrayCreateItem("") $exit = TrayCreateItem("Exit") TrayCreateItem("") TraySetState() While 1 $msg = TrayGetMsg() $xmsg = GUIGetMsg() Select Case $xmsg = $sent1 WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $Show WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $about Msgbox(64,"about:","MyProgram 1.0") Case $msg = $exit ExitLoop EndSelect WEnd Exit EndIf WEnd Exit so, one problem is that when the window pops up, when you click the X on the window to close it, it doesn't do anything. I would like it so the windows closes but the app is still running in the system tray. Is this possible?? the other thing I am going to need to code is so once the file is found, it pops up the window...the user can close the window, but app is still running in system tray....then it starts over again looking for the file...if it is found it will pop up the window again. possible? Edited November 2, 2006 by vocoder
lcgreenwald Posted November 2, 2006 Posted November 2, 2006 You are almost there. Change this part of your script. TraySetState() While 1 $msg = TrayGetMsg() $xmsg = GUIGetMsg() Select Case $xmsg = $sent1 WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $Show WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $about MsgBox(64, "about:", "MyProgram 1.0") Case $msg = $exit ; Delete the tray items and close the GUI TrayItemDelete($Show) TrayItemDelete($spacer1) TrayItemDelete($about) TrayItemDelete($spacer2) TrayItemDelete($exit) TrayItemDelete($spacer3) GUIDelete() ExitLoop EndSelect WEnd ;Exit <-- This Exit is causing your program to exit. EndIf WEnd Exit
vocoder Posted November 3, 2006 Author Posted November 3, 2006 that doesn't seem to do what I want - although it fixed one problem, thanks! I guess what I really want is when the user clicks the - (minimize) on the window it would send it back to the systray (where the time is) and not have the window listed on the taskbar anymore. if this isn't possible, then a button on the main gui that sends 'send back to systray' and it do this. possible? what should i be looking at? like how virus scanner systray icons work. you double click them, the control window comes up..but then you can close the control window, but the systray icon still stays and your virus scan software still runs. for my program, when i hit the x (even with the fix) nothing happens. it doesnt even exit the program.
vocoder Posted November 3, 2006 Author Posted November 3, 2006 expandcollapse popupraySetState() ; ; Do $guiMsg = GUIGetMsg() $trayMsg = TrayGetMsg() if Not WinActive("CONTROL") and $clicked = 1 Then ;sleep(1000);waits a second before setting to tray GUISetState(@SW_HIDE, $guiCONTROL) $clicked = 0 EndIf Select Case $trayMsg = $TRAY_EVENT_PRIMARYDOWN or $trayMsg = $TRAY_EVENT_PRIMARYDOUBLE If $clicked = 0 Then sleep(100) GUISetState(@SW_SHOW, $guiCONTROL) $clicked = 1 Else GUISetState(@SW_HIDE, $guiCONTROL) $clicked = 0 EndIf Case $guiMsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE, $guiCONTROL) $clicked = 0 EndSelect ; until $guiMsg = $GUI_EVENT_CLOSE EndIf WEnd oÝ÷ ÚȨv'âyÙ²r^¶Z½ëaƵêÓ¬zÔj×Øj^j»-¡Ú0«bÁ©í½êâßÙ§¢Û.èhÂÚuÙ²³+-¬¬zW¶*'¢b¢{-¢Øb±Êy«¢+Ø)]¡¥±Ä(($$$$$ÀÌØíµÍôQÉåÑ5Í ¤($$$$$ÀÌØíáµÍôU%Ñ5Í ¤($$$$%M±Ð($$$$$% ÍÀÌØíáµÍôÀÌØí͹ÐÄ($$$$$$%]¥¹MÑMÑÑ ÅÕ½Ðí =9QI=0ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤($$$$$% ÍÀÌØíµÍôÀÌØíM¡½Ü($$$$$$%]¥¹MÑMÑÑ ÅÕ½Ðí =9QI=0°ÅÕ½ÐìÅÕ½Ðì°M]}M!=¤($$$$$% ÍÀÌØíµÍôÀÌØí!¥($$$$$$%]¥¹MÑMÑÑ ÅÕ½Ðí =9QI=0ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤($$$$$% ÍÀÌØíµÍôÀÌØí½ÕÐ($$$$$$%5Í ½à ØаÅÕ½Ðí½ÕÐèÅÕ½Ðì°ÅÕ½Ðí5åAɽɴĸÀÅÕ½Ðì¤($$$$$% ÍÀÌØíµÍôÀÌØíá¥Ð($$$$$$$ì±ÑÑ¡ÑÉä¥ÑµÌ¹±½ÍÑ¡U$($$$$$$%QÉå%ѵ±Ñ ÀÌØíM¡½Ü¤($$$$$$%QÉå%ѵ±Ñ ÀÌØíÍÁÈĤ($$$$$$%QÉå%ѵ±Ñ ÀÌØí½ÕФ($$$$$$%QÉå%ѵ±Ñ ÀÌØíÍÁÈȤ($$$$$$%QÉå%ѵ±Ñ ÀÌØí!¥¤($$$$$$%QÉå%ѵ±Ñ ÀÌØíÍÁÈ̤($$$$$$%QÉå%ѵ±Ñ ÀÌØíá¥Ð¤($$$$$$%QÉå%ѵ±Ñ ÀÌØíÍÁÈФ($$$$$$%U%±Ñ ¤($$$$$$%á¥Ñ1½½À($$$$%¹M±Ð($$$%]¹( so the first part of the code works (app still runs in the system tray)..but now i have to add the 'winsetstate' stuff to the first part of the code..if i put it in my code, it reverts to how it used to work (wrongly). i also tried just adding the case statements to the case statements in the first code bit, but that didn't work at all either. what am i doing wrong?
lcgreenwald Posted November 3, 2006 Posted November 3, 2006 Is this doing what you are looking for? 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:", "MyProgram 1.0") Case $msg = $exit ; Delete the tray items and close the GUI TrayItemDelete($Show) TrayItemDelete($spacer1) TrayItemDelete($about) TrayItemDelete($spacer2) TrayItemDelete($Hide) TrayItemDelete($spacer3) TrayItemDelete($exit) TrayItemDelete($spacer4) GUIDelete() ExitLoop 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
JSThePatriot Posted November 3, 2006 Posted November 3, 2006 I would say that the GUISetState(@SW_SHOW) or GUISetState(@SW_HIDE) would be the best option. You may even consider GUIDelete(), and putting your re-creation of the GUI in a function. Maybe even consider OnEventMode for the GUI. Thanks, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
vocoder Posted November 5, 2006 Author Posted November 5, 2006 thanks for the help, I have it mostly working now. Although now i'm having a different problem (go figure). i always want the app to sit in the system tray. if the file isn't found, thats fine, just have it sit in the system tray. but to keep checking the directory every x amount of time (that is why i have the sleep function in there). if it scans the directory and finds the file, it pops up. it works if the file is there. but if i take the file out, run the app, then copy the file to the directory, the window never pops up. the idea is once the file is found, i'll delete the file and the app will continue to run looking for a new file and repeat the process if it finds one.
lcgreenwald Posted November 6, 2006 Posted November 6, 2006 Add another couple of case statements. If the file is deleted then set a variable. If the file exists and the file had been deleted then clear the deleted var and set the gui state to show.
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