举例://模拟 alt + F
keybd_event(VK_MENU,0,KEYEVENTF_EXTENDEDKEY or 0,0);
keybd_event(70,0,KEYEVENTF_EXTENDEDKEY or 0,0);
keybd_event(70,0,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);
keybd_event(VK_MENU,0,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);

解决方案 »

  1.   

    he keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function. VOID keybd_event(    BYTE bVk, //按键代码,就象omkeydown里的
        BYTE bScan, // hardware scan code
        DWORD dwFlags, // flags specifying various function options
        DWORD dwExtraInfo  // additional data associated with keystroke
       );
     ParametersbVkSpecifies a virtual-key code. The code must be a value in the range 1 to 254. bScanSpecifies a hardware scan code for the key. dwFlagsA set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags: Value Meaning
    KEYEVENTF_EXTENDEDKEY If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).
    KEYEVENTF_KEYUP If specified, the key is being released. If not specified, the key is being depressed.
     dwExtraInfoSpecifies an additional 32-bit value associated with the key stroke.  Return ValuesThis function has no return value.
      

  2.   

    再一个举子:        //运行windows记事本
            winexec('notepad',1);        //把记事本窗口激活
            setforegroundwindow(findwindow(nil,'无标题-记事本'));        //模拟输入 'abc'
            keybd_event(65,0,KEYEVENTF_EXTENDEDKEY or 0,0);
            keybd_event(65,0,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);        keybd_event(66,0,KEYEVENTF_EXTENDEDKEY or 0,0);
            keybd_event(66,0,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);        keybd_event(67,0,KEYEVENTF_EXTENDEDKEY or 0,0);
            keybd_event(67,0,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);        //模拟 alt + F 打开文件菜单
            keybd_event(VK_MENU,0,KEYEVENTF_EXTENDEDKEY or 0,0);
            keybd_event(70,0,KEYEVENTF_EXTENDEDKEY or 0,0);
            keybd_event(70,0,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);
            keybd_event(VK_MENU,0,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);        //模拟输入 按 s  保存
            keybd_event(83,0,KEYEVENTF_EXTENDEDKEY or 0,0);
            keybd_event(83,0,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);
            //至于按键的 vkcode,你自己编个工具在form的 onkeydown里得到
      

  3.   

    只要按 alt + D 就可以把ie地址栏设成焦点了。首先模拟输入 alt + D 咯,然后再。。