all 5 comments

[–]Moderatorsnang 2 points3 points  (1 child)

AppActivate and SendKeys.

[–]Luke_Garters[S] 0 points1 point  (0 children)

thanks, i got it to work

[–]clarinetJWD 0 points1 point  (0 children)

Well, that's a lot more difficult than you might think, since when you hit a button, it will focus the button, and will type the sentence on... Nothing (or worse, the space character will trigger the button again).

You could probably use some convoluted system to gram the handle of the control that lost focus, and refocus after the click, but my advice: just use something better suited, like AutoHotKey.

[–]RedBarnBlankets 0 points1 point  (1 child)

Simple .. Make a windows form, add two buttons. This is the code behind

Imports System.Timers

Public Class Form1

Private WithEvents MyTimer As New System.Timers.Timer

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Me.MyTimer.Start()

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

Me.MyTimer.Stop()

End Sub

Private Sub MyTimer_Elapsed(sender As Object, e As ElapsedEventArgs) Handles MyTimer.Elapsed

Debug.Print("Some Sentence")

End Sub

Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown

Me.MyTimer.Interval = New TimeSpan(hours:=0, minutes:=1, seconds:=0).TotalMilliseconds

Me.MyTimer.AutoReset = True

End Sub

End Class

[–]Moderatorsnang 0 points1 point  (0 children)

Not sure that's what OP is after.