3
已解决
王梓轩
资深光能
资深光能
#include<bits/stdc++.h>
#include<windows.h>
#define KEY_DOWN(VK_NONAME)((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
void SendInputString(string str)
{
int len=str.length();
if(len==0)return;
std::vector<INPUT>in(len*2);
ZeroMemory(&in[0],in.size()*sizeof(INPUT));
int i=0,idx=0;
while(i<len)
{
WORD ch=(WORD)str[i++];
if((ch<0xD800)||(ch>0xDFFF))
{
in[idx].type=INPUT_KEYBOARD;
in[idx].ki.wScan=ch;
in[idx].ki.dwFlags=KEYEVENTF_UNICODE;
++idx;
in[idx]=in[idx-1];
in[idx].ki.dwFlags|=KEYEVENTF_KEYUP;
++idx;
}
else
{
in[idx].type=INPUT_KEYBOARD;
in[idx].ki.wScan=ch;
in[idx].ki.dwFlags=KEYEVENTF_UNICODE;
++idx;
in[idx].type=INPUT_KEYBOARD;
in[idx].ki.wScan=(WORD)str[i++];
in[idx].ki.dwFlags=KEYEVENTF_UNICODE;
++idx;
in[idx]=in[idx-2];
in[idx].ki.dwFlags|=KEYEVENTF_KEYUP;
++idx;
in[idx]=in[idx-2];
in[idx].ki.dwFlags|=KEYEVENTF_KEYUP;
++idx;
}
}
SendInput(in.size(),&in[0],sizeof(INPUT));
}
int main()
{
string a,lujing="C:\\Program Files (x86)\\Kingsoft\\TypeEasy\\TypeGame\\Police\\Data\\English\\E_General\\";
getline(cin,a),lujing+=a;
while(!KEY_DOWN(' '));
ifstream inFile;
inFile.open((lujing+".txt").c_str(),ios::in);
getline(inFile,a);
SendInputString(a);
fclose(stdin);
}