Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Taskbar button text [modified]

Taskbar button text [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
linuxquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kartikdasani
    wrote on last edited by
    #1

    I am trying to get the list of windows displayed in the windows taskbar and am doing so in the following manner:

    HWND hDesktop = GetDesktopWindow();
    HWND hTray = FindWindow(_T("Shell_TrayWnd"), NULL );
    HWND hReBar = FindWindowEx( hTray, NULL, _T("ReBarWindow32") , NULL );
    HWND hTask = FindWindowEx( hReBar, NULL, _T("MSTaskSwWClass") , NULL );
    HWND hToolbar = FindWindowEx(hTask,NULL,_T("ToolbarWindow32") , _T("Running Applications") );
    long cnt = SendMessage(hToolbar, TB_BUTTONCOUNT,0,0);
    long pid,hprocess,text,len;
    WCHAR * buttontext[128];
    GetWindowThreadProcessId(hToolbar(LPDWORD)pid);
    hprocess = (long)OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION,0,pid);
    text = (long)VirtualAllocEx((HANDLE)hprocess,0,sizeof(buttontext),MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
    for(int i=0;i<cnt;i++)
    {
    len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
    if(len>-1)
    {
    ReadProcessMemory((HANDLE)hprocess, (LPCVOID)text,buttontext,sizeof(buttontext),NULL);
    wcout<<buttontext<<"\n";
    }
    }

    I have not been able to get the text and any other message eg:TB_PRESSBUTTON doesn't work either. Any suggestions?

    modified on Friday, July 29, 2011 8:38 AM

    L _ 3 Replies Last reply
    0
    • K kartikdasani

      I am trying to get the list of windows displayed in the windows taskbar and am doing so in the following manner:

      HWND hDesktop = GetDesktopWindow();
      HWND hTray = FindWindow(_T("Shell_TrayWnd"), NULL );
      HWND hReBar = FindWindowEx( hTray, NULL, _T("ReBarWindow32") , NULL );
      HWND hTask = FindWindowEx( hReBar, NULL, _T("MSTaskSwWClass") , NULL );
      HWND hToolbar = FindWindowEx(hTask,NULL,_T("ToolbarWindow32") , _T("Running Applications") );
      long cnt = SendMessage(hToolbar, TB_BUTTONCOUNT,0,0);
      long pid,hprocess,text,len;
      WCHAR * buttontext[128];
      GetWindowThreadProcessId(hToolbar(LPDWORD)pid);
      hprocess = (long)OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION,0,pid);
      text = (long)VirtualAllocEx((HANDLE)hprocess,0,sizeof(buttontext),MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
      for(int i=0;i<cnt;i++)
      {
      len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
      if(len>-1)
      {
      ReadProcessMemory((HANDLE)hprocess, (LPCVOID)text,buttontext,sizeof(buttontext),NULL);
      wcout<<buttontext<<"\n";
      }
      }

      I have not been able to get the text and any other message eg:TB_PRESSBUTTON doesn't work either. Any suggestions?

      modified on Friday, July 29, 2011 8:38 AM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please edit your question and add <pre> tags around your code to make it more readable.

      The best things in life are not things.

      1 Reply Last reply
      0
      • K kartikdasani

        I am trying to get the list of windows displayed in the windows taskbar and am doing so in the following manner:

        HWND hDesktop = GetDesktopWindow();
        HWND hTray = FindWindow(_T("Shell_TrayWnd"), NULL );
        HWND hReBar = FindWindowEx( hTray, NULL, _T("ReBarWindow32") , NULL );
        HWND hTask = FindWindowEx( hReBar, NULL, _T("MSTaskSwWClass") , NULL );
        HWND hToolbar = FindWindowEx(hTask,NULL,_T("ToolbarWindow32") , _T("Running Applications") );
        long cnt = SendMessage(hToolbar, TB_BUTTONCOUNT,0,0);
        long pid,hprocess,text,len;
        WCHAR * buttontext[128];
        GetWindowThreadProcessId(hToolbar(LPDWORD)pid);
        hprocess = (long)OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION,0,pid);
        text = (long)VirtualAllocEx((HANDLE)hprocess,0,sizeof(buttontext),MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
        for(int i=0;i<cnt;i++)
        {
        len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
        if(len>-1)
        {
        ReadProcessMemory((HANDLE)hprocess, (LPCVOID)text,buttontext,sizeof(buttontext),NULL);
        wcout<<buttontext<<"\n";
        }
        }

        I have not been able to get the text and any other message eg:TB_PRESSBUTTON doesn't work either. Any suggestions?

        modified on Friday, July 29, 2011 8:38 AM

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        Do some error checking. It's like a Cataract Operation. Check return values for error. Call GetLastError to get the error value. Use that in the error lookup tool. All that will give you a lot of information on what is going wrong.

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++)

        Polymorphism in C

        1 Reply Last reply
        0
        • K kartikdasani

          I am trying to get the list of windows displayed in the windows taskbar and am doing so in the following manner:

          HWND hDesktop = GetDesktopWindow();
          HWND hTray = FindWindow(_T("Shell_TrayWnd"), NULL );
          HWND hReBar = FindWindowEx( hTray, NULL, _T("ReBarWindow32") , NULL );
          HWND hTask = FindWindowEx( hReBar, NULL, _T("MSTaskSwWClass") , NULL );
          HWND hToolbar = FindWindowEx(hTask,NULL,_T("ToolbarWindow32") , _T("Running Applications") );
          long cnt = SendMessage(hToolbar, TB_BUTTONCOUNT,0,0);
          long pid,hprocess,text,len;
          WCHAR * buttontext[128];
          GetWindowThreadProcessId(hToolbar(LPDWORD)pid);
          hprocess = (long)OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION,0,pid);
          text = (long)VirtualAllocEx((HANDLE)hprocess,0,sizeof(buttontext),MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
          for(int i=0;i<cnt;i++)
          {
          len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
          if(len>-1)
          {
          ReadProcessMemory((HANDLE)hprocess, (LPCVOID)text,buttontext,sizeof(buttontext),NULL);
          wcout<<buttontext<<"\n";
          }
          }

          I have not been able to get the text and any other message eg:TB_PRESSBUTTON doesn't work either. Any suggestions?

          modified on Friday, July 29, 2011 8:38 AM

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          kartikdasani wrote:

          len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);

          The value of i is counting from 0 to TB_BUTTONCOUNT. Are you sure those values match the command identifiers of the buttons on your toolbar? See here[^] for more details. You should also (always) follow Superman[^]'s advice.

          The best things in life are not things.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups