将窗口置于顶部/活动状态

时间:2015-04-30 15:13:45

标签: vb.net

我需要一些帮助来完成我为游戏制作的小程序。我无法让它工作,所以它切换到游戏,然后按我想要的按钮。它找到窗口,但只是不切换到它或使其活动。我使用的是正确的功能吗?

Public Class Form1

    Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Integer) As Integer

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        'Dim Hwnd As Long = BringWindowToTop("Aftermath v0.9.0  (build: Apr 15 2015 14:38:12) - final D3D9")
        Dim Hnd As Integer = Win32.FindWindow(Nothing, "Aftermath v0.9.0  (build: Apr 15 2015 14:38:12) - final D3D9") & BringWindowToTop(Hnd)
        If (Not Hnd = 0) Then
            SendKeys.Send("{enter}")
            SendKeys.Send("/ginvite " & Chr(34) & TextBox1.Text & Chr(34))
        Else
            MessageBox.Show("Error")
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ListBox1.Items.Add(TextBox1.Text)
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        ListBox1.Items.Remove(ListBox1.SelectedItem)
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim curItem As String = ListBox1.SelectedItem.ToString()
        SendKeys.Send("/ginvite " & Chr(34) & curItem & Chr(34))
        SendKeys.Send("{enter}")
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim curItem As String = ListBox1.SelectedItem.ToString()
        SendKeys.Send("/gaccept " & Chr(34) & curItem & Chr(34))
        SendKeys.Send("{enter}")
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        For i As Integer = 0 To Me.ListBox1.Items.Count - 1
            Me.ListBox1.SetSelected(i, True)
        Next
        'Dim curItems As String = ListBox1.SelectedItems.ToString()
        'SendKeys.Send("/ginvite" & Chr(34) & curItems & Chr(34))
        'SendKeys.Send("{enter}")
    End Sub

End Class

如果你能用我的列表框帮我,我也很乐意。我想要它,所以它在前面和后面打印我们的每个字符串Chr(34)

我目前拥有的代码(不起作用):

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
    For i As Integer = 0 To Me.ListBox1.Items.Count - 1
        Me.ListBox1.SetSelected(i, True)
    Next
    'Dim curItems As String = ListBox1.SelectedItems.ToString()
    'SendKeys.Send("/ginvite" & Chr(34) & curItems & Chr(34))
    'SendKeys.Send("{enter}")
End Sub

0 个答案:

没有答案