乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      C 模擬鼠標(biāo)點(diǎn)擊和鍵盤輸入的操作 mouse

       覓書時(shí)代 2021-04-11

      實(shí)際運(yùn)用,視頻講解

      python和C++實(shí)現(xiàn)模擬鍵鼠操作實(shí)測說明【300英雄】

      視頻傳送門:點(diǎn)我

      相關(guān)環(huán)境

      操作系統(tǒng):Win10 企業(yè)版
      編譯環(huán)境:MinGW

      相關(guān)說明

      參考資料:windows API,里面很詳細(xì),愛死了
      使用的Windows API中的 mouse_event()keybd_event()。

      mouse_event

      private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
      在這里插入圖片描述
      簡單寫個(gè)實(shí)例,參考 mouse_event() 控制鼠標(biāo)操作

      #include <Windows.h> 1、這里是鼠標(biāo)左鍵按下和松開兩個(gè)事件的組合即一次單擊: mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ) 2、模擬鼠標(biāo)右鍵單擊事件: mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 ) 3、兩次連續(xù)的鼠標(biāo)左鍵單擊事件 構(gòu)成一次鼠標(biāo)雙擊事件: mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ) mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ) 4、使用絕對(duì)坐標(biāo) mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 500, 500, 0, 0 ) 需要說明的是,如果沒有使用MOUSEEVENTF_ABSOLUTE,函數(shù)默認(rèn)的是相對(duì)于鼠標(biāo)當(dāng)前位置的點(diǎn),如果dx,和dy,用0,0表示,這函數(shù)認(rèn)為是當(dāng)前鼠標(biāo)所在的點(diǎn)。 5、直接設(shè)定絕對(duì)坐標(biāo)并單擊 mouse_event(MOUSEEVENTF_LEFTDOWN, X * 65536 / 屏幕寬, Y * 65536 / 屏幕高, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, X * 65536 / 屏幕寬, Y * 65536 / 屏幕高, 0, 0); 其中X,Y分別是你要點(diǎn)擊的點(diǎn)的橫坐標(biāo)和縱坐標(biāo) ps:求屏幕大小,參考 https://blog.csdn.net/yp18792574062/article/details/88351342 #include <Windows.h> // 帶標(biāo)題欄和菜單欄 int width = GetSystemMetrics(SM_CXSCREEN); int height = GetSystemMetrics(SM_CYSCREEN);
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29

      keybd_event

      VOID keybd_event(BYTE bVk,BYTE bScan,DWORD dwFlags,DWORD dwExtralnfo);
      
      • 1
      • 1

      在這里插入圖片描述
      下圖轉(zhuǎn)自:keybd_event模擬鍵盤輸入
      在這里插入圖片描述
      簡單實(shí)例

      #include <Windows.h> keybd_event(16,0,0,0);//按下Shift鍵 keybd_event('A',0,0,0);//按下a鍵 keybd_event('A',0,KEYEVENTF_KEYUP,0);//松開a鍵 keybd_event(16,0,KEYEVENTF_KEYUP,0);//松開Shift鍵
      • 1
      • 2
      • 3
      • 4
      • 5
      • 1
      • 2
      • 3
      • 4
      • 5

      實(shí)際案例

      實(shí)現(xiàn)效果:來回走動(dòng),并按 'q’鍵。ps:管理員運(yùn)行
      main.cpp

      // 編譯 g++ main.cpp,管理員運(yùn)行 a.exe
      #include <Windows.h>
      #include <iostream>
      using namespace std;
      
      int main() 
      {
      // 獲取帶標(biāo)題欄和菜單欄即全屏像素大小
      int width = GetSystemMetrics(SM_CXSCREEN);
      int height = GetSystemMetrics(SM_CYSCREEN);
      // 睡眠5s,準(zhǔn)備時(shí)間
      Sleep(5000);
      // 死循環(huán)
      while (1) 
      {
      // 移動(dòng)到絕對(duì)位置右擊
      mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_MOVE, 1170 * 65535 / width, 362 * 65535 / height, 0, 0 );
      Sleep(3500);
      
      // 按下'q'鍵
      keybd_event(81, 0, 0, 0);
      keybd_event(81, 0, KEYEVENTF_KEYUP, 0);
      Sleep(500);
      
      // 移動(dòng)到絕對(duì)位置右擊
      mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTDOWN  | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_MOVE, 679 * 65535 / width, 760 * 65535 / height, 0, 0 );
      Sleep(3500);
      
      }
      
      //system('pasue');
      return 0;
      }
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33

      獲取鼠標(biāo)當(dāng)前位置

      #include <Windows.h> #include <iostream> using namespace std; int main() { // 死循環(huán) while (1) { POINT pt = {0,0}; GetCursorPos(&pt); printf('x=%d,y=%d\n', pt.x,pt.y); Sleep(3000); } //system('pause'); return 0; }
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多