當前位置:編程學習大全網 - 編程軟體 - 高分求寫壹個簡單的按鍵程序

高分求寫壹個簡單的按鍵程序

這種程序壹般不讓貼。

給妳壹部分。

頭文件:

#include <Windows.h>

#include <Winuser.h>

#include <stdio.h>

#include <stdlib.h>

#include <memory.h>

#include <string.h>

#include <time.h>

時間等待函數:

void wait ( int m_seconds )

{ clock_t endwait;

endwait = clock () + m_seconds ;

while (clock() < endwait) {}

}

調用參數單位是毫秒。

毫秒數用隨機數:

double r;

srand((unsigned)time(NULL)); // 種子

r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );

r = r * 2000.0; // 0-2000 毫秒

按鍵:

例如按cmd和回車

keybd_event(VkKeyScan('C'),1,0,0); keybd_event(VkKeyScan('C'),1,KEYEVENTF_KEYUP,0);

keybd_event(VkKeyScan('M'),1,0,0); keybd_event(VkKeyScan('M'),1,KEYEVENTF_KEYUP,0);

keybd_event(VkKeyScan('D'),1,0,0); keybd_event(VkKeyScan('D'),1,KEYEVENTF_KEYUP,0);

keybd_event(VK_RETURN,1,0,0);

keybd_event(VK_RETURN,1,KEYEVENTF_KEYUP,0);

------

運氣好妳看到上面的語句。

  • 上一篇:SAS兩項分組 進行方差分析的程序怎麽寫?
  • 下一篇:乒乓球發球機哪個牌子的好?
  • copyright 2024編程學習大全網