Taskbar button text [modified]
-
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
-
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
-
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
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.
-
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
kartikdasani wrote:
len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
The value of
i
is counting from0
toTB_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.