2017-08-02 163 views
0

我首次使用VB。我不知道,爲什麼這個簡單的代碼不起作用。VB 2010 sendkeys錯誤

Imports System.Runtime.InteropServices 

Public Class Form1 

    Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 
     Application.Exit() 
    End Sub 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
     Dim ProcID As Integer 
     ProcID = 2940 
     AppActivate(ProcID) 
     SendKeys.SendWait("Username") 
     SendKeys.SendWait("{ENTER}") 
     SendKeys.SendWait("Password") 
     SendKeys.SendWait("{ENTER}") 
    End Sub 
End Class 

錯誤: enter image description here

+0

在這行做此異常出現? –

+0

第一個SendKeys行 – V0lvox337

+0

你有沒有試過My.Computer.Keyboard.SendKey? –

回答

0

這是因爲遊戲衛隊是protectiong我的窗口.... 「只是」做繞道和對其做=)