Roman Posted March 12, 2007 Share Posted March 12, 2007 Hi I just want to delete the "Script paused" item from the default tray-icon menu because the other item "Exit" is the only one i need. How can i do that? The help file mentions the "TrayItemDelete" command, but wants a "controlID" of that menu item, but which value is that? I feel like an absolut beginner... Thanks for every help. Roman Link to comment Share on other sites More sharing options...
BigDod Posted March 12, 2007 Share Posted March 12, 2007 (edited) Modified from the TrayCreateItem in the help file #Include <Constants.au3> Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $exititem ExitLoop EndSelect WEnd Exit Edit - Removed unrequired line Edited March 12, 2007 by BigDod Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Roman Posted March 12, 2007 Author Share Posted March 12, 2007 I saw this help information too, but i wonder if that self created "Exit" has the same behaviour like the "Exit" from the default menu item. Reason: For example, my script starts an external exe file with "RunWait" und waits for termination and the return code of that executable. This lasts maybe 10 minutes. If i click "Exit" from the default tray menu item during this RunWait, the script immediately ends, doesn't matter the external program has terminated or not! But if i use your example, the scripts ends the earliest when the external executable terminated because i can handle the input of that tray menu item only in the next lines of code after the RunWait command, or not? Or is it possible to have something like a second thread, i mean AutoIt waits with RunWait for termination of an external program und handles the input of that tray menu item at the same time? Roman. Link to comment Share on other sites More sharing options...
Shevilie Posted March 13, 2007 Share Posted March 13, 2007 You could do that... Have 2 scripts... A loader/killer and the main script... The loader/killer have the tray icon and the main has none Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
Roman Posted March 13, 2007 Author Share Posted March 13, 2007 You could do that... Have 2 scripts... A loader/killer and the main script... The loader/killer have the tray icon and the main has none I have done that already in other scripts, thanks. A possible way - but not very "neat" i think. But the conclusion is, that i can not hide or disable a menu item (in my case the item "Script paused") from the default tray menu?What a pity. Regards,Roman Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2007 Moderators Share Posted March 13, 2007 (edited) Just a little imagination is all:Global $bToggleTrayPause MsgBox(64, 'Info', 'Pause active') _ToggleTrayPause() MsgBox(64, 'Info', 'Pause Not Active') _ToggleTrayPause() MsgBox(64, 'Info', 'Pause Active again') Func _ToggleTrayPause() $bToggleTrayPause = Not $bToggleTrayPause If $bToggleTrayPause Then Opt('TrayMenuMode', 1) Else Opt('TrayMenuMode', 0) EndIf Return EndFuncObviously MsgBox() would be replaced by RunWait() and you would _TogglePause() before RunWait(). Edit: And _TogglePause() after RunWait() to reactivate it. Edited March 13, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Roman Posted March 13, 2007 Author Share Posted March 13, 2007 (edited) Hm... but in your example, i will "lose" all menu items temporarely - i will lose the whole tray icon menu. Remember, i need the "Exit" item quite urgent during RunWait(). Or am i wrong with analyzing your code? Greetings. Edited March 13, 2007 by roman Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2007 Moderators Share Posted March 13, 2007 Hm... but in your example, i will "lose" all menu items temporarely - i will lose the whole tray icon menu.Remember, i need the "Exit" item quite urgent during RunWait().Or am i wrong with analyzing your code? Greetings.I don't see you being able to do what you want with RunWait() and still be able to register Exit without registering a DLL call... and I'm not quite sure about that one myself... I believe PaulIA has some Tray tools in his AU3Lib.au3, you can find it in the Example forum. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2007 Moderators Share Posted March 13, 2007 Want a really nasty work around? expandcollapse popupGlobal $bToggleTrayPause MsgBox(64, 'Info', 'Pause active') _ToggleTrayPause() MsgBox(64, 'Info', 'Pause Not Active') _ToggleTrayPause() MsgBox(64, 'Info', 'Pause Active again') Func _ToggleTrayPause() $bToggleTrayPause = Not $bToggleTrayPause If $bToggleTrayPause Then _RunTrayWriteFile(@TempDir & '\TrayMess.txt') Else Send("!{F9}") Opt('TrayIconHide', 0) EndIf Return EndFunc Func _RunTrayWriteFile($hFile) FileClose(FileOpen($hFile, 2)) Local $sString = "If $cmdline[0] = 0 Then Exit" & @CRLF & _ "HotKeySet('!{F9}', '_ExitHK')" & @CRLF & _ "Opt('TrayMenuMode', 1)" & @CRLF & _ "Opt('TrayOnEventMode', 1)" & @CRLF & _ "TrayCreateItem(' Exit ')" & @CRLF & _ "TrayItemSetOnEvent(-1, '_ExitNow')" & @CRLF & _ "While 1" & @CRLF & _ "Sleep(100000)" & @CRLF & _ "WEnd" & @CRLF & _ "Func _ExitNow()" & @CRLF & _ "ProcessClose($cmdline[1])" & @CRLF & _ "Exit" & @CRLF & _ "EndFunc" & @CRLF & _ "Func _ExitHK()" & @CRLF & _ "Exit" & @CRLF & _ "EndFunc" FileWrite($hFile, $sString) Local $iPID = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $hFile & '" ' & @AutoItPID, '', @SW_HIDE) Opt('TrayIconHide', 1) ProcessWait($iPID) FileDelete($hFile) Return 1 EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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