WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Control Manager
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Window 7 Access System Tray Notification Area

 Keywords: Window 7 Win7 Access System Tray Systray Notification Area 64-bit Shell_TrayWnd cGetTBText cClickToolbar ToolbarWindow32

Question:

I am trying to access a program only available in the system tray (systray, notification area) in Windows 7. I found the code below in your help faq but it no longer works with Windows 7 64-bit. Can you update it to work or is there some other way to access a program in the system tray and select a menu?
;RoboScripter
; Made with
; RoboScripter ver: 28
; CtlMgr ver: 20026
AddExtender("wwctl34i.dll")

;Title: Notification Area
;ID: 0
;Class: ToolbarWindow32
;Level: 4
window1=cWndByWndSpec("Shell_TrayWnd","explorer",3,304,303,40965)
window2=cWndbyid(window1,303)
window3=cWndbyid(window2,0)
ControlHandle=cWndbyid(window3,0)
result=cGetTbText(ControlHandle)
Message("Toolbar Text",StrReplace(result,@TAB,@CRLF))

;Get the index of the button
select1=ItemLocate("WinBatch PopMenu", result, @TAB);note ItemLocate is case sensitive
Message("",select1)
cClickToolbar(Controlhandle,select1) ;Clicks a toolbar button

Answer:

The systray is a 64-bit control on Windows 7 and therefore requires the use of 64-bit WinBatch to access the toolbar data. Here is a code sample that will locate and left click on an item in the systray using the 64-bit version of WinBatch:
AddExtender("wwctl64i.dll")

;Title: User Promoted Notification Area
;ID: 1504
;Class: ToolbarWindow32
;Level: 4

; Default cWndByWndSpec seems OK here
window1=cWndByWndSpec("Shell_TrayWnd","explorer",2,303,40965)
window2=cWndbyid(window1,303)
window3=cWndbyid(window2,0)
ControlHandle=cWndbyid(window3,1504)
tblist=cGetTbText(ControlHandle)

tbitem = AskItemlist('Choose Items to Left Click', tblist, @TAB, @UNSORTED, @SINGLE)

clicktypes = "Left-Click":@TAB:"Right-Click"
type = AskItemlist("Click Type?", clicktypes, @TAB, @UNSORTED, @SINGLE )
If type == "Left-Click" Then clicktype = 1
Else clicktype = 3

buttonnum=ItemLocate(tbitem,tblist,@TAB)
cSetFocus( ControlHandle )
cClickToolbar(ControlHandle,buttonnum,clicktype)
;SendKey( '{down}' )
Exit

Article ID:   W17563
Filename:   Window 7 Access System Tray Notification Area .txt
File Created: 2012:12:05:10:07:02
Last Updated: 2012:12:05:10:07:02