不是指用mouse_down事件的方法。而是要求用VB自动按ctrl键同时按下鼠标左键,从而控制后台程序。
如下我用了四个方案,但都没有成功,请大虾们指导:
'mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'SendKeys 17 'vbKeyConterol '17 Ctrl 键
' mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
' mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
'SendKeys 17 'vbKeyConterol '17 Ctrl 键
'mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
GetCursorPos tPoint1 '获得当前鼠标位置
hWin = WindowFromPoint(tPoint1.X, tPoint1.Y) '获得窗口名柄
SendKeys "{^}"
PostMessage hWin, WM_KEYDOWN, &H17, &H10001 ' 模拟按下 VK_Ctrl 键
''keybd_event VK_Ctrl, 0, 0, 0 '按下Ctrl键
' keybd_event VK_C, 0, 0, 0 '按下C键
' Delay 600 '延迟 毫秒。'
'PostMessage hWin, MOUSEEVENTF_RIGHTDOWN, 0, &H10001 ' 模拟按下 VK_Ctrl 键
SendKeys "{^}"
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
'SendKeys 17 'vbKeyConterol '17 Ctrl 键
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
' PostMessage hWin, MOUSEEVENTF_RIGHTUP, 0, &HC0010001 ' 模拟抬起 VK_Ctrl 键 VK_Ctrl=&H17
' keybd_event VK_C, 0, KEYEVENTF_KEYUP, 0 '释放C键
' keybd_event VK_Ctrl, 0, KEYEVENTF_KEYUP, 0 '释放Ctrl键
SendKeys "{^}"
PostMessage hWin, WM_KEYUP, &H17, &HC0010001 ' 模拟抬起 VK_Ctrl 键 VK_Ctrl=&H17
SendMessage等方案均已试用过,均未果。可能是键盘CTRL加鼠标的方式还有其它不同?
请大虾们劳神试验一样,再将VB源码贴出来,大家都会感激您。
如何用VB实现模拟按ctrl键同时按下鼠标左键,从而控制后台程序?
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Dim anctlejiang As Long '这句写到通...
vb 如何模拟按住ctrl+点击鼠标左键。
Button = 1’button是一个判断鼠标的按键,为1是左键,2是右键 And Shift = 1 End Sub
VB 如何实现按Ctrl+鼠标左键多选,求详细代码
很简单:dim str1 as string ‘定义一个字符串变量str1 Private Sub Command1_Click() '通过单击事件选中text1的全部内容 text1.selstar=0 text1.sellength=len(text1)str1=text1.seltext End Sub
用vb编写ctrl+shift+z按键脚本。按下F1执行一次组合按键
把下面代码复制到模块中,调用:Hook Form1.hwnd,取消:Unhook Option Explicit Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)Private Const KEYEVENTF_EXTENDEDKEY = &H1 Private Const KEYEVENTF_...
vb,如何控制键盘上的ctrl+c组合健和ctrl+v组合健,VB代码如何编写
If Clipboard.GetFormat(vbCFText) Then keybd_event VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0 '起动ctrl keybd_event Asc("V"), MapVirtualKey(Asc("V"), 0), 0, 0 '模拟按下"V"键,此处为ascll码 keybd_event Asc("V"), MapVirtualKey(Asc("V"), 0), KEYEVENTF_KEYUP, 0 '撤消...
VB中如何实现按下键盘上Ctrl+alt+end重启或注销或关机
Sub Command1_Click()Shell "shutdown -s -t 60"End Sub Private Sub Command2_Click()Shell "shutdown -a"End Sub Private Sub Form_Load()Command1.Caption = "一分钟关机"Command2.Caption = "取消"End Sub 只写了倒计机关机和取消倒计时,其他功能按照上面的参数表自己修改一下就行了 ...
VB中如何实现在另外的窗口中点击或者按下快捷键的问题
If S = "你要查找的窗口标题" Then '开始模拟按crtl+s键 SetForegroundWindow lngHand Sleep 200 SendMessage MainWnd, WM_SETFOCUS, 0&, 0& keybd_event vbKeyControl, 0, KEYEVENTF_EXTENDEDKEY, 0 keybd_event vbKeyS, 0, KEYEVENTF_EXTENDEDKEY, 0 Sleep 100 keybd_event vbKeyControl, 0...
用VB编写程序,按下快捷键时执行操作
) '此处为快捷名称 oMyShortcut.IconLocation = "" '此处为快捷图标 oMyShortcut.TargetPath = "%windir%\\system32\\cmd.exe" '此处为源文件 oMyShortcut.Hotkey = "ALT+CTRL+C" ''此处为快捷热键 oMyShortcut.Save '‘如果要删除此快捷方式,只需将里面的各选项设为空,再次执行该源码就好 ...
vb中按下ctrl键和松开ctrl的命令怎么写
在事件KeyDown和KeyUp中有个Shift。要判断Ctrl键是否按下,使用该常数。该参数用作位屏蔽。它可被用来测试任何键组合。CtrlDown = (Shift And VbCtrlMask) > 0 ShiftDown = (Shift And vbShiftMask) > 0 AltDown = (Shift And VbAltMask) > 0 用命令按下和松开Ctrl键:使用API函数keybd_...
如何利用VB实现按下鼠标中键等于同时按下键盘上CTRL和R键?
msgbox "你按下了r+Shift键"End If End Sub VB keypress事件中键盘上每个键的KeyAscii值分别是什么?悬赏分:0 - 解决时间:2008-7-10 16:01 提问者: paul_xy - 试用期 一级 最佳答案 键码 常数 值 描述 vbKeyLButton 1 鼠标左键 vbKeyRButton 2 鼠标右键 vbKeyCancel 3 CANCEL 键 vb...