Windows : Retrive Quick Launch toolbar items

A

Ak Newfish

How can I get Quick Launch toolbar items, present in the explorer/
desktop area? (Where you can see "Show Desktop" menu item)

Regards,
--AK
 
H

Heesob Park

2009/3/23 Ak Newfish said:
How can I get Quick Launch toolbar items, present in the explorer/
desktop area? (Where you can see "Show Desktop" =C2=A0menu item)
puts Dir.entries(ENV['USERPROFILE']+'\Application
Data\Microsoft\Internet Explorer\Quick Launch')

Regards,

Park Heesob
 
A

Ak Newfish

Hi Park,

Thanks a ton! works fine.

I have another problem pops up on my way, should need to get the
Notification area items (where you can see "volume control"), present in
the explorer/desktop area.

How to get notification area items?

Regards,
--AK.
 
H

Heesob Park

Hi,

2009/3/23 Ak Newfish said:
Hi Park,

Thanks a ton! works fine.

I have another problem pops up on my way, should need to get the
Notification area items (where you can see "volume control"), present in
the explorer/desktop area.

How to get notification area items?
If you mean system tray icons, that's not easy as you think.
Here is the code:


require 'Win32API'

PROCESS_QUERY_INFORMATION = 1024
PROCESS_ALL_ACCESS = 0x1F0FFF
WM_USER = 0x400
TB_BUTTONCOUNT = (WM_USER+24)
TB_GETBUTTON = (WM_USER+23)
MEM_COMMIT = 0x1000
MEM_RELEASE = 0x8000
PAGE_READWRITE = 0x4
TBSTATE_HIDDE = 0x8

FindWindow = Win32API.new('user32', 'FindWindow', 'PP', 'L')
FindWindowEx = Win32API.new('user32', 'FindWindowEx', 'LLPP', 'L')
SendMessage = Win32API.new('user32', 'SendMessage', 'LILL', 'L')
GetWindowThreadProcessId = Win32API.new('user32',
'GetWindowThreadProcessId', 'LP', 'L')
OpenProcess = Win32API.new('kernel32', 'OpenProcess', 'LIL', 'L')
GetModuleFileNameEx = Win32API.new('psapi', 'GetModuleFileNameEx', 'LLPL', 'L')
CloseHandle = Win32API.new('kernel32', 'CloseHandle', 'L', 'L')
ReadProcessMemory = Win32API.new('kernel32', 'ReadProcessMemory', 'LLPLP', 'L')
VirtualAllocEx = Win32API.new('kernel32', 'VirtualAllocEx', 'LLLLL', 'L')
VirtualFreeEx = Win32API.new('kernel32', 'VirtualFreeEx', 'LLL', 'L')

def getProcessNameFromhWnd(dwhWnd)
ppid = 0.chr * 4
GetWindowThreadProcessId.call(dwhWnd,ppid)
pid = ppid.unpack('L').first
hProcess = OpenProcess.call(PROCESS_ALL_ACCESS, 0, pid)
buffer = 0.chr * 1024
cbLen = GetModuleFileNameEx.call(hProcess, 0, buffer, buffer.length)
CloseHandle.call(hProcess)
buffer.strip
end

# Get the tray window handle. ( Window XP).
hWindow = FindWindow.call("Shell_TrayWnd", 0)
hWindow = FindWindowEx.call(hWindow, 0, "TrayNotifyWnd", 0)
hWindow = FindWindowEx.call(hWindow, 0, "SysPager", 0)
hWindow = FindWindowEx.call(hWindow, 0, "ToolbarWindow32", 0)

# Get the count of buttons in tray window.
trayCount = SendMessage.call(hWindow, TB_BUTTONCOUNT, 0, 0)
ppid = 0.chr * 4
GetWindowThreadProcessId.call(hWindow, ppid)
pid = ppid.unpack('L').first
hProcess = OpenProcess.call(PROCESS_ALL_ACCESS, 0, pid)
addr = VirtualAllocEx.call(hProcess, 0, 24, MEM_COMMIT, PAGE_READWRITE)
for cb in 0 ... trayCount
tray = 0.chr * 24
tb = 0.chr * 20
SendMessage.call(hWindow,TB_GETBUTTON,cb,addr)
cbRead = 0.chr * 4
ReadProcessMemory.call(hProcess,addr,tb,tb.length,cbRead)
fsState = tb[8,1].unpack('c').first
if fsState != TBSTATE_HIDDE
ReadProcessMemory.call(hProcess,tb[12,4].unpack('L').first,tray,tray.length,cbRead)
name = getProcessNameFromhWnd(tray[0,4].unpack('L').first)
puts name
end
end
VirtualFreeEx.call(hProcess,addr,0,MEM_RELEASE)
CloseHandle.call(hProcess)



Regards,

Park Heesob
 
A

Ak Newfish

Hi Park,

Thanks for your code! I mean for System tray icons and code worked like
a fly :)

Thanks a ton for your help.

Regards,
--AK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top