Jump to content

Recommended Posts

Posted (edited)

Hi all guys of the forum, based on this script:

I want to make custom button name but i have a problem:

#include <WinAPI.au3>

Global $hHookMsgBox

_MsgBox(0, "Title", "Text", "Button1")
_MsgBox(1, "Title", "Text", "Button1|Button2")
;~ _MsgBox(2, "Title", "Text")
;~ _MsgBox(3, "Title", "Text")
;~ _MsgBox(4, "Title", "Text")
;~ _MsgBox(5, "Title", "Text")
;~ _MsgBox(6, "Title", "Text")
;~ _MsgBox(7, "Title", "Text")

Func _MsgBox($flag, $title, $text, $var = "", $timeout = 0, $hwnd = 0)
Global $MsgBox_Name = StringSplit($var, "|")
Local $hProcMsgBox = DllCallbackRegister("CbtHookProcMsgBox", "int", "int;int;int")
Local $TIDMsgBox = _WinAPI_GetCurrentThreadId()
$hHookMsgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProcMsgBox), 0, $TIDMsgBox)
Local $iRet = MsgBox($flag, $title, $text, $timeout, $hwnd)
_WinAPI_UnhookWindowsHookEx($hHookMsgBox)
DllCallbackFree($hProcMsgBox)
$MsgBox_Name = ""
Return $iRet
EndFunc ;==>_MsgBox_Ex

Func CbtHookProcMsgBox($nCode, $wParam, $lParam, $hHookMsgBox)
Local $RET = 0, $hBitmap = 0, $xWnd = 0
Local $sButtonText
If $nCode < 0 Then
$RET = _WinAPI_CallNextHookEx($hHookMsgBox, $nCode, $wParam, $lParam)
Return $RET
EndIf
Switch $nCode
Case 5 ;5=HCBT_ACTIVATE
_WinAPI_SetDlgItemText($wParam, 1, $MsgBox_Name[1])
_WinAPI_SetDlgItemText($wParam, 2, $MsgBox_Name[2])
_WinAPI_SetDlgItemText($wParam, 3, "&Abort")
_WinAPI_SetDlgItemText($wParam, 4, "&Retry")
_WinAPI_SetDlgItemText($wParam, 5, "&Ignore")
_WinAPI_SetDlgItemText($wParam, 6, "&Yes")
_WinAPI_SetDlgItemText($wParam, 7, "&No")
_WinAPI_SetDlgItemText($wParam, 8, "Help")
_WinAPI_SetDlgItemText($wParam, 10, "&Try Again")
_WinAPI_SetDlgItemText($wParam, 11, "&Continue")
EndSwitch
Return
EndFunc ;==>CbtHookProcMsgBox

Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString)
Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _
"hwnd", $hDlg, _
"int", $nIDDlgItem, _
"str", $lpString)
Return $aRet[0]
EndFunc ;==>_WinAPI_SetDlgItemText

If i start only one of those separately work, ifi try to start both of them not. I think the problem is "clear" the array, i have add the $MsgBox_Name = "" but not work. Some suggestion?

Thanks to all

Edited by MyEarth
Posted

Change

_MsgBox(0, "Title", "Text", "Button1")
to
_MsgBox(0, "Title", "Text", "Button1|")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...