0

i know that sendkeys function is not the right way to change text of text box

i just want to try the function although that this function is not Effective
lets say that i got form with textbox and timer

Timer1.Interval = 1000


Timer1.Tick:

textbox1.Focus()
sendkeys.Send("123")

now evrey second the timer send keys into my textbox.

if i Minimize My Application the application send keys to EvreyWhere
lets say that i open NotePad And Then Run My Application the application send the keys into notepad and not my application

how can i send keys only to my application?

nnm
  • 865
  • 1
  • 8
  • 9
  • Have a look at this http://stackoverflow.com/questions/4309282/win32-check-if-window-is-minimized Just test before sendkeys. Another option (might not be reliable) would be to test if textbox1 has the focus after the setfocus call. – Tony Hopkinson Jul 01 '12 at 14:12
  • i dont want to stop the application when i Minimize the window – nnm Jul 01 '12 at 16:59

1 Answers1

1

The problem is once your application is minimized it is no longer the active application. SendKeys sends to the Active Application. Take a look at this Forum Link for possible options

From above link:

Use SendKeys to send keystrokes and keystroke combinations to the active application. This class cannot be instantiated. To send a keystroke to a class and immediately continue with the flow of your program, use Send. To wait for any processes started by the keystroke, use SendWait.

Mark Hall
  • 53,938
  • 9
  • 94
  • 111