anoncoward Posted August 24, 2017 Share Posted August 24, 2017 #include <GUIToolbar.au3> #include <Constants.au3> #include <GUIConstans.au3> #NoTrayIcon Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 1) Opt("GUIOnEventMode", 1) Opt("TrayOnEventMode", 1) Func ConfigMenu() Sleep(5000) MouseClick($MOUSE_CLICK_RIGHT, 1580, 1180, 1, 50) Sleep(1000) MouseClick($MOUSE_CLICK_LEFT, 1400, 120, 1, 50) EndFunc ConfigMenu() I just want to click on a tray icon and select a menu item. But it appears the script pauses even with the 'Opt("TrayAutoPause", 0)'. I've tried various combinations of the Opts there, as well as various includes. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 24, 2017 Moderators Share Posted August 24, 2017 anoncoward, You need to create a tray menu with items to select - look at TrayCreateItem in the Help file. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
anoncoward Posted August 24, 2017 Author Share Posted August 24, 2017 Melba23, Thank you for your reply. So TrayCreateItem modifies the icon and I can add or remove items from it and when used with TrayMenuMode 1 I can remove the pause/exit options and only have my new items? So I'm guessing this keeps it from pausing when it first right clicks my tray icon? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 24, 2017 Moderators Share Posted August 24, 2017 anoncoward, Quote So TrayCreateItem modifies the icon No, it modifies the pop-up menu attached to the icon - the icon itself remains as before. As to the remainder of your questions - yes. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
anoncoward Posted August 25, 2017 Author Share Posted August 25, 2017 So now I've got: #NoTrayIcon #include <GUIToolbar.au3> #include <Constants.au3> #include <GUIConstants.au3> Opt("TrayMenuMode", 3) TrayCreateItem("Radio 1", -1, -1, $TRAY_ITEM_RADIO) TrayItemSetState(-1, $TRAY_CHECKED) Func ConfigMenu() Sleep(5000) MouseClick($MOUSE_CLICK_RIGHT, 1580, 1180, 1, 50) <========== It doesn't move past this. Sleep(1000) MouseClick($MOUSE_CLICK_LEFT, 1400, 120, 1, 50) EndFunc ConfigMenu() I can remove the #NoTrayIcon, and see the new menu without pause/exit but it appears to still be pausing. Link to comment Share on other sites More sharing options...
SlackerAl Posted August 25, 2017 Share Posted August 25, 2017 I just copy/pasted your code from the last post and added a ";" before your comment. Waits 5 seconds, moves mouse to the bottom right of my screen and opens the right click menu, waits 1 second and moves up the screen. What did you expect it to do? As an aside, if you are planning to use this to open and select items from the tray, you must appreciate your script is going to become dependent on screen resolution and the exact position of the tray? Which does not sound very nice to me... Problem solving step 1: Write a simple, self-contained, running, replicator of your problem. Link to comment Share on other sites More sharing options...
anoncoward Posted August 25, 2017 Author Share Posted August 25, 2017 Well, I'm actually using PixelSearch to select the right color icon. When I run it, mine doesn't move after rightclicking on the tray icon. I'm using Windows 10. I'll have to double check my version of AutoIT. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2017 Moderators Share Posted August 25, 2017 anoncoward, I am confused. You asked about how to alter the script icon and now I see that you have added the #notrayicon directive, which makes having a tray menu somewhat moot. You also appear to be using a function to get the menu to appear, which is a very strange way to get to a popup menu to as you would usually expect it to react to user input. So just exactly what are you trying to do? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
anoncoward Posted August 25, 2017 Author Share Posted August 25, 2017 (edited) #NoTrayIcon #include <GUIConstantsEx.au3> #include <Timers.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <TrayConstants.au3> ; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants. TraySetClick(0) Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. TrayCreateItem("Radio 1", -1, -1, $TRAY_ITEM_RADIO) TrayItemSetState(-1, $TRAY_CHECKED) ; Variable Defs $5sec = 5000 $30sec = $5sec * 6 $1min = $30sec * 2 $5min = $1min * 5 Func ChangeVPN() $yCoord = 1408 $coord = PixelSearch( 1360, 1160, 1599, 1199, 0x00FF0D) Sleep($5sec) MouseClick($MOUSE_CLICK_RIGHT, $coord[0], $coord[1], 1) Sleep(1000) MouseClick($MOUSE_CLICK_LEFT, $yCoord, 121, 1, 50) Sleep(1000) MouseClick($MOUSE_CLICK_LEFT, $yCoord, 201, 1, 50) MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) ;; for testing EndFunc ChangeVPN() Here is the actual code. Sorry, I was at work and didn't have my exact code. The coords are 1373, 1174. I use Private Internet Access and want to switch VPNs periodically. To get the coords I added: MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) After the last MouseClick line in my function, and it pops up, however my mouse doesn't move from the right click on my PIA tray icon (skipping the other two mouse clicks. Edited August 25, 2017 by anoncoward Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2017 Moderators Share Posted August 25, 2017 (edited) anoncoward, I am still confused. When using the #notrayicon directive, you do not get an AutoIt script icon in the tray and so you should not be able to pause the script by clicking on it. Which icon in the tray are you actually trying to click? And your script is probably not progressing because a pop-up menu is usually blocking and nothing will happen until you have selected something within it - which your script does not seem to do. Perhaps if you list the actions you want to take when changing VPN we might suggest a suitable method - using a HotKey seems to be a good possibility. M23 Edited August 25, 2017 by Melba23 Wrong button too soon! Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
anoncoward Posted August 25, 2017 Author Share Posted August 25, 2017 I think it was the software. Command line openvpn for the win. 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