Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HWND ButtonHandle;
- if( (wnd = FindWindow(0, "Do you want to save?")) )
- {
- ButtonHandle = FindWindowEx(wnd, 0, "SaveButton", "&Save");
- SendMessage(wnd, WM_COMMAND, MAKEWORD(GetDlgCtrlID(ButtonHandle), BN_CLICKED ), (LPARAM)ButtonHandle);
- }
- SendMessage(ButtonHandle, BM_CLICK, 0, 0);
- SendMessage(ButtonHandle, WM_LBUTTONDOWN, 0, 0);
- SendMessage(ButtonHandle, WM_LBUTTONUP, 0, 0);
- SendMessage(ButtonHandle, BM_CLICK, 0, 0);
- HWND buttonHandle = 0;
- BOOL CALLBACK GetButtonHandle(HWND handle, LPARAM)
- {
- char label[100];
- int size = GetWindowTextA(handle,label,sizeof(label));
- if(strcmp(label,"&Save") == 0)
- {
- buttonHandle = handle;
- return false;
- }
- return true;
- }
- void main()
- {
- HWND windowHandle = FindWindowA(NULL,"Do you want to Save?");
- if(windowHandle != 0)
- {
- BOOL ret = EnumChildWindows(windowHandle,GetButtonHandle,0);
- if(buttonHandle != 0)
- {
- LRESULT res = SendMessage(buttonHandle,BM_CLICK,0,0);
- //SendMessage(buttonHandle,WM_LBUTTONDOWN,0,0);
- //SendMessage(buttonHandle,WM_LBUTTONUP,0,0);
- }
- }
- }
- SendMessage(btnHandle, WM_LBUTTONDOWN, 0, 0);
- SendMessage(btnHandle, WM_LBUTTONUP, 0, 0);
- SendMessage(btnHandle, WM_LBUTTONDOWN, 0, 0);
- SendMessage(btnHandle, WM_LBUTTONUP, 0, 0);
- void CMyClass::OnMessageY(CWnd *cwnd)
- {
- CBaseClass::OnMessageY(cwnd);
- //... my code
- }
- HWND ButtonHandle;
- if( (wnd = FindWindow(0, "Do you want to save?")) )
- {
- SendMessage(ButtonHandle, WM_LBUTTONDOWN, MK_LBUTTON, 0);
- SendMessage(ButtonHandle, WM_LBUTTONUP, MK_LBUTTON, 0);
- }
Add Comment
Please, Sign In to add comment