sulfurious Posted January 29, 2008 Author Share Posted January 29, 2008 Erm, Since MSCreatoR gave the whole solution away on a silver platter, and some people still didn't get it,Yes, I did acknowledge that using the mouse coordinate method works. I also either refute it working with a compiled script tray menu correctly, or I am in need of some correction for my erroroneous attempt. It's so simple you'll kick yourself... WinGetHandle("[CLASS:Shell_TrayWnd]")Um, I understand that to return a handle is nice, but I do not understand how to apply this to make the handle 'pop open' to display the tray menu. Can you elaborate? The guy was just asking for a good solution, he wasn't happy with yours. It is nothing personal, get over it.For the record, I am asking for a solution that is, I hope, better than a mouse move/click approach. However, I am most happy that people take the time to help, and definitively do not intend disrespect to said help. Opt("WinSearchChildren", 1) Opt("WinTitleMatchMode", 4) WinActivate("[CLASS:TrayNotifyWnd]") Does that do exactly what he wants now? I tried that, but I could not get it to work. I simply made some tray items, from a tray item made a gui with a button, and made the button do the fuction above, with the OPTs in place. Does this refer to the script itself by default, or what is the scope of pulling the CLASS:TrayNotifyWnd ? I still do not find a way to trigger the tray to 'pop up'. It is highly probable that I am not applying the data presented to me in the correct syntax or structure. I should imagine that this is possible without the mousing, but who knows. Again, thanks for your interst and time. Sul. Link to comment Share on other sites More sharing options...
psylem Posted January 29, 2008 Share Posted January 29, 2008 That code simply brings the focus to the entire system tray. If you move the arrow keys you'll notice the tray items are shifting focus to one another and the item in focus is surrounded by a square. You can open them with an "enter key" event. Ok, I didn't understand that you also wanted to open a specific tray item, but I think we're getting closer. I'll have another look at the problem, but it can't be too difficult. Link to comment Share on other sites More sharing options...
sulfurious Posted January 29, 2008 Author Share Posted January 29, 2008 That code simply brings the focus to the entire system tray. If you move the arrow keys you'll notice the tray items are shifting focus to one another and the item in focus is surrounded by a square. You can open them with an "enter key" event.Ok, I didn't understand that you also wanted to open a specific tray item, but I think we're getting closer. I'll have another look at the problem, but it can't be too difficult.Ok, now I see, it focuses on the system tray. I did not know you could navigate the tray like that, arrows/enter etc..I thought that by using the systray udf I could get the icon index of the compiled script. Then if needed use the mouse method to trigger it. However, I cannot get a successful return of the tray icon index. I think it has something to do with the fact that an autoit compiled script is not a true parent process, but more of a child process to the wrapper, at least in the sense of the tray icon. I posted some of what I was trying with that earlier.Anyway,, thanks for the interest.Sul. Link to comment Share on other sites More sharing options...
psylem Posted January 29, 2008 Share Posted January 29, 2008 (edited) Here's a working example, save it as "New AutoIt v3 Script.au3", run it and then press F1. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: Psylem Script Function: Demo to activate a task tray item #ce ---------------------------------------------------------------------------- #Include <GuiToolBar.au3> HotKeySet("{ESC}","OnESC") HotKeySet("{F1}","OnF1") While 1 sleep(500) WEnd Func OnF1() Activate("AutoIt - New AutoIt v3 Script.au3") EndFunc Func Activate($taskName) AutoItSetOption("WinSearchChildren", 1) AutoItSetOption("WinTitleMatchMode", 4) $hWnd = WinGetHandle("[TITLE:Notification Area]") For $i = 0 To _GUICtrlToolbar_ButtonCount($hWnd) - 1 ConsoleWrite(_GUICtrlToolbar_GetButtonText($hWnd,$i) & @CRLF) If _GUICtrlToolbar_GetButtonText($hWnd,$i) = $taskName Then ;The doco mentions _GUICtrlToolbar_ClickButton, but this doesn't exist ;The following lines don't work either... ;_GUICtrlToolbar_PressButton($hWnd, $i) ;_GUICtrlToolbar_CheckButton($hWnd, $i) WinActivate("[TITLE:Notification Area]") _GUICtrlToolbar_SetHotItem($hWnd, _GUICtrlToolbar_CommandToIndex($hWnd, $i)) Sleep(200) Send("{ENTER}") ConsoleWrite("Button Pressed") ExitLoop EndIf Next EndFunc Func OnESC() Exit EndFunc I figured out the tray was a ToolWindow32 class and somehow figured out this means it's a toolbar and so you can use the GuiToolBar library to interact with it. It wasn't a very intuitive process, but I think this solution is what you were looking for. I notice that the mouse cursor moves down when the enter command is sent. If you want it to stay where it was, the only thing I can think is to quickly get the mouse position and restore it after sending enter (unless you find a better way to activate the item). Edited January 29, 2008 by psylem Link to comment Share on other sites More sharing options...
sulfurious Posted January 29, 2008 Author Share Posted January 29, 2008 That is a pretty good solution. It is very similar to the mouse move click really, but it does solve the issue of actually getting the correct icon to 'click' on. Furthermore, it allows me to use the compiled script name.exe, instead of calling multiple routines to find the index based on the tooltip name. I too looked at the gui toolbar functions, and the button ones did not seem to apply for my solution. I, ahem, missed the intended use of the sethotitem. My fault there. I did not think to use NotificationArea anyway, so I doubt I would have gotten it to work. I will keep looking for a way to not interfere with the mouse while I have time to play. Thanks to all who gave help, I have not only learned new stuff (as always), but have a few different methods to play with for the solution to my problem. Thank you for your time and interest. Sul. Link to comment Share on other sites More sharing options...
psylem Posted January 29, 2008 Share Posted January 29, 2008 I will keep looking for a way to not interfere with the mouse while I have time to play. Yeah, I thought there would be a way to activate the menu without moving the mouse cursor, but I think the menu is positioned relative to the mouse cursor anyway, so even if you find a method then you have to decide if you really want the menu appearing where ever your mouse happens to be at the time. The other option is something like this... $pos = MouseGetPos() Send("{ENTER}") MouseMove($pos[0], $pos[1], 0) I know it's a hack, but I found this gives the desired result. I just tried moving the mouse in figure 8's while activating the script and couldn't even tell the mouse was moved at all. 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