|
本帖最后由 fybhwsx 于 2019-2-21 08:37 编辑
Local $MsgBox_DJS = _MsgBoxDJS(2 + 64 + 0 + 262144, '提示', '增加了按钮文本自定义,取消了A版_MsgBoxDJS的前两种模式,只保留按钮倒计时。这样$Cflag变量和$__Cflag = $Cflag就没用了,因为完全不懂DllCall,' & _
'请教下A版或懂DllCall的朋友,这两个变量有在DllCall中传递吗,直接删除似乎会导致不稳定?还有就是有点儿强迫症,怎样一开始就显示自定义的按钮文本和倒计时,而不是先显示下MsgBox的默认按钮?希望A版或知道的朋友能帮助实现想法!', 300, '', '', '重装', '跳过', '退出')
MsgBox(262144, '', '按下按钮:' & $MsgBox_DJS)
;_MsgBoxDJS函数 链接 http://www.autoitx.com/forum.php ... =%B5%B9%BC%C6%CA%B1 作者:afan版主
Func _MsgBoxDJS($flag, $title, $text, $timeout = 10, $Cflag = 2, $hwnd = '', $Button1 = '', $Button2 = '', $Button3 = '')
Global $___Timer = DllCallbackRegister('__Timer', 'int', 'hwnd;uint;uint;dword')
If $timeout = '' Or $timeout = -1 Then $timeout = 10
Global $s__title = $title, $s__text = $text, $__Cflag = $Cflag, $v__zt = 1, $v__ttc = $timeout, $__bttxtFlag = 0, $Button__1 = $Button1, $Button__2 = $Button2, $Button__3 = $Button3
Global $__Timer_DLL = DllCall('user32.dll', 'uint', 'SetTimer', 'hwnd', 0, 'uint', 0, 'int', 100, 'ptr', DllCallbackGetPtr($___Timer))
Local $rtMsg = MsgBox($flag, $title, $text, 0, $hwnd)
DllClose($__Timer_DLL)
;DllCallbackFree($___Timer)
Return $rtMsg
EndFunc ;==>_MsgBoxDJS
Func __Timer($hwnd, $uiMsg, $idEvent, $dwTime)
Global $__Timer_DLL, $__bttxtFlag, $__Cflag, $s__title, $v__ttc, $s__text, $v__zt, $___Timer, $s_titleF, $v__TimerJS, $Button__1, $Button__2, $Button__3
If $idEvent = $__Timer_DLL[0] Then
Global $s__bttxt, $i_ControlFocus, $n__Static
If $__bttxtFlag = 0 Then
;WinActivate($s__title)
If $Button__1 <> '' Then ControlSetText($s__title, $s__text, 'Button1', $Button__1)
If $Button__2 <> '' Then ControlSetText($s__title, $s__text, 'Button2', $Button__2)
If $Button__3 <> '' Then ControlSetText($s__title, $s__text, 'Button3', $Button__3)
$i_ControlFocus = ControlGetFocus($s__title)
$s__bttxt = ControlGetText($s__title, $s__text, $i_ControlFocus)
$__bttxtFlag = 1
EndIf
If $v__TimerJS = 9 Then
If $i_ControlFocus = 'Button1' Then
ControlSetText($s__title, $s__text, $i_ControlFocus, $Button__1 & StringFormat(' %s', $v__ttc - $v__zt))
If $Button__2 <> '' Then ControlSetText($s__title, $s__text, 'Button2', $Button__2)
If $Button__3 <> '' Then ControlSetText($s__title, $s__text, 'Button3', $Button__3)
ElseIf $i_ControlFocus = 'Button2' Then
ControlSetText($s__title, $s__text, 'Button1', $Button__1)
ControlSetText($s__title, $s__text, $i_ControlFocus, $Button__2 & StringFormat(' %s', $v__ttc - $v__zt))
If $Button__3 <> '' Then ControlSetText($s__title, $s__text, 'Button3', $Button__3)
ElseIf $i_ControlFocus = 'Button3' Then
ControlSetText($s__title, $s__text, 'Button1', $Button__1)
ControlSetText($s__title, $s__text, 'Button2', $Button__2)
ControlSetText($s__title, $s__text, $i_ControlFocus, $Button__3 & StringFormat(' %s', $v__ttc - $v__zt))
EndIf
If $v__zt = $v__ttc Then
DllClose($__Timer_DLL)
;DllCallbackFree($___Timer)
ControlClick($s__title, $s__text, $i_ControlFocus, '', 2)
EndIf
$v__zt += 1
$v__TimerJS = 0
Else
$v__TimerJS += 1
EndIf
EndIf
EndFunc ;==>__Timer
|
|