vb.net上的键重叠[外部程序上的宏项目] [英] Keys overlapping on vb.net [a macro project on external program]

查看:82
本文介绍了vb.net上的键重叠[外部程序上的宏项目]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个使用F1〜F12的VB宏,并使用shift + F1〜F12和ctrl + F1〜F12, 必须在外部程序(例如浏览器)中运行的程序, 问题来了,Shift + F1〜F12部分重叠, 它不起作用(在Firefox上),与Firefox的HotKey/ShortCut重叠, (因为它最终变成Shift + F1 + ctrl + v) 有解决这个问题的主意吗? :( 我正在使用Visual Studio 2013.

I'm making a VB Macro that uses F1~F12, and shift + F1~F12, and ctrl + F1~F12, which must be working in an external program, such as browsers, here comes the problem, the Shift + F1~F12 part are overlapping, it's not working (on firefox), it overlaps with the HotKey/ShortCut of firefox, (because it ended up as Shift+F1+ctrl+v) any idea to fix this? :( I'm using visual studio 2013.

Public Const MOD_CONTRO As Integer = &H2
Public Const MOD_SHIFT As Integer = &H4
Public Const WM_HOTKEY As Integer = &H312

受保护的替代子WndProc(由System.Windows.Forms.Message引用ByRef m)

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

 If m.Msg = WM_HOTKEY Then
        Dim id As IntPtr = m.WParam
        Select Case (id.ToString)

            Case "101"
             Clipboard.SetText(System.IO.File.ReadAllText(Application.StartupPath & "\SF1.txt"))
             SendKeys.Send("^" & "v")
            '^This is the problem part, 

 End Select

    End If

    MyBase.WndProc(m)
End Sub

 Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As      

 System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

    UnregisterHotKey(Me.Handle, 101)
End Sub

Private Sub Home_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    RegisterHotKey(Me.Handle, 101, &H4, Keys.F1)
End Sub

推荐答案

这样做可以解决问题, 作为我从这里从Joiner中学到的代码的一部分! 按下并自动向上移动?(避免长时间按下按住)

Doing this fixed the problem, as part of codes I learned from Joiner from here! shift pressed, and automatically up?(to avoid long press and hold)

私有声明子keybd_event库"user32"(ByVal bVk作为字节,ByVal bScan作为字节,ByVal dwFlags作为整数,ByVal dwExtraInfo作为整数)

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)

案例"101" Clipboard.SetText(System.IO.File.ReadAllText(Application.StartupPath&"\ SF1.txt")) keybd_event(& H10,0,& H2,0) SendKeys.SendWait("^"&"v")

Case "101" Clipboard.SetText(System.IO.File.ReadAllText(Application.StartupPath & "\SF1.txt")) keybd_event(&H10, 0, &H2, 0) SendKeys.SendWait("^" & "v")

这篇关于vb.net上的键重叠[外部程序上的宏项目]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆