tomuky2k Posted February 25, 2013 Share Posted February 25, 2013 Hi, Hope someone can help me figure out what I'm doing wrong, fairly new to AutoIt but have done a few little tools for myself and what to do something a bit more complicated. I am trying to create a system tray icon that when right clicked brings up a menu with a few options for websites and exit(this I can do and get working). What I want to add is the ability to Double Click the tray icon and have it launch a preset website? Here is my working code for the right click and menu: expandcollapse popup#include <Constants.au3> #TrayIcon TraySetIcon("icon.ico") #Disable Default Tray Opt("TrayMenuMode", 3) #Tray Tip TraySetToolTip ("My Name") Local $firstitem = TrayCreateItem("Google") Local $seconditem = TrayCreateItem("MSN") TrayCreateItem("") Local $thirditem = TrayCreateItem("GMail") TrayCreateItem("") Local $exititem = TrayCreateItem("Exit") TraySetState() TraySetClick(16) While 1 Local $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $firstitem ShellExecute("http://www.google.co.uk") Case $msg = $seconditem ShellExecute("http://www.msn.co.uk") Case $msg = $thirditem ShellExecute("http://gmail.com") Case $msg = $exititem ExitLoop EndSelect WEnd Exit Now here is my attempt for adding the double click that doesn't work, expandcollapse popup#include <Constants.au3> #TrayIcon TraySetIcon("icon.ico") #Disable Default Tray Opt("TrayMenuMode", 3) #Tray Tip TraySetToolTip ("My Name") Local $firstitem = TrayCreateItem("Google") Local $seconditem = TrayCreateItem("MSN") TrayCreateItem("") Local $thirditem = TrayCreateItem("GMail") TrayCreateItem("") Local $exititem = TrayCreateItem("Exit") TraySetState() TraySetClick(16) ; Functions Func SpecialEvent() Select Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOUBLE ShellExecute("http://www.autoitscript.com") EndSelect EndFunc ;==>SpecialEvent While 1 Local $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $firstitem ShellExecute("http://www.google.co.uk") Case $msg = $seconditem ShellExecute("http://www.msn.co.uk") Case $msg = $thirditem ShellExecute("http://gmail.com") Case $msg = $exititem ExitLoop EndSelect WEnd Exit Obviously would love some help if someone knows how to accomplish this and/or wants a challenge. I had a look at the help as you can see, but just can't get it to do anything else. Thank you for your help in advance. Tom Link to comment Share on other sites More sharing options...
PhoenixXL Posted February 25, 2013 Share Posted February 25, 2013 (edited) This should do the work expandcollapse popup#include <Constants.au3> #TrayIcon TraySetIcon("icon.ico") #Disable Default Tray Opt("TrayMenuMode", 3) #Tray Tip TraySetToolTip("My Name") Local $firstitem = TrayCreateItem("Google") Local $seconditem = TrayCreateItem("MSN") TrayCreateItem("") Local $thirditem = TrayCreateItem("GMail") TrayCreateItem("") Local $exititem = TrayCreateItem("Exit") TraySetState() TraySetClick(16) While 1 Local $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $firstitem ShellExecute("http://www.google.co.uk") Case $msg = $seconditem ShellExecute("http://www.msn.co.uk") Case $msg = $thirditem ShellExecute("http://gmail.com") Case $msg = $TRAY_EVENT_PRIMARYDOUBLE ShellExecute("http://www.autoitscript.com") Case $msg = $exititem ExitLoop EndSelect WEnd ExitFor setting Event check Opt( "TrayOnEventMode") set to 1.Otherwise use TrayGetMsg. Both cannot be used simultaneously Regards Edited February 25, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
tomuky2k Posted February 25, 2013 Author Share Posted February 25, 2013 Thank you for a very quick and correct reply. Very happy, Thank you once again. 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