Jump to content

[Solved] How To Refresh Traytooltip Display ?


Go to solution Solved by KaFu,

Recommended Posts

Afaik all tray related calls are made using ShellNotify_Icon, which is also implemented as _WinAPI_ShellNotifyIcon in AutoIt.

The reason the _SysTray functions in HMW access explorer.exe memory is that HMW can not only manipulate it's own tray icon but in fact all tray icons :)...

Link to post
Share on other sites

Yes, but if I knew hIcon param in NOTIFYICONDATA passed to Shell_NotifyIcon while the tray icon was created, I could pass it to IUserNotification::SetIconInfo method.

Maybe I can get the taskbar Image list through TB_GETIMAGELIST or SHGetFileInfo and then the handle through ImageList_GetIcon (but I dunno the exact icon index  :doh:).

Maybe there is a way to retrieve your own thread Image list ... Anyway I dunno the icon index.

Can I ask you another question? Why is it necessary to access explorer.exe memory to retrieve TBBUTTON data? What would happen if I held TBButton structure in my process memory and I did:

DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETBUTTON, "wparam", $iIndex, "lparam", DllStructGetPtr($TBBUTTON))
Link to post
Share on other sites

I'm not quite sure about this, but it seems that no information is retained in the current process at all. I guess the info is passed to the Tray via Shell_NotifyIcon and than it's gone (if not buffered manually).

The information is stored as part of the Tray Toolbar, that's why HMW uses the TBBUTTON (Toolbar Button) structure and ReadMemory to extract that info from explorer.exe. So as far as I see that's the only way to get the icon handle.

Link to post
Share on other sites

I'm not quite sure about this, but it seems that no information is retained in the current process at all. I guess the info is passed to the Tray via Shell_NotifyIcon and than it's gone (if not buffered manually).

I think Autoit executables buffer it manually, in fact you can put #noTrayicon anywhere in your script and from that point on the icon disappears, so the script is able to send whenever it wants a NIM_DELETE message through Shell_notifyIcon with the icon handle used previously.

The information is stored as part of the Tray Toolbar, that's why HMW uses the TBBUTTON (Toolbar Button) structure and ReadMemory to extract that info from explorer.exe.

I got it, but I don't understand why it is necessary to load TBBUTTON in explorer.exe memory, fill it through SendMessage(GET_BUTTON) and read it form explorer memory. Why can't we simply load TBBUTTON in our process memory, fill it via SendMessage with the params:

- hWnd: $trayHwnd -> Taskbar handle (explorer)

- Msg: $GET_BUTTON

- wParam: $iIndex

- lParam: $TBBUTTON -> DllStructGetPtr(DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[2];dword dwData;int iString")) just the pointer to TBBUTTON stored in our process memory, not in explorer memory

I suspect it is because lParam structure must belong to hWnd memory, otherwise it can be filled by SendMessage  :geek:

Thank you for your time and I'm sorry to bother you but these stuffs really make me curious :)

Edited by j0kky
Link to post
Share on other sites

I think Autoit executables buffer it manually, in fact you can put #noTrayicon anywhere in your script and from that point on the icon disappears, so the script is able to send whenever it wants a NIM_DELETE message through Shell_notifyIcon with the icon handle used previously.

 

You might be right, this behavior implies that. but I don't know of a way to access it.

I suspect it is because lParam structure must belong to hWnd memory, otherwise it can be filled by SendMessage  :geek:

Thank you for your time and I'm sorry to bother you but these stuffs really make me curious :)

 

That sounds like the most reasonable explanation. I guess it has something to do with shared memory and it seems like explorer.exe is not using this. So my best guess is that you send a pointer with your sendmessage which is just invalid in the explorer.exe process context.

Don't worry about bothering, I'm curious myself :)...

Link to post
Share on other sites

You might be right, this behavior implies that. but I don't know of a way to access it.

 

And that's why I'm thinking to open a feature request for adding a macro containing the icon handle :)

Thank you for your time, this topic was really interesting :)

Edited by j0kky
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...