Jump to content

Stop pausing when using tray icons.


Recommended Posts

#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

  • Moderators

anoncoward,

You need to create a tray menu with items to select - look at TrayCreateItem in the Help file.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

#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 by anoncoward
Link to comment
Share on other sites

  • Moderators

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 by Melba23
Wrong button too soon!

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...