C++自动输入器v2.1

回复帖子

@AuCloud  2021-01-13 16:14 回复

C++自动输入器v2.1

  • 根据反馈,gets()在高版本g++中已经被弃用了,更新成了cin.getline()

  • 更新了操作方式,降低了操作说明的理解难度(?)


使用方法:

  • 在程序目录文件夹新建shuru.txt文件
  • 把想要输入的内容放在shuru.txt
  • 编译并运行程序
  • 将光标放在需要输入的地方,将输入法设置为英文,等待10秒钟
  • 开始输入!

#include<iostream>
#include<cstring>
#include<cstdio>
#include<windows.h>
using namespace std;
int n;
char s[1][10000001];
int main()
{
    freopen("shuru.txt","r",stdin);
    freopen("qwq.cpp","w",stdout);
    cout<<"#include<iostream>\n#include<ctime>\n#include<windows.h>\nusing namespace std;\nint main()\n{\nSleep(10000);\n";
    int i=0;
    while(cin.getline(s[i],10000000))
    {
        int l=strlen(s[i]);
        for(int j=0;j<l;j++)
        {
            if(s[i][j]>='a'&&s[i][j]<='z')
                cout<<"keybd_event('"<<char(s[i][j]-'a'+'A')<<"',(BYTE)0, 0 ,0); \nkeybd_event('"<<char(s[i][j]-'a'+'A')<<"', (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            else if(s[i][j]=='#')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('3',(BYTE)0, 0 ,0); \nkeybd_event('3', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='!')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('1',(BYTE)0, 0 ,0); \nkeybd_event('1', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='@')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('2',(BYTE)0, 0 ,0); \nkeybd_event('2', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='$')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('4',(BYTE)0, 0 ,0); \nkeybd_event('4', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='%')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('5',(BYTE)0, 0 ,0); \nkeybd_event('5', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='^')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('6',(BYTE)0, 0 ,0); \nkeybd_event('6', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='&')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('7',(BYTE)0, 0 ,0); \nkeybd_event('7', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='*')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('8',(BYTE)0, 0 ,0); \nkeybd_event('8', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='<')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_COMMA,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_COMMA, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='>')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_PERIOD ,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_PERIOD , (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='(')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('9',(BYTE)0, 0 ,0); \nkeybd_event('9', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]==')')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event('0',(BYTE)0, 0 ,0); \nkeybd_event('0', (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='[')
            {
                cout<<"keybd_event(VK_OEM_4,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_4, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]==']')
            {
                cout<<"keybd_event(VK_OEM_6,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_6, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='-')
            {
                cout<<"keybd_event(VK_OEM_MINUS,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_MINUS, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='_')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_MINUS,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_MINUS, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='=')
            {
                cout<<"keybd_event(VK_OEM_PLUS,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_PLUS, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='+')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_PLUS,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_PLUS, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='\t')
            {
                cout<<"keybd_event(VK_TAB,(BYTE)0, 0 ,0); \nkeybd_event(VK_TAB, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='`')
            {
                cout<<"keybd_event(VK_OEM_3,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_3, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='~')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_3,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_3, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]==';')
            {
                cout<<"keybd_event(VK_OEM_1,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_1, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]==':')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_1,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_1, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='{')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_4,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_4, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='\'')
            {
                cout<<"keybd_event(VK_OEM_7,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_7, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='\"')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_7,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_7, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='\\')
            {
                cout<<"keybd_event(VK_OEM_5,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_5, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='|')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_5,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_5, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='/')
            {
                cout<<"keybd_event(VK_OEM_2,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_2, (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='?')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_2,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_2, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='}')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_OEM_6,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_6, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='?')
            {
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0); \nkeybd_event(VK_DIVIDE,(BYTE)0, 0 ,0); \nkeybd_event(VK_DIVIDE, (BYTE)0, KEYEVENTF_KEYUP,0);\nkeybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]==' ')
            {
                cout<<"keybd_event(VK_SPACE, 0, 0 ,0); \nkeybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]=='.')
            {
                cout<<"keybd_event(VK_OEM_PERIOD ,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_PERIOD , (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]==',')
            {
                cout<<"keybd_event(VK_OEM_COMMA ,(BYTE)0, 0 ,0); \nkeybd_event(VK_OEM_COMMA , (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            }
            else if(s[i][j]>='0'&&s[i][j]<='9')
                cout<<"keybd_event('"<<s[i][j]<<"',(BYTE)0, 0 ,0); \nkeybd_event('"<<s[i][j]<<"', (BYTE)0, KEYEVENTF_KEYUP,0);\n";
            else if(s[i][j]>='A'&&s[i][j]<='Z')
                cout<<"keybd_event(VK_LSHIFT, 0, 0,0);\nkeybd_event('"<<s[i][j]<<"',(BYTE)0, 0 ,0); \nkeybd_event('"<<s[i][j]<<"', (BYTE)0, KEYEVENTF_KEYUP,0);keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP,0);\n";
            cout << " \n";
        }
        cout<<"\nkeybd_event(VK_RETURN, 0, 0 ,0);\nkeybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP,0);\n";
    }
    cout<<"return 0;\n}";
    fclose(stdout);
    system("g++ qwq.cpp -o qwq");
    system("pause");
    fprintf(stderr, "------Running------\nPlease wait for about ten seconds.");
    system("qwq");
    return 0;
}
@AuCloud  2021-01-13 16:20 回复 举报

句柄无效可能是fclose UB了,目前不知道咋修,反正不影响最终效果(?)

@swift_zym 2021-01-13 16:51 回复 举报

(如果用clang编译,要在开始处加一句#pragma comment(lib,"user32"))

反馈
如果你认为某个帖子有问题,欢迎向洛谷反馈,以帮助更多的同学。



请具体说明理由,以增加反馈的可信度。