2.双击text1,然后输入如下代码:
Private Sub Text1_Change(Index As Integer)
Clipboard.SetText TxtUser(Index).Text
End Sub
3.运行后单击测试通过
(删除原来的进程, 重新打开新的进程可勉强实现)
Option Explicit
'窗口焦点设置
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
'Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'显示窗口
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongConst WM_CLOSE = &H10
Public lHwnd As Long
Public sHwnd As String
Sub Main()
lHwnd = 0
lHwnd = FindWindow(vbNullString, "form1")
If lHwnd >0 Then
'MsgBox "app exit " &CStr(lHwnd)
'ShowWindow lHwnd, SW_SHOW '用showwindow方法没有效果
'删除原来的进程, 重新打开新的进程
SendMessage lHwnd, WM_CLOSE, 0, 0
Form1.Show
Else
Form1.Show
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)