Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to send click a button within another application
ToolBarWindow32 object. I have found on internet but i can't still do it.
I used SendMessage(hToolbar, TB_PRESSBUTTON, (WPARAM)0, MAKELONG(TRUE, 0)); but nothing happened. I also tried

TBBUTTON TB_Data;<br />
SendMessage(hToolbar, TB_GETBUTTON, (WPARAM)1 /*index*/, (LPARAM)&TB_Data);<br />
SendMessage(hToolbar, TB_PRESSBUTTON, TB_Data.idCommand, (LPARAM)true);<br />

or

SendMessage(hToolbar, TB_PRESSBUTTON, 0, 0);<br />

but they aren't worrking.
--------------
HWND hToolbar;
TBBUTTON TB_Data;

HWND hWnd = ::FindWindow(0, L"Test window");

hToolbar= ::FindWindowEx(hWnd, 0, L"ToolbarWindow32", 0);

// Send click...
// Help me


Thanks in advance.
Posted

Have you already tried it ? :) :
::SendMessage(hWndFrameOfBar,
              WM_COMMAND,
              (WPARAM) iBtnCommand,
              (LPARAM) 0);
 
Share this answer
 
Comments
Chicken123456789 4-Oct-10 0:04am    
How can I get hWndFrameOfBar and iBtnCommand?...
Eugen Podsypalnikov 4-Oct-10 1:45am    
Hm... I thought, you know them :)
- Please validate your received hWnd and hToolbar by Spy.
- Try it (yours) also with the index 0 (the separators have their positions as well).
- Please observe the returned value by SendMessage(.., TB_GETBUTTON, ..)
- Try also the message TB_GETBUTTONINFO (set the field cbSize before you will pass a TBBUTTONINFO)
- Usually, the commands handling frame of a bar is its parent or the main window
- Does the window "Test window" lie in an external process (started by the same rights) ?
Try sending the following 2 commands one after the other -
SendMessage(hToolbar, TB_PRESSBUTTON, TB_Data.idCommand, (LPARAM)TRUE);
SendMessage(hToolbar, TB_PRESSBUTTON, TB_Data.idCommand, (LPARAM)FALSE);
 
Share this answer
 
Thank _Superman_
But They don't work...

HWND hToolbar;
TBBUTTON TB_Data;

HWND hWnd = ::FindWindow(0, L"Test window");

hToolbar = ::FindWindowEx(hWnd, 0, L"ToolbarWindow32", 0);

::SendMessage(hToolbar, TB_GETBUTTON, (WPARAM)6 /*index*/, (LPARAM)&TB_Data);
// ==> TB_Data was not changed.
// "Test windows" was closed...?

::SendMessage(hToolbar, TB_PRESSBUTTON, TB_Data.idCommand, (LPARAM)TRUE);
::SendMessage(hToolbar, TB_PRESSBUTTON, TB_Data.idCommand, (LPARAM)FALSE);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900