Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automated process manipulation; close tray app
#4
Quote:ShutDownProcess kills the process without doing cleanup (orphan systray icon left)

http://www.quickmacros.com/forum/showthr...4#pid31254



Quote:Probably it is done by PostMessage hwnd WM_COMMAND ?

Only if it is a classic menu, class name #32768. The code can be recorded.

Example 1 - close Task Manager through its tray icon, using WM_COMMAND.
Step 1 - record. Recorded code:
Code:
Copy      Help
#region Recorded 2018-06-18 08:17:15
rig 1734 15 win("" "Shell_TrayWnd") 1 ;;tool bar 'User Promoted Notification ...', push button 'CPU 5%[]Memory 61%[]Disk 0%...'
lef 36 14 wait(15 WV win("" "#32768")) 1 ;;menu item 'Close'
;men 30435 win("" "TrayiconMessageWindow") ;;Close
#endregion

Step 2 - uncomment the men line and remove other code.
Code:
Copy      Help
men 30435 win("" "TrayiconMessageWindow") ;;Close

---------------------

Else use accessible object functions. To create code use dialogs from the floating toolbar, button "Windows controls".

Example 2 - close Task Manager through its tray icon, using accessible objects.

Code:
Copy      Help
;find tray icon using its tooltip text as wildcard
int w=win("" "Shell_TrayWnd")
Acc a.Find(w "PUSHBUTTON" "CPU *Memory *" "class=ToolbarWindow32[]id=1504" 0x1005) ;;Tested on Win10; else may be different tooltip text, id, etc.

;right-click the tray icon to show context menu
a.Mouse(2); mou
;sub.AccPostRightClickMessage a ;;or try this. Does not move the mous pointer, but may not work with some tray icons or on some Windows versions. Tested on Win10.

;wait for context menu
int w1=wait(5 WV win("" "#32768"))

;find the Close item and click
Acc a1.Find(w1 "MENUITEM" "Close" "" 0x1001)
a1.DoDefaultAction


#sub AccPostRightClickMessage
function Acc&a

int x y
a.Location(x y)
x+2; y+2
int w3=child(a)
ScreenToClient w3 +&x
int lParam=MakeInt(x y)
PostMessage w3 WM_RBUTTONDOWN MK_RBUTTON lParam
PostMessage w3 WM_RBUTTONUP 0 lParam


Messages In This Thread
RE: Automated process manipulation - by TheVig - 06-17-2018, 02:25 PM
RE: Automated process manipulation - by Ethereal - 06-17-2018, 03:22 PM
RE: Automated process manipulation - by Gintaras - 06-18-2018, 05:49 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)