'Right Clicking System Tray Icon then Clicking Option in that menu?

Trying to Right Click on tray icon then clicking on a specific item in that menu.

my code is:

#Include C:\Users\basil\Desktop\Scripting/trayicon.ahk


Process, Exist, Probkp.exe

If ErrorLevel <> 0

`Process, Close, Probkp.exe`

Sleep 1000

Run, D:\POS Software\Software\bkp\Probkp.exe


Tray_Refresh()

{

`WM_MOUSEMOVE := 0x200`

`HiddenWindows := A_DetectHiddenWindows`

`DetectHiddenWindows, On`

`TrayTitle := "AHK_class Shell_TrayWnd"`

`ControlNN := "ToolbarWindow323"`

`IcSz := 24`

`Loop, 2`

`{`

    `ControlGetPos, xTray,yTray,wdTray,htTray, %ControlNN%, %TrayTitle%`

    `y := htTray - 10`

    `While (y > 0)`

    `{`

        `x := wdTray - IcSz/2`

        `While (x > 0)`

        `{`

point := (y << 16) + x

PostMessage, %WM_MOUSEMOVE%, 0, %point%, %ControlNN%, %TrayTitle%

x -= IcSz/2

        `}`

        `y -= IcSz/2`

    `}`

    `TrayTitle := "AHK_class NotifyIconOverflowWindow"`

    `ControlNN := "ToolbarWindow321"`

    `IcSz := 32`

`}`

`DetectHiddenWindows, %HiddenWindows%`

`Return`

}


Sleep 1000


TrayIcon_Button("Probkp.exe", "R")

which so far right clicks on the required tray icon but i can't figure out how to click on the required item in that menu.

Menu items are:

-Backup Now

-Server Settings

-Transfer Transactions / Period

-Transfer Transactions

-Transfer Data

-Download Transactions

-Reset Orders

-Exit

Required Item is "Transfer Transactions"

Also Tray Refresh works on windows 10 yet not on windows 7 due to this line of code:

`ControlNN := "ToolbarWindow323"`

Where windows 7 the code is "ToolbarWindow322" not "ToolbarWindow323"

Is there a way to make this dynamic for both windows?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source