Jump to content

Moving the tray menu


Recommended Posts

Greetings.

A while back I was searching for a way to use a hotkey to bring the tray menu up and move the mouse or focus to it. I was able (with help) to figure that out. I was starting the program via the startup folder. When I used the hotkey, the mouse moved to the tray and I could either use the arrow keys or the mouse to choose which option.

I was playing with some msstyles to change the color scheme etc of my xp rig. I downloaded something call uxtheme multipatcher to be able to edit my own themes. For some reason now when I use my hotkey, it actually moves the tray menu to my mouse cursor, exactly like a context menu would. I love this. If I mess with the original script and run it from scite, or I shut down my program and then run a traymenu script of similar style from scite, it no longer does this. A reboot however seems to cure the problem and it is back to making the tray menu act like a context menu.

This is extremely handy to have working. I have created dynamic tray items based off an .ini file, and unlike a context menu, I can do many autoit functions right from the script.

I will post an example of basically what I am doing, albeit less the .ini and dynamic item creation. Other than that, it is very similar to what I might be doing in my program.

Can anyone explain why this is happening, and possibly how I would go about re-creating this again. I would hate to reformat (which I like to do often) and never see this again.

Thank you.

Sul.

#Include <GuiToolBar.au3>
Opt("TrayOnEventMode",1)
Opt('TrayMenuMode',1)
Opt("GUIOnEventMode", 1)
HotKeySet('b','_trayUP')

$settingsitem = TrayCreateMenu("Settings")
$displayitem = TrayCreateItem("Display", $settingsitem)
$printeritem = TrayCreateItem("Printer", $settingsitem)
TrayCreateItem("")
$aboutitem = TrayCreateItem("About")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,'_exit')

$end = 1
While $end = 1
    Sleep(500)
WEnd

Func _trayUP()
    Activate('Autoit - tray_test.au3'); non-compiled
;~  Activate('tray_test.exe'); compiled
EndFunc

Func Activate($taskName)
    AutoItSetOption("WinSearchChildren", 1)
    AutoItSetOption("WinTitleMatchMode", 4)
    $hWnd = WinGetHandle("[TITLE:Notification Area]")
    For $i = 0 To _GUICtrlToolbar_ButtonCount($hWnd) - 1
        If _GUICtrlToolbar_GetButtonText($hWnd,$i) = $taskName Then   
            WinActivate("[TITLE:Notification Area]")
            _GUICtrlToolbar_SetHotItem($hWnd, _GUICtrlToolbar_CommandToIndex($hWnd, $i))
            Sleep(200)
            Send("{ENTER}")
            ExitLoop
        EndIf
    Next
EndFunc

Func _exit()
    $end = 0
    Exit
EndFunc
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...