Guest User

Untitled

a guest
May 20th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. HWND ButtonHandle;
  2. if( (wnd = FindWindow(0, "Do you want to save?")) )
  3. {
  4. ButtonHandle = FindWindowEx(wnd, 0, "SaveButton", "&Save");
  5. SendMessage(wnd, WM_COMMAND, MAKEWORD(GetDlgCtrlID(ButtonHandle), BN_CLICKED ), (LPARAM)ButtonHandle);
  6.  
  7. }
  8.  
  9. SendMessage(ButtonHandle, BM_CLICK, 0, 0);
  10.  
  11. SendMessage(ButtonHandle, WM_LBUTTONDOWN, 0, 0);
  12. SendMessage(ButtonHandle, WM_LBUTTONUP, 0, 0);
  13.  
  14. SendMessage(ButtonHandle, BM_CLICK, 0, 0);
  15.  
  16. HWND buttonHandle = 0;
  17.  
  18. BOOL CALLBACK GetButtonHandle(HWND handle, LPARAM)
  19. {
  20. char label[100];
  21. int size = GetWindowTextA(handle,label,sizeof(label));
  22. if(strcmp(label,"&Save") == 0)
  23. {
  24. buttonHandle = handle;
  25. return false;
  26. }
  27. return true;
  28. }
  29. void main()
  30. {
  31. HWND windowHandle = FindWindowA(NULL,"Do you want to Save?");
  32. if(windowHandle != 0)
  33. {
  34. BOOL ret = EnumChildWindows(windowHandle,GetButtonHandle,0);
  35.  
  36. if(buttonHandle != 0)
  37. {
  38. LRESULT res = SendMessage(buttonHandle,BM_CLICK,0,0);
  39. //SendMessage(buttonHandle,WM_LBUTTONDOWN,0,0);
  40. //SendMessage(buttonHandle,WM_LBUTTONUP,0,0);
  41. }
  42.  
  43. }
  44.  
  45.  
  46.  
  47. }
  48.  
  49. SendMessage(btnHandle, WM_LBUTTONDOWN, 0, 0);
  50. SendMessage(btnHandle, WM_LBUTTONUP, 0, 0);
  51. SendMessage(btnHandle, WM_LBUTTONDOWN, 0, 0);
  52. SendMessage(btnHandle, WM_LBUTTONUP, 0, 0);
  53.  
  54. void CMyClass::OnMessageY(CWnd *cwnd)
  55. {
  56. CBaseClass::OnMessageY(cwnd);
  57. //... my code
  58. }
  59.  
  60. HWND ButtonHandle;
  61. if( (wnd = FindWindow(0, "Do you want to save?")) )
  62. {
  63. SendMessage(ButtonHandle, WM_LBUTTONDOWN, MK_LBUTTON, 0);
  64. SendMessage(ButtonHandle, WM_LBUTTONUP, MK_LBUTTON, 0);
  65. }
Add Comment
Please, Sign In to add comment