Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27513

VS 2012 SendKeys Issue - When shift is pressed it causes "/" to be "? and break functionality

$
0
0
Hello this is my first post, I have created a few applications over the years, <URL removed by moderator... No advertisement allowed!>


I am having 1 perticular issue with my application "SACNR Keybinder Evolution"

In this section here
Code:

Sub macro(ByVal param_obj() As Object)
        Try
            Dim substr As String = param_obj(1)
            Dim pressed As String = param_obj(0)
            If substr.Contains(txtToggleChar.Text) Then
                If Not CMDNumber.ContainsKey(pressed) Then CMDNumber(pressed) = 1
                Dim splitstring() As String = Split(substr, txtToggleChar.Text)
                Dim x As Integer = 0
                For Each item In splitstring
                    x = x + 1
                    If x >= CMDNumber(pressed) Then
                        SendKeys.Send(SendT() + item + SendEnter())
                        CMDNumber(pressed) = CMDNumber(pressed) + 1
                        If splitstring.GetLength(0) = x Then CMDNumber(pressed) = 1
                        Exit Sub
                    End If
                Next
            Else
                substr = substr.Replace(txtDelayChar.Text, txtMacroChar.Text + txtDelayChar.Text)
                Dim splitstring() As String = Split(substr, txtMacroChar.Text)
                For Each item In splitstring
                    If item.Length > 4 Then
                        If item(0) = txtDelayChar.Text And IsNumeric(item.Substring(1, 4)) = True Then
                            Thread.Sleep(item.Substring(1, 4))
                            item = item.Remove(0, 5)
                        End If
                    End If
                    SendKeys.SendWait(SendT() + item + SendEnter())
                Next
            End If
            keybinderdisabled = False
        Catch ex As Exception
            MsgBox("String contains invalid character!")
        End Try
    End Sub


Specifically this bit

Code:

For Each item In splitstring
                    x = x + 1
                    If x >= CMDNumber(pressed) Then
                        SendKeys.Send(SendT() + item + SendEnter())
                        CMDNumber(pressed) = CMDNumber(pressed) + 1
                        If splitstring.GetLength(0) = x Then CMDNumber(pressed) = 1
                        Exit Sub
                    End If
                Next

This all runs in a background thread, So if some one presses SHIFT while this is running it screws it up, For example if i put "testing 1 2 3 54 646" in the first keybind textbox, It should sendkeys "t/testing 1 2 3 54 646{ENTER}" but if shift is pressed during this at any point it will send this "t?testing ! " £ $% ^&*" which causes my SAMP command to screw up and instead posts in main chat the message instead of sending it as a command due to / being turned in to a ?.

So on to my question, can any 1 suggest a way to fix this issue?

Thanks.
(the 2 functions sendt and sendenter are uninmportant they just check if checkbox is checked if so return t or ENTER else return blank)

Viewing all articles
Browse latest Browse all 27513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>