Windows : Retrive Quick Launch toolbar items

Discussion in 'Ruby' started by Ak Newfish, Mar 23, 2009.

  1. Ak Newfish

    Ak Newfish Guest

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

    Regards,
    --AK
    --
    Posted via http://www.ruby-forum.com/.
    Ak Newfish, Mar 23, 2009
    #1
    1. Advertising

  2. Ak Newfish

    Heesob Park Guest

    2009/3/23 Ak Newfish <>:
    > 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
    Heesob Park, Mar 23, 2009
    #2
    1. Advertising

  3. Ak Newfish

    Ak Newfish Guest

    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.

    --
    Posted via http://www.ruby-forum.com/.
    Ak Newfish, Mar 23, 2009
    #3
  4. Ak Newfish

    Heesob Park Guest

    Hi,

    2009/3/23 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?
    >

    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
    Heesob Park, Mar 23, 2009
    #4
  5. Ak Newfish

    Ak Newfish Guest

    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



    --
    Posted via http://www.ruby-forum.com/.
    Ak Newfish, Mar 24, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mrmagoo
    Replies:
    1
    Views:
    545
    Bruno Alexandre
    Jun 10, 2006
  2. CT
    Replies:
    0
    Views:
    276
  3. Amit Shinde

    Retrive the items in list box

    Amit Shinde, May 20, 2004, in forum: ASP General
    Replies:
    1
    Views:
    103
    Dominique
    May 20, 2004
  4. Vikas Gholap
    Replies:
    10
    Views:
    772
    Bertram Scharpf
    Feb 13, 2009
  5. pcouas
    Replies:
    0
    Views:
    240
    pcouas
    Feb 19, 2007
Loading...

Share This Page