Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. // PostMessage.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. # include <iostream>
  5. # include <Windows.h>
  6. # include <synchapi.h>
  7.  
  8. int SendADown(int threadId) {
  9.     std::cout << "Send 'a' Down";
  10.  
  11.     // Copied params from spy++
  12.     WPARAM wParam = 0x41;
  13.     LPARAM lParam = 0x001E0001;
  14.  
  15.     return PostThreadMessage(threadId, WM_KEYDOWN, wParam, lParam);
  16. }
  17.  
  18. int SendAUp(int threadId) {
  19.     std::cout << "Send 'a' Up";
  20.  
  21.     // Copied params from spy++
  22.     WPARAM wParam = 0x41;
  23.     LPARAM lParam = 0xC01E0001;
  24.  
  25.     return PostThreadMessage(threadId, WM_KEYUP, wParam, lParam);
  26. }
  27.  
  28. int main()
  29. {
  30.     const int THREAD_ID = 15224;
  31.  
  32.     SendADown(THREAD_ID);
  33.     Sleep(3000);
  34.     SendAUp(THREAD_ID);
  35.     std::cout << "Hello World!\n";
  36.    
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement