使用INPUT数组的Windows.h c ++ CTRL + V模拟 [英] Windows.h c++ CTRL+V simulation with INPUT array

查看:65
本文介绍了使用INPUT数组的Windows.h c ++ CTRL + V模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试模拟ctrl + v执行。

但它不起作用,我不太清楚从哪里开始。



我也不知道是否  SendInput(1,ip,sizeof(INPUT));

数字"1"是结构数组大小的计数? (所以它应该是4?。然而,无论我尝试什么,它都不起作用,一些澄清会很感激!



$
INPUT ip [3];

     ip [0] .type = INPUT_KEYBOARD;

     ip [0 ] .ki.wScan = 0;

     ip [0] .ki.dwFlags = 0;

     ; ip [0] .ki.wVk = VK_CONTROL;

     ip [0] .ki.time = 0;

   ;   ip [0] .ki.dwExtraInfo = 0;



     ip [1] .type = INPUT_KEYBOARD;

     ip [1] .ki.wScan = 0;

     ip [1] .ki.dwFlags = 0;

     ip [1] .ki.wVk = 0x56;

     ip [1] .ki.time = 0;

     ip [1] .ki.dwExtraInfo = 0;



     ip [2] .type = INPUT_KEYBOARD;

   ;    ip [2] .ki.wScan = 0;

        ip [2] .ki.dwFlags = KEYEVENTF_KEYUP;

        ip [2] .ki.wVk = VK_CONTROL;

        ip [2] .ki.time = 0;

        ip [2] .ki.dwExtraInfo = 0;



        ip [3] .type = INPUT_KEYBOARD;

        ip [3] .ki.wScan = 0;

        ip [3] .ki.dwFlags = KEYEVENTF_KEYUP;

        ip [3] .ki.wVk = 0x56;

        ip [3] .ki.time = 0;

        ip [3] .ki.dwExtraInfo = 0;



        SendInput(1,ip,sizeof(INPUT));

I'm trying to simulate a ctrl+v execution.
But it doesn't work and I am not quite sure where to go from here.

Also I do wonder if  SendInput(1, ip, sizeof(INPUT));
the number "1" is the count of how the size of the array of the structs? (so it should be 4?. However it don't work no matter what I try and some clarification would be thankful!


INPUT ip[3];
        ip[0].type = INPUT_KEYBOARD;
        ip[0].ki.wScan = 0;
        ip[0].ki.dwFlags = 0;
        ip[0].ki.wVk = VK_CONTROL;
        ip[0].ki.time = 0;
        ip[0].ki.dwExtraInfo = 0;

        ip[1].type = INPUT_KEYBOARD;
        ip[1].ki.wScan = 0;
        ip[1].ki.dwFlags = 0;
        ip[1].ki.wVk = 0x56;
        ip[1].ki.time = 0;
        ip[1].ki.dwExtraInfo = 0;

        ip[2].type = INPUT_KEYBOARD;
        ip[2].ki.wScan = 0;
        ip[2].ki.dwFlags = KEYEVENTF_KEYUP;
        ip[2].ki.wVk = VK_CONTROL;
        ip[2].ki.time = 0;
        ip[2].ki.dwExtraInfo = 0;

        ip[3].type = INPUT_KEYBOARD;
        ip[3].ki.wScan = 0;
        ip[3].ki.dwFlags = KEYEVENTF_KEYUP;
        ip[3].ki.wVk = 0x56;
        ip[3].ki.time = 0;
        ip[3].ki.dwExtraInfo = 0;

        SendInput(1, ip, sizeof(INPUT));

推荐答案

我正在尝试模拟ctrl + v执行。

但它不起作用,我不太清楚从哪里开始。

I'm trying to simulate a ctrl+v execution.
But it doesn't work and I am not quite sure where to go from here.


第一步是仔细阅读  发送输入功能 文件。

The first step is to carefully read the SendInput function  documentation.

我也不知道是否  SendInput(1,ip,sizeof(INPUT));

数字"1"是结构数组大小的计数? (所以它应该是4?。
Also I do wonder if  SendInput(1, ip, sizeof(INPUT));
the number "1" is the count of how the size of the array of the structs? (so it should be 4?.

同样,文档提供了答案。 它说第一个参数应该是"
pInputs 数组中的结构数。 所以在您的代码中,数组中有多少个结构?1或4? 


Again, the documentation provides the answer.  It says that the first parameter should be "The number of structures in the pInputs array."  So in your code, how many structures are in the array? 1 or 4? 

INPUT ip [3];
INPUT ip[3];


尽管你质疑结构的数量在数组中是1或4,看看你实际为数组声明了多少。 都不是1或4.

And although you question whether the number of structures in the array is 1 or 4, look how many you actually declared for the array.  Neither 1 or 4.



     ip [3] .type = INPUT_KEYBOARD;

     ip [3] .ki.wScan = 0;

     ip [3] .ki.dwFlags = KEYEVENTF_KEYUP;

     ip [3] .ki.wVk = 0x56;

     ip [3] .ki.time = 0;

     ip [3] .ki.dwExtraInfo = 0;


        ip[3].type = INPUT_KEYBOARD;
        ip[3].ki.wScan = 0;
        ip[3].ki.dwFlags = KEYEVENTF_KEYUP;
        ip[3].ki.wVk = 0x56;
        ip[3].ki.time = 0;
        ip[3].ki.dwExtraInfo = 0;


现在代码使用s数组索引,引用数组中不存在的成员。



And now the code uses array index that references a non-existent member of the array.



这篇关于使用INPUT数组的Windows.h c ++ CTRL + V模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆