KaFu Posted January 18, 2015 Share Posted January 18, 2015 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 ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
j0kky Posted January 18, 2015 Share Posted January 18, 2015 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 ). 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)) Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
KaFu Posted January 20, 2015 Share Posted January 20, 2015 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. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
j0kky Posted January 20, 2015 Share Posted January 20, 2015 (edited) 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 Thank you for your time and I'm sorry to bother you but these stuffs really make me curious Edited January 20, 2015 by j0kky Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
KaFu Posted January 20, 2015 Share Posted January 20, 2015 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 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 ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
j0kky Posted January 20, 2015 Share Posted January 20, 2015 (edited) 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 January 20, 2015 by j0kky Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs 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