vb定时器启动工作的条件是什么

vb定时器启动工作的条件是什么,第1张

vb定时器启动工作的条件是Enabled和Interval。若希望窗体一加载定时器就开始工作,应将Enabled属性设置为True。否则,保持此属性为False。Interval是计时器最重要的属性,用于设置计时器事件之间的时间间隔,取值在0~65767(ms)之间。如果设置为0,则表示计时器无效。

首先加上这几个声明,要做成模块

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


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8177398.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存