給你個(gè)參考的例子,窗體打開(kāi)時(shí)可能大小有變化,軟件名可能有變化
創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供藁城網(wǎng)站建設(shè)、藁城做網(wǎng)站、藁城網(wǎng)站設(shè)計(jì)、藁城網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、藁城企業(yè)網(wǎng)站模板建站服務(wù),十載藁城做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
先加個(gè)控件ListBox1,運(yùn)行后雙擊ListBox1上程序名
Public Class Form1
Public myProcess() As Process
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myProcesses() As Process = Process.GetProcesses()
Dim jh As New ArrayList
For Each bs As Process In myProcesses
If CInt(bs.MainWindowHandle) 0 Then
ListBox1.Items.Add(bs.ProcessName)
jh.Add(bs)
End If
Next
ReDim myProcess(jh.Count - 1)
jh.CopyTo(myProcess)
End Sub
Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Integer, ByVal nCmdShow As Long) As Integer
Private Sub ListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick
Dim a As Process = myProcess(ListBox1.SelectedIndex)
Try
Dim dd = ShowWindow(a.MainWindowHandle, H1)
AppActivate(a.Id)
Catch ex As Exception
End Try
End Sub
End Class
這樣不好,應(yīng)該使用 Table 鍵,按照 Table 鍵順序來(lái)切換。因?yàn)榛剀囃脕?lái)確定你要按下頁(yè)面的確定按鈕。如果非要使用回車:
Private Sub 文本框按下回車鍵(sender As Object, e As KeyEventArgs) Handles TextBox3.KeyDown, TextBox2.KeyDown, TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
Select Case sender.name
Case "TextBox1"
TextBox2.Focus()
Case "TextBox2"
TextBox3.Focus()
Case "TextBox3"
TextBox1.Focus()
End Select
End If
End Sub
Public RunProcess As Process
RunProcess.start("djiwqjidjwqi")
AppActivate(RunProcess.Id())