久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <legend id='WEFwS'><style id='WEFwS'><dir id='WEFwS'><q id='WEFwS'></q></dir></style></legend>

    <small id='WEFwS'></small><noframes id='WEFwS'>

      • <bdo id='WEFwS'></bdo><ul id='WEFwS'></ul>

      <tfoot id='WEFwS'></tfoot>
      <i id='WEFwS'><tr id='WEFwS'><dt id='WEFwS'><q id='WEFwS'><span id='WEFwS'><b id='WEFwS'><form id='WEFwS'><ins id='WEFwS'></ins><ul id='WEFwS'></ul><sub id='WEFwS'></sub></form><legend id='WEFwS'></legend><bdo id='WEFwS'><pre id='WEFwS'><center id='WEFwS'></center></pre></bdo></b><th id='WEFwS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WEFwS'><tfoot id='WEFwS'></tfoot><dl id='WEFwS'><fieldset id='WEFwS'></fieldset></dl></div>

      使用 SendInput 發送兩個或更多字符

      Sending Two or more chars using SendInput(使用 SendInput 發送兩個或更多字符)

          <bdo id='homKl'></bdo><ul id='homKl'></ul>
            <tbody id='homKl'></tbody>
              <legend id='homKl'><style id='homKl'><dir id='homKl'><q id='homKl'></q></dir></style></legend>

              <i id='homKl'><tr id='homKl'><dt id='homKl'><q id='homKl'><span id='homKl'><b id='homKl'><form id='homKl'><ins id='homKl'></ins><ul id='homKl'></ul><sub id='homKl'></sub></form><legend id='homKl'></legend><bdo id='homKl'><pre id='homKl'><center id='homKl'></center></pre></bdo></b><th id='homKl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='homKl'><tfoot id='homKl'></tfoot><dl id='homKl'><fieldset id='homKl'></fieldset></dl></div>

              1. <small id='homKl'></small><noframes id='homKl'>

              2. <tfoot id='homKl'></tfoot>
                本文介紹了使用 SendInput 發送兩個或更多字符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                要發送字符,我們可以使用 SendInput.如何使用它發送多個字符?

                To send a char, we can use SendInput. How can I use it to send more than one char?

                我試過這個代碼,但它沒有發送任何東西:

                I tried this code but it does not send anything:

                INPUT in;
                in.type=INPUT_KEYBOARD;
                in.ki.wScan=0;
                in.ki.time=0;
                in.ki.dwExtraInfo=0;
                in.ki.wVk=0x53+0x54;
                
                SendInput(2,&in,sizeof(INPUT));
                

                那么,正確的方法是什么?

                So, what is the right way?

                推薦答案

                SendInput() 的第一個參數指定你傳入的 INPUT 結構的數量.你是僅傳入 1,但您告訴 SendInput() 您正在傳入 2.

                The first parameter of SendInput() specifies how many INPUT structures you are passing in. You are only passing in 1, but you are telling SendInput() that you are passing in 2.

                您不能在單個 INPUT 中指定兩個單獨的虛擬鍵.您需要聲明一個由多個 INPUT 組成的數組,每個虛擬鍵有 2 個 INPUT - 一個用于 keydown 事件,一個用于 keyup 事件.因此,在您的示例中,您實際上需要 4 個 INPUT 來發送 2 個虛擬鍵,如@user4581301 的回答所示.

                You cannot specify two separate virtual keys in a single INPUT. You need to declare an array of multiple INPUTs, 2 INPUTs for each virtual key - one for the keydown event, and one for the keyup event. So, in your example, you actually need 4 INPUTs to send 2 virtual keys, as shown in @user4581301's answer.

                現在,關于 KEYEVENTF_UNICODE,你不使用虛擬鍵,而是使用實際的 Unicode 代碼點,它們使用 UTF-16 代碼單元指定,每個 INPUT.所以這意味著如果你想發送一個需要 UTF-16 代理對的 Unicode 代碼點,你需要 2 組向下/向上 INPUT,一組用于高代理,一組用于低代理.該警告在 SendInput() 文檔中提及,但實際上 vScan 字段是 16 位 WORD,并且 KEYEVENTF_UNICODE 事件生成 WM_CHAR 消息,該消息將 UTF-16 代理代碼單元作為單獨的消息傳遞.

                Now, regarding KEYEVENTF_UNICODE, you don't use virtual keys with it, you use actual Unicode codepoints instead, where they are specified using UTF-16 codeunits, one per INPUT. So that means if you want to send a Unicode codepoint that requires a UTF-16 surrogate pair, you need 2 sets of down/up INPUTs, one set for the high surrogate, and one set for the low surrogate. That caveat is NOT mentioned in the SendInput() documentation, but it is implied by the fact that the vScan field is a 16bit WORD, and that KEYEVENTF_UNICODE events generate WM_CHAR messages, which passes UTF-16 surrogate codeunits as separate messages.

                因此,要使用 KEYEVENTF_UNICODE 發送一串 Unicode 字符,您可以執行以下操作:

                So, to send a string of Unicode characters using KEYEVENTF_UNICODE, you can do something like this:

                #include <vector>
                #include <string>
                
                void SendInputString(const std::wstring &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));
                }
                

                這篇關于使用 SendInput 發送兩個或更多字符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                In what ways do C++ exceptions slow down code when there are no exceptions thown?(當沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                When and how should I use exception handling?(我應該何時以及如何使用異常處理?)
                Scope of exception object in C++(C++中異常對象的范圍)
                Catching exceptions from a constructor#39;s initializer list(從構造函數的初始化列表中捕獲異常)
                Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區別)
              3. <tfoot id='ZD9yt'></tfoot>

                <small id='ZD9yt'></small><noframes id='ZD9yt'>

                        <tbody id='ZD9yt'></tbody>

                      <legend id='ZD9yt'><style id='ZD9yt'><dir id='ZD9yt'><q id='ZD9yt'></q></dir></style></legend>

                      • <bdo id='ZD9yt'></bdo><ul id='ZD9yt'></ul>

                          <i id='ZD9yt'><tr id='ZD9yt'><dt id='ZD9yt'><q id='ZD9yt'><span id='ZD9yt'><b id='ZD9yt'><form id='ZD9yt'><ins id='ZD9yt'></ins><ul id='ZD9yt'></ul><sub id='ZD9yt'></sub></form><legend id='ZD9yt'></legend><bdo id='ZD9yt'><pre id='ZD9yt'><center id='ZD9yt'></center></pre></bdo></b><th id='ZD9yt'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZD9yt'><tfoot id='ZD9yt'></tfoot><dl id='ZD9yt'><fieldset id='ZD9yt'></fieldset></dl></div>
                        • 主站蜘蛛池模板: 99热在线免费 | 青青草视频免费观看 | 久久亚洲欧美日韩精品专区 | 一区二区三区精品视频 | 午夜影院操| 视频在线一区二区 | av中文在线 | 瑟瑟视频在线看 | 亚州av | 国产精品综合网 | 91免费小视频 | 欧美日韩在线一区二区 | 一区二区三区国产精品 | 日韩精品一区二区三区中文字幕 | 亚洲精品一区在线观看 | www亚洲免费国内精品 | 日日骚网 | 欧美freesex黑人又粗又大 | 自拍 亚洲 欧美 老师 丝袜 | 四虎影| a在线免费观看视频 | 国产色 | 古装人性做爰av网站 | 亚洲视频免费一区 | 精品久久99 | www.青娱乐 | 免费观看一级特黄欧美大片 | 日韩欧美一级 | 99在线播放| 国产一区二区三区四区 | 黄色一级片aaa | 久久久99国产精品免费 | 成年免费大片黄在线观看一级 | 国产91在线播放精品91 | 美日韩中文字幕 | 欧美精品在线一区 | 91高清免费观看 | 日本在线小视频 | 国产成人精品一区二区三区在线观看 | 男女精品久久 | 中文视频在线 |