我是用VS2010的
- Public Class Form1
- Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
- Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Boolean
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Form2.Show()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Dim MapleStorys As IntPtr = FindWindow("MssTaskSwWClass", "MapleStory")
- If MapleStorys = False Then MsgBox("未找到楓谷", vbCritical, "未找到")
- Return
- SetForegroundWindow(MapleStorys)
- SendKeys.Send("「S」")
- SendKeys.Send("「S」")
- SendKeys.Send("「S」")
- SendKeys.Send("「S」")
- End Sub
- Sub start()
- SendKeys.Send("「S」")
- End Sub
- Public Shared Sub Send(ByVal keys As String)
- End Sub
- End Class
複製代碼 |