Ana sayfa HEPSİ Klavyeyi Kullanarak Sendkeys Yapmak

Klavyeyi Kullanarak Sendkeys Yapmak[VB.NET]

63
0

Vb.Net içerisinde belli başlı komutlar olmasına rağmen bir çok komut .net tabanda sağlıklı çalışmayabiliyor . Tabi bir çok komuttan kastımız , Sendkeys ile alakalı yani tuşa basma olayları konusunda bir nebze yetersizdir . Piyasada bulunan bir çok macro recorder bile belirlenen kayıtları yaparken basmama ihtimalleri kaçırma ihtimalleri vardır .
Örneğin Shift +A kombinasyonu yapmak istediğinizde Shift Butonunu kaçırıp sadece A ya basabilir ve büyük küçük yazma problemleri ortaya çıkartabilir . Zaten sorun bu kadar küçük değil hiç yazmadığı bile olabilir . Şimdi size anlatacağım yöntem ile doğrudan kullandığınız klavye bileşenlerini kullanarak sendkeys işlemi yapacağız ve tuşları kaçırma olaylarını yok edeceğiz . Öncelikle sendkeys in mantığını ve alternatifini anlatalım

Sendkeys Komutu Ne İşe Yarar ?

Sendkeys komutu belirli kombinasyon yada tuşlamayı yapar .
Sendkeys.Send(“Merhaba Ben Webdeyazilim”) ‘ Örnek kodumuz bize tırnak içindeki sonucu yazacaktır .

Sendkeys Komutu Alternatifi Nedir ?
Sendkeys komutunu direk olarak kullanmadan klavye bileşenleri ile yazalım öncelikle bir kaç module ihtiyacımız var bunlar microsoft’un paylaştığı ücretsiz projeler arasında bulunmaktadır .

Bu proje içerisinden sadece UserInteraction klasörünü kopyalamanız yeterli Create a soft keyboard (VBSoftKeyboard)
isimli projeyi indirelim.

Sendkeys Alterntif için gerekli olan dosyalar Resim : 1.0.0
Sendkeys Alterntif için gerekli olan dosyalar Resim : 1.0.0

Yazdığım Fonksiyon sayesinde IputKeys(“Webdeyazilim”) yaparak , sendkey alternatifini kullanabiliriz . Eklemek istediğiniz komutları Keys yazıp nokta koyarak görebilirsiniz .

'UserInteraction.KeyboardInput.SendToggledKey : Tuşu serbest Bırakmak
'UserInteraction.KeyboardInput.Sendkeys :  Tuşa basmak
     Public Sub InputKeys(ByVal Words As String)
        Dim SingleWord As String
        Dim SingleInt As Integer
        For i = 0 To Words.Length - 1
            Thread.Sleep(keyboardspeed.Value)
            SingleWord = Words.Chars(i)
            SingleInt = Asc(SingleWord)
            UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)

            Select Case SingleWord
                Case ","
                    UserInteraction.KeyboardInput.SendKey(Keys.Oemcomma)
                Case "."
                    UserInteraction.KeyboardInput.SendKey(Keys.OemPeriod)
                Case " "
                    UserInteraction.KeyboardInput.SendKey(Keys.Space)
                Case "a"
                    UserInteraction.KeyboardInput.SendKey(Keys.A)
                Case "b"
                    UserInteraction.KeyboardInput.SendKey(Keys.B)
                Case "c"
                    UserInteraction.KeyboardInput.SendKey(Keys.C)
                Case "ç"
                    UserInteraction.KeyboardInput.SendKey(Keys.Oem5)
                Case "d"
                    UserInteraction.KeyboardInput.SendKey(Keys.D)
                Case "e"
                    UserInteraction.KeyboardInput.SendKey(Keys.E)
                Case "f"
                    UserInteraction.KeyboardInput.SendKey(Keys.F)
                Case "h"
                    UserInteraction.KeyboardInput.SendKey(Keys.H)
                Case "g"
                    UserInteraction.KeyboardInput.SendKey(Keys.G)
                Case "ğ"
                    UserInteraction.KeyboardInput.SendKey(Keys.G)
                Case "i"
                    UserInteraction.KeyboardInput.SendKey((Keys.Oem7))
                Case "ı"
                    UserInteraction.KeyboardInput.SendKey((Keys.I))
                Case "j"
                    UserInteraction.KeyboardInput.SendKey(Keys.J)
                Case "k"
                    UserInteraction.KeyboardInput.SendKey(Keys.K)
                Case "l"
                    UserInteraction.KeyboardInput.SendKey(Keys.L)
                Case "m"
                    UserInteraction.KeyboardInput.SendKey(Keys.M)
                Case "n"
                    UserInteraction.KeyboardInput.SendKey(Keys.N)
                Case "o"
                    UserInteraction.KeyboardInput.SendKey(Keys.O)
                Case "ö"
                    UserInteraction.KeyboardInput.SendKey(Keys.Oem4)
                Case "p"
                    UserInteraction.KeyboardInput.SendKey(Keys.P)
                Case "q"
                    UserInteraction.KeyboardInput.SendKey(Keys.Q)
                Case "r"
                    UserInteraction.KeyboardInput.SendKey(Keys.R)
                Case "s"
                    UserInteraction.KeyboardInput.SendKey(Keys.S)
                Case "ş" ' ALT + 0254
                    UserInteraction.KeyboardInput.SendKey(Keys.Oem1)
                Case "t"
                    UserInteraction.KeyboardInput.SendKey(Keys.T)
                Case "u"
                    UserInteraction.KeyboardInput.SendKey(Keys.U)
                Case "ü"
                    UserInteraction.KeyboardInput.SendKey(Keys.Oem6)
                Case "v"
                    UserInteraction.KeyboardInput.SendKey(Keys.V)
                Case "w"
                    UserInteraction.KeyboardInput.SendKey(Keys.W)
                Case "x"
                    UserInteraction.KeyboardInput.SendKey(Keys.X)
                Case "y"
                    UserInteraction.KeyboardInput.SendKey(Keys.Y)
                Case "z"
                    UserInteraction.KeyboardInput.SendKey(Keys.Z)
                    'CAPSLOCK
                Case "A"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.A))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "B"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.B))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "C"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.C))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "Ç"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey(Keys.Oem5)
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "D"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.D))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "E"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.E))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "F"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.F))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "H"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.H))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "G"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.G))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "Ğ"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.Oem4))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "I"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.I))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "İ"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.Oem7))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "J"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.J))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "K"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.K))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "L"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.L))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "M"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.M))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "N"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.N))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "O"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.O))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "Ö"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey(Keys.Oem4)
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "P"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.P))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "Q"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.Q))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "R"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.R))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "S"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.S))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "Ş"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.Oem1))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "T"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.T))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "U"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.U))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "Ü"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey(Keys.Oem6)
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "V"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey(Keys.V)
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "W"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.W))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "X"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.X))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "Y"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.Y))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                Case "Z"
                    UserInteraction.KeyboardInput.SendKey(Keys.RShiftKey)
                    UserInteraction.KeyboardInput.SendKey((Keys.Z))
                    UserInteraction.KeyboardInput.SendToggledKey(Keys.RShiftKey)
                        'CAPSLOCK
                Case "0"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad0)
                Case "1"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad1)
                Case "2"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad2)
                Case "3"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad3)
                Case "4"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad4)
                Case "5"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad5)
                Case "6"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad6)
                Case "7"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad7)
                Case "8"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad8)
                Case "9"
                    UserInteraction.KeyboardInput.SendKey(Keys.NumPad9)

            End Select
        Next
    End Sub

BİR CEVAP BIRAK

Lütfen bir yorum yazın!
Lütfen Adınızı Girin!