S.l.e!ep.¢%

像打了激速一样,以四倍的速度运转,开心的工作
简单、开放、平等的公司文化;尊重个性、自由与个人价值;
posts - 1098, comments - 335, trackbacks - 0, articles - 1
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

SendInput 摸拟键盘

Posted on 2010-01-13 23:14 S.l.e!ep.¢% 阅读(1036) 评论(0)  编辑 收藏 引用 所属分类: RootKit
				
						
								void
						
						
								envoiChaine
						(char* sText)
{bool bShift, bControl, bAlt;
    unsignedint nPos, nCpt;
    char cChar;
    short nKeyScan;
    INPUT input[256];
    for (nPos=0;nPos<=strlen(sText)-1;nPos++)
    {ZeroMemory(input, sizeof input);
        nCpt =0;
        cChar = sText[nPos];
        nKeyScan =VkKeyScan(cChar);
        bShift = (HIBYTE(nKeyScan) &1?1:0);
        bControl = (HIBYTE(nKeyScan) &2?1:0);
        bAlt = (HIBYTE(nKeyScan) &4?1:0);
        if (bShift)
        {
            input[nCpt].type = INPUT_KEYBOARD;
            input[nCpt].ki.wVk = VK_SHIFT;
            input[nCpt].ki.wScan =MapVirtualKey(VK_SHIFT, 0);
            nCpt++;
        }if (bControl)
        {
            input[nCpt].type = INPUT_KEYBOARD;
            input[nCpt].ki.wVk = VK_CONTROL;
            input[nCpt].ki.wScan =MapVirtualKey(VK_CONTROL, 0);
            nCpt++;
        }if (bAlt)
        {
            input[nCpt].type = INPUT_KEYBOARD;
            input[nCpt].ki.wVk = VK_MENU;
            input[nCpt].ki.wScan =MapVirtualKey(VK_MENU, 0);
            nCpt++;
        }
        input[nCpt].type = INPUT_KEYBOARD;
        input[nCpt].ki.wVk =LOBYTE(nKeyScan);
        input[nCpt].ki.wScan =MapVirtualKey(LOBYTE(nKeyScan), 0);
        nCpt++;
        input[nCpt].type = INPUT_KEYBOARD;
        input[nCpt].ki.wVk =LOBYTE(nKeyScan);
        input[nCpt].ki.wScan =MapVirtualKey(LOBYTE(nKeyScan), 0);
        input[nCpt].ki.dwFlags = KEYEVENTF_KEYUP;
        nCpt++;
        if (bShift)
        {
            input[nCpt].type = INPUT_KEYBOARD;
            input[nCpt].ki.wVk = VK_SHIFT;
            input[nCpt].ki.wScan =MapVirtualKey(VK_SHIFT, 0);
            input[nCpt].ki.dwFlags = KEYEVENTF_KEYUP;
            nCpt++;
        }if (bControl)
        {
            input[nCpt].type = INPUT_KEYBOARD;
            input[nCpt].ki.wVk = VK_CONTROL;
            input[nCpt].ki.wScan =MapVirtualKey(VK_CONTROL, 0);
            input[nCpt].ki.dwFlags = KEYEVENTF_KEYUP;
            nCpt++;
        }if (bAlt)
        {
            input[nCpt].type = INPUT_KEYBOARD;
            input[nCpt].ki.wVk = VK_MENU;
            input[nCpt].ki.wScan =MapVirtualKey(VK_MENU, 0);
            input[nCpt].ki.dwFlags = KEYEVENTF_KEYUP;
            nCpt++;
        }SendInput(nCpt, input, sizeof INPUT);
    }}
		

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理