Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #define WINVER 0x0601
- #include <windows.h>
- using namespace std;
- /*
- 1. copy some text
- 2. enter any character and press enter
- 3. after 1.5 seconds it will type it
- */
- INPUT ip;
- HKL kbl;
- inline short getVKCode(char ch) {
- return VkKeyScanExA(ch, kbl);
- }
- string getClipboard() {
- HANDLE h;
- if (!OpenClipboard(NULL)) return "";
- h = GetClipboardData(CF_TEXT);
- return string((char *)h);
- }
- void keyDown(short c) {
- ip.ki.wVk = c;
- ip.ki.dwFlags = 0; //keydown
- SendInput(1, &ip, sizeof(INPUT));
- }
- void keyUp(short c) {
- ip.ki.wVk = c;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- int main() {
- bool useshift[200] = {};
- {
- string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ<>:\"{}()!@#$%^&*_+~";
- for (char ch : s) {
- useshift[(int)ch] = 1;
- }
- }
- kbl = GetKeyboardLayout(0);
- ip.type = INPUT_KEYBOARD;
- ip.ki.wScan = 0;
- ip.ki.time = 0;
- ip.ki.dwExtraInfo = 0;
- while (1) {
- string waitstr;
- getline(cin, waitstr);
- string towrite = getClipboard();
- Sleep(1500);
- for (int i = 0; i < (int)towrite.length(); ++i) {
- char ch = towrite[i];
- if (useshift[(int)ch]) {
- keyDown(0x10);
- Sleep(1);
- }
- keyDown(getVKCode(ch));
- Sleep(5);
- keyUp(getVKCode(ch));
- Sleep(5);
- if (useshift[(int)ch]) {
- keyUp(0x10);
- Sleep(1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement