Diana (Cda) Posted November 11, 2008 Share Posted November 11, 2008 I'm only having problem with one aspect of a script. Here is the script in question: expandcollapse popup; ; AutoIt 3x ; #include <GuiConstants.au3> #include <_PartitionLetters.au3> ; this replaces drive letters #include<_WEReplacement.au3> ; references a Windows Explorer replacement program #Include<_SYSTRAY, refresh.au3> #NoTrayIcon ; AutoIt's icon doesn't show in systray TraySetIcon($Icons1 & "\TXT file icon 01.ico") #region ===== File: =================================================== $File = @ScriptDir & "\PUAC- LaunchIfNotRunning - DO NOT RUN APPS.txt" #endregion ============================================================ ;*****===== Tray "context menu": =====*****=====*****=====*****=====*****===== ;Opt("GuiOnEventMode", 1) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) ;------------------------------------------------------------------------------ TrayCreateItem($File) TrayItemSetOnEvent(-1, "_UnhideWindow") TrayCreateItem("") ; creates a "separator" line between items in tray menu TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_Quit") TrayCreateItem("") ; creates a "separator" line between items in tray menu ;*****=====*****=====*****=====*****=====*****=====*****=====*****=====*****===== ;-------------- While 1 Sleep(150) WEnd ;-------------- ShellExecute($File, "", "", "Open", @SW_HIDE) Func _UnhideWindow() ShellExecute($File, "", "", "Open", @SW_SHOW) ; CLOSE SCRIPT AND REMOVE FROM TRAY ... ? EndFunc Func _Quit() Exit EndFunc ;==>_Quit There might not be a simple way to minimize to tray but fortunately I learned how to work with tray scripting just recently and thought the @SW_HIDE might just work after all. I've managed so far to mimic opening something and sending directly to the tray. The only part I can't figure out is where it says above "CLOSE SCRIPT AND REMOVE FROM TRAY ...". Right now, when this script is running, the process shows up merely as the usu. "Autoit.exe". For obvious reasons, ProcessClose("AutoIt3.exe") just would not be a good thing to use. Is there a way to get this script to close when clicking on "Exit" in the tray (its name is "PUAC- LaunchIfNotRunning - DO NOT RUN APPS.au3")? It's not using the process name or whether or not a file exists, so I just don't have a notion what coding to use. Thanks! Link to comment Share on other sites More sharing options...
Diana (Cda) Posted November 11, 2008 Author Share Posted November 11, 2008 Actually, instead of right-clicking on an AI script tray item, is there code to handle a double-click instead? That would mimic the whole tray thing completely of opening a tray-minimized script. Link to comment Share on other sites More sharing options...
ludocus Posted November 11, 2008 Share Posted November 11, 2008 (edited) your doing it wrong.. use: expandcollapse popup; ; AutoIt 3x ; Opt('WinTitleMatchMode', 2') #include <GuiConstants.au3> #include <_PartitionLetters.au3> ; this replaces drive letters #include<_WEReplacement.au3> ; references a Windows Explorer replacement program #Include<_SYSTRAY, refresh.au3> #NoTrayIcon ; AutoIt's icon doesn't show in systray TraySetIcon($Icons1 & "\TXT file icon 01.ico") #region ===== File: =================================================== $File = @ScriptDir & "\PUAC- LaunchIfNotRunning - DO NOT RUN APPS.txt" #endregion ============================================================ ;*****===== Tray "context menu": =====*****=====*****=====*****=====*****===== ;Opt("GuiOnEventMode", 1) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) ;------------------------------------------------------------------------------ $item = TrayCreateItem($File) TrayItemSetOnEvent(-1, "_UnhideWindow") TrayCreateItem("") ; creates a "separator" line between items in tray menu TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_Quit") TrayCreateItem("") ; creates a "separator" line between items in tray menu ;*****=====*****=====*****=====*****=====*****=====*****=====*****=====*****===== ;-------------- While 1 Sleep(150) WEnd ;-------------- ShellExecute($File, "", "", "Open", @SW_HIDE) Func _UnhideWindow() ;WinSetState('LaunchIfNotRunning - DO NOT RUN APPS', '', @SW_SHOW) If you want to show it WinClose('LaunchIfNotRunning - DO NOT RUN APPS');to close the window.. TrayItemDelete($item);to delete the item ;ShellExecute($File, "", "", "Open", @SW_SHOW) <== WRONG ; CLOSE SCRIPT AND REMOVE FROM TRAY ... ? EndFunc Func _Quit() Exit EndFunc ;==>_Quit Edited November 11, 2008 by ludocus 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