Question

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

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
Was it helpful?

Solution

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)

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top