我有一個關於Sendkeys Class的問題,因爲我想使用這個類來發送一些按鍵到活動的應用程序。 作爲第一步驟i要測試的{}輸入擊鍵,所以爲了實現這一我提出在vb.net簡單的應用程序2010在VB.NET中發送按鍵的簡單應用程序
Public Class Form1
Public Shared data As String
Private Sub SendintText(command As String)
Try
SendKeys.SendWait(command)
Catch e As Exception
MsgBox(e.StackTrace)
End Try
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
data = TextBox1.Text.ToString
SendingText(data)
End Sub
末級
當我試圖爲運行{Enter}我收到了infinit循環錯誤: 在System.Windows.Forms.dll中發生了類型爲「System.StackOverflowException」的未處理的異常 有人可以幫助我嗎?
以後編輯:在此期間我已經找到另一個例子
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
System.Threading.Thread.Sleep(2000)
SendKeys.SendWait("{ENTER}")
End Sub
如果在後臺我有兩個應用:
- 的Visual Studio
- 目標應用
哪有我專注於目標應用程序,因爲現在當我運行表單時,那個f orm成爲活動..有什麼解決方案從命令提示符調用winform與一些參數(我想發送的密鑰)?
後來EDIT2 強大的文本 我已經放棄了Windows窗體的想法,所以我finnally已在控制檯應用程序的簡單程序,用來模擬鍵盤...導入系統 進口System.Windows.Forms的
模塊模塊1
Sub Main(ByVal args() As String)
Dim data As String = args(0)
Console.WriteLine("You insert the : {0}", data)
System.Threading.Thread.Sleep(5000)
SendKeys.SendWait(data)
End Sub
前端模塊
通過在鄰的方式rder在需要\「測試\」的參數中使用雙引號......(我花了15分鐘才能找出),因此它可能是有用的... 再次感謝您的信息。
當你點擊按鈕,它就會集中。那麼發送按鍵到按鈕的目的是什麼? – PraveenVenu 2012-03-20 15:38:35
我只想測試發送密鑰(通過在文本框中輸入該密鑰)到應用程序...有沒有可能做到這一點? – Operagust 2012-03-20 16:15:55
當然,你可以做到這一點。你看了?你搜索什麼? – UnhandledExcepSean 2012-03-20 19:06:17