为何不能模拟按键? ( 积分: 30 )

  • 主题发起人 主题发起人 sy0116
  • 开始时间 开始时间
S

sy0116

Unregistered / Unconfirmed
GUEST, unregistred user!
我想用一下代码模拟按下ALT+S组合键,不过没有作用,在用QQ测试时发现并没有成功模拟按下ALT+S组合键,倒是把字母&quot;S&quot;输入到对话框中去了<br>keybd_event(MOD_ALT, MapVirtualKey(MOD_ALT, 0), 0, 0);<br>keybd_event(Ord('S'), MapVirtualKey(Ord('S'), 0), 0, 0);<br>keybd_event(Ord('S'), MapVirtualKey(Ord('S'), 0), KEYEVENTF_KEYUP, 0);<br>keybd_event(MOD_ALT, MapVirtualKey(MOD_ALT, 0), KEYEVENTF_KEYUP, 0);<br>不过,用以下却可以模拟Ctrl+Enter组合键,这是为何?<br>keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0);<br>keybd_event(Ord('V'), MapVirtualKey(Ord('V'), 0), 0, 0);<br>keybd_event(Ord('V'), MapVirtualKey(Ord('V'), 0), KEYEVENTF_KEYUP, 0);<br>keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0);
 
我想用一下代码模拟按下ALT+S组合键,不过没有作用,在用QQ测试时发现并没有成功模拟按下ALT+S组合键,倒是把字母&quot;S&quot;输入到对话框中去了<br>keybd_event(MOD_ALT, MapVirtualKey(MOD_ALT, 0), 0, 0);<br>keybd_event(Ord('S'), MapVirtualKey(Ord('S'), 0), 0, 0);<br>keybd_event(Ord('S'), MapVirtualKey(Ord('S'), 0), KEYEVENTF_KEYUP, 0);<br>keybd_event(MOD_ALT, MapVirtualKey(MOD_ALT, 0), KEYEVENTF_KEYUP, 0);<br>不过,用以下却可以模拟Ctrl+Enter组合键,这是为何?<br>keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0);<br>keybd_event(Ord('V'), MapVirtualKey(Ord('V'), 0), 0, 0);<br>keybd_event(Ord('V'), MapVirtualKey(Ord('V'), 0), KEYEVENTF_KEYUP, 0);<br>keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0);
 
keybd_event(VK_MENU, 0, 0, 0);<br>keybd_event(Ord('S'), 0, 0, 0);<br>keybd_event(Ord('S'), 0, KEYEVENTF_KEYUP, 0);<br>keybd_event(VK_MENU,0, KEYEVENTF_KEYUP, 0);<br>应该就行了<br>
 
同意楼上 &nbsp;但为啥ALT在VK里是VK_MENU啊
 
大概微软觉着ALT键总是用来调出菜单吧^_^
 
接受答案了.
 

Similar threads

I
回复
0
查看
774
import
I
I
回复
0
查看
578
import
I
I
回复
0
查看
635
import
I
后退
顶部