Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
再定义一个TIMER控件,Inerval的值设成1000
主要代码如下
Dim ret
Dim x, ret, ret2 As Long
Private Sub Timer1_Timer()
i = i + 1
If i = 180 Then ret = Shell("d:\1.exe", 1)
If i = 480 Then ret1 = Shell("d:\2.exe", 1)
If i = 1080 Then
x = OpenProcess(0, False, ret)
ret = TerminateProcess(x, 0)
ret = closehandel(x)
End If
If i = 1680 Then
x = OpenProcess(0, False, ret2)
ret2 = TerminateProcess(x, 0)
ret2 = closehandel(x)
End If
End Sub
窗口放一timer1关键是这句IEDialogHwnd
=
FindWindow("ThunderRT6FormDC",
"盛大魔界II
帐号注册机")
要用SKY++
获得程序主窗口的类
和标题
当前程序
类为ThunderRT6FormDC
标题为盛大魔界II
帐号注册机
Timer1.Interval
=
3000
表示3秒
定时器每三秒运行一次
将以下代码复制入
Option
Explicit
'用于查找窗口的API
Private
Declare
Function
SendMessage
Lib
"user32"
Alias
"SendMessageA"
(ByVal
hwnd
As
Long,
ByVal
wMsg
As
Long,
ByVal
wParam
As
Long,
ByVal
lParam
As
String)
As
Long
Private
Declare
Function
FindWindow
Lib
"user32"
Alias
"FindWindowA"
(ByVal
lpClassName
As
String,
ByVal
lpWindowName
As
String)
As
Long
Const
WM_CLOSE
=
&H10
Function
CloseSystemConfirmDlg()
As
Boolean
Dim
IEDialogHwnd
As
Long
Dim
subHwnd
As
Long
Dim
tempmsg
As
String
IEDialogHwnd
=
FindWindow("ThunderRT6FormDC",
"盛大魔界II
帐号注册机")
DoEvents
If
IEDialogHwnd
Then
CloseSystemConfirmDlg
=
True
Call
SendMessage(IEDialogHwnd,
WM_CLOSE,
0,
0)
End
If
End
Function
Private
Sub
Form_Load()
Timer1.Interval
=
3000
Timer1.Enabled
=
True
End
Sub
Private
Sub
Timer1_Timer()
Call
CloseSystemConfirmDlg
End
Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)