Sendkeys.Send sending to many characters

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 3524 Views - Last Post: 20 March 2012 - 06:31 AM Rate Topic: -----

#1 TheNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-March 12

Sendkeys.Send sending to many characters

Posted 18 March 2012 - 11:04 AM

Hello everyone
This is my first post of your forum, and I'm very excited to see what there is to learn in here :-)

But first i have a problem with auto program for a java chat.
I want it to select the window by it self, and send the keys of a textbox, this is what i got so far:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Timer1.Interval = 7200000 Then
            GeckoWebBrowser1.BringToFront()
            GeckoWebBrowser1.Select()
            Windows.Forms.Cursor.Position = New System.Drawing.Point(GeckoWebBrowser1.Location.X + Me.Location.X + 150, GeckoWebBrowser1.Location.Y + Me.Location.Y + 175)
            mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
            SendKeys.Send(TextBox1.Text + "{ENTER}")
            System.Windows.Forms.SendKeys.Flush()
        End If
    End Sub



I hope someone can help me out :-) Tell me if i'm doing something wrong ! :)

Is This A Good Question/Topic? 0
  • +

Replies To: Sendkeys.Send sending to many characters

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Sendkeys.Send sending to many characters

Posted 18 March 2012 - 11:48 AM

Sendkeys is too fickle. Search codeplex for there virtual key project. Far better results.
Was This Post Helpful? 0
  • +
  • -

#3 MrTwEaK  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 18 March 2012 - 03:25 PM

Ok, well im assuming that you are getting to many characters because your using a Timer so try this instead.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Timer1.Interval = 7200000 Then
            GeckoWebBrowser1.BringToFront()
            GeckoWebBrowser1.Select()
            Windows.Forms.Cursor.Position = New System.Drawing.Point(GeckoWebBrowser1.Location.X + Me.Location.X + 150, GeckoWebBrowser1.Location.Y + Me.Location.Y + 175)
            mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
            SendKeys.Send(TextBox1.Text + "{ENTER}")
            System.Windows.Forms.SendKeys.Flush()
        End If
    End Sub

Pub


Was This Post Helpful? 0
  • +
  • -

#4 MrTwEaK  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 18 March 2012 - 03:31 PM

Ok, well im assuming that you are getting to many characters because your using a Timer so try this instead.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Timer1.Interval = 7200000 Then
           Timer1.Enable = False
           SendMsg(TextBox1.Text)
        End If
    End Sub

Public Sub SendMsg(ByVal Msg As String)
            GeckoWebBrowser1.BringToFront()
            GeckoWebBrowser1.Select()
            Windows.Forms.Cursor.Position = New System.Drawing.Point(GeckoWebBrowser1.Location.X +           Me.Location.X + 150, GeckoWebBrowser1.Location.Y + Me.Location.Y + 175)
            mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
            SendKeys.SendWait(Msg)
            SendKeys.SendWait("{ENTER}")
            System.Windows.Forms.SendKeys.Flush()
End Sub


Was This Post Helpful? 0
  • +
  • -

#5 TheNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 02:00 AM

Mr. Tweak:
So I've tried your code, but I still get the same error. It's randomly sending to many characters like this:
I should write "/goto 76"
It is writing "//////gggggooootttttooooo 77777777776666" and every time it's seems to be different.
Was This Post Helpful? 0
  • +
  • -

#6 TheNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 02:02 AM

Mr. Tweak:
So I've tried your code, but I still get the same error. It's randomly sending to many characters like this:
I should write "/goto 76"
It is writing "//////gggggooootttttooooo 77777777776666" and every time it's seems to be different.
Was This Post Helpful? 0
  • +
  • -

#7 TheNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 06:07 AM

Ok, so I've got it to stop writing to many characters, but now it wont write "/", it just writes "7".
I've tried changing it to {divide} and {/}, i also tried adding shift like this +(7) and +(/) but nothing seems to work.

Any ideas?
Was This Post Helpful? 0
  • +
  • -

#8 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 06:13 AM

Yeah, Sendkeys is unreliable, even MS says it's not 100%. I gave you the best solution!

This post has been edited by _HAWK_: 19 March 2012 - 06:23 AM

Was This Post Helpful? 1
  • +
  • -

#9 TheNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 06:29 AM

View Post_HAWK_, on 19 March 2012 - 06:13 AM, said:

Yeah, Sendkeys is unreliable, even MS says it's not 100%. I gave you the best solution!


Hehe sorry, i couldn't really find it, so i gave it a shot anyways.
But thank you for the link, i'm trying it out right now, will post results! :)
Was This Post Helpful? 0
  • +
  • -

#10 TheNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 06:44 AM

Okay, back again.
I'm really sorry to ask this, but how the F*** do you implement there inputsimulator into vb?
Was This Post Helpful? 0
  • +
  • -

#11 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 204
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 09:47 AM

Its a DLL file. Add a reference to it from your project. (Right-click on the project name in the Solution Exploere > Add Reference)
Was This Post Helpful? 0
  • +
  • -

#12 MrTwEaK  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 01:15 PM

I dont see why he would need to add a .dll file to his project 1 cause its size to be bigger and 2 have to implement it. Just try to mess around with the code you have try this set the timer interval to 7200000. Then put the code below into the timer.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
    End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
           Timer1.Enable = False
           SendMsg(TextBox1.Text)
End Sub

Public Sub SendMsg(ByVal Msg As String)
            GeckoWebBrowser1.BringToFront()
            GeckoWebBrowser1.Select()
            Windows.Forms.Cursor.Position = New System.Drawing.Point(GeckoWebBrowser1.Location.X +           Me.Location.X + 150, GeckoWebBrowser1.Location.Y + Me.Location.Y + 175)
            mouse_event(MOUSEEVENTF_LEFTDOWN , 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
            SendKeys.SendWait(Msg)
            SendKeys.SendWait("{ENTER}")
End Sub



Im not sure if your trying to use sendkeys when the form starts or when you click a button, but if your using it once your click a button just use the SendMsg function cause there wouldnt be a need for a timer. But if you need to sendkeys a few minutes after you start then look into a better method then a timer or something.
Was This Post Helpful? 0
  • +
  • -

#13 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 204
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 01:24 PM

View PostMrTwEaK, on 20 March 2012 - 01:45 AM, said:

I dont see why he would need to add a .dll file to his project 1 cause its size to be bigger


the DLL is just 14 KB
Was This Post Helpful? 0
  • +
  • -

#14 MrTwEaK  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 01:29 PM

View PostnK0de, on 19 March 2012 - 01:24 PM, said:

View PostMrTwEaK, on 20 March 2012 - 01:45 AM, said:

I dont see why he would need to add a .dll file to his project 1 cause its size to be bigger


the DLL is just 14 KB


If your a programmer 14kb is a big difference when you can simply write a function that saves you time and doesnt have a need of an extra 14kb.
Was This Post Helpful? 0
  • +
  • -

#15 TheNinja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-March 12

Re: Sendkeys.Send sending to many characters

Posted 19 March 2012 - 01:30 PM

Okay,I should've explaned what i was trying to do a little further.

It's supposed to write click the browser, send the message, every 2 minutes.
This hole event is started by a button, that starts 3 different timers.
One timer for text
One timer for a imagescan i made
and one timer for a click on a coordinate at the browser.

It all works just fine, except the text part not using the right characters.

I'm trying to do the Codeplex sendkey instead and I'll post back what i get :-)!

Thank you all for the good answers!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2