I "lifted" the following piece of code from the archived board:
https://autohotkey.com/board/topic/3773 ... /?p=237440
Thanks to pajenn and SKAN for it (hope I got this right).
Code: Select all
SafelyRemoveHardware() {
if WinExist("Battery Meter") and WinExist("ahk_class SystemTray_Main") {
hWnd := WinExist( "Battery Meter ahk_class SystemTray_Main" )
PostMessage, 1226, 1226, 0x201,, ahk_id %hWnd% ; Left Click Down
PostMessage, 1226, 1226, 0x202,, ahk_id %hWnd% ; Left Click Up
WinWaitActive, ahk_id %hWnd%,,1 ; Wait for SRH Tray left-click-Menu
ControlSend,,{Down}{Down},ahk_id %hWnd% ; Select the first menu Item
}
}
For a couple of years it worked perfectly fine on Windows 10 x64 - I hit my key combo and it opens the context menu where I can choose a USB device to eject.
It usually worked way faster than doing so the regular way - opening "hidden icons" tray and clicking the right icon.
Unfortunately after the latest Win10 update (version 1709 build 16299.192) this function isn't working anymore. The hWnd is being returned by WinExist but nothing else happens.
Does anybody know how to make it pop the context menu again?
Thanks