#include-once #include #include Global Const $tagCBT_CREATEWND = "ptr lpcs;HWND tagCBT_CREATEWND" Global Const $tagCREATESTRUCT = "ptr lpCreateParams;handle hInstance;HWND hMenu;HWND hwndParent;int cy;int cx;int y;int x;LONG style;ptr lpszName;ptr lpszClass;DWORD dwExStyle" Global $g__hProcDlgBox = DllCallbackRegister("__DlgBox_CbtHookProc", "LRESULT", "int;WPARAM;LPARAM") Global $g__TIdDlgBox = _WinAPI_GetCurrentThreadId() Global $g__hHookDlgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g__hProcDlgBox), 0, $g__TIdDlgBox) Global Const $g__MaxDlgBtns = 5 ; maximum of 5 buttons to rename text Global Const $g__MaxDlgItemId = 11 ; maximun ID of buttons to search is 11 as this is the maximun used in Messagebox Global $g__DlgBoxPosX, $g__DlgBoxPosY, $g__DlgBoxWidth, $g__DlgBoxHeight Global $g__aDlgBoxBtnText[$g__MaxDlgBtns] Global $g__DlgBtnCount = 0 Global $g_DlgBoxTimeout = 0 Global $g_DlgBoxTimeCtrlNum, $g_DlgBoxTimeCtrlId Global $g_DlgBoxTimerId _DlgBox_SetDefaults() OnAutoItExitRegister("__DlgBox_UnregisterHook") Func _DlgBox_SetButtonNames($TxtBtn1 = Default, $TxtBtn2 = Default, $TxtBtn3 = Default, $TxtBtn4 = Default, $TxtBtn5 = Default) $g__aDlgBoxBtnText[0] = $TxtBtn1 $g__aDlgBoxBtnText[1] = $TxtBtn2 $g__aDlgBoxBtnText[2] = $TxtBtn3 $g__aDlgBoxBtnText[3] = $TxtBtn4 $g__aDlgBoxBtnText[4] = $TxtBtn5 $g__DlgBtnCount = @NumParams EndFunc ;==>_DlgBox_SetButtonNames Func _DlgBox_SetPosition($x = Default, $y = Default) ;only for MsgBox, not working and not needed for InputBox $g__DlgBoxPosX = $x $g__DlgBoxPosY = $y EndFunc ;==>_DlgBox_SetPosition Func _DlgBox_SetSize($w = Default, $h = Default) $g__DlgBoxWidth = $w $g__DlgBoxHeight = $h EndFunc ;==>_DlgBox_SetSize Func _DlgBox_SetDefaults() $g__DlgBoxPosX = Default $g__DlgBoxPosY = Default $g__DlgBoxWidth = Default $g__DlgBoxHeight = Default For $i = 0 To UBound($g__aDlgBoxBtnText) - 1 $g__aDlgBoxBtnText[$i] = Default Next $g_DlgBoxTimeout = 0 EndFunc ;==>_DlgBox_SetDefaults Func _DlgBox_SetTimeout($iTimeout = 0, $CtrlId = 1) $g_DlgBoxTimeout = $iTimeout $g_DlgBoxTimeCtrlNum = $CtrlId EndFunc ;==>_DlgBox_SetTimeout Func __DlgBox_CbtHookProc($nCode, $wParam, $lParam) Local $tcw, $tcs Local $iSearch = 0 Local $ahBtn[$g__DlgBtnCount] If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndIf Switch $nCode Case 3 ;5=HCBT_CREATEWND If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class $tcw = DllStructCreate($tagCBT_CREATEWND, $lParam) $tcs = DllStructCreate($tagCREATESTRUCT, DllStructGetData($tcw, "lpcs")) If $g__DlgBoxPosX <> Default Then DllStructSetData($tcs, "x", $g__DlgBoxPosX) If $g__DlgBoxPosY <> Default Then DllStructSetData($tcs, "y", $g__DlgBoxPosY) If $g__DlgBoxWidth <> Default Then DllStructSetData($tcs, "cx", $g__DlgBoxWidth) If $g__DlgBoxHeight <> Default Then DllStructSetData($tcs, "cy", $g__DlgBoxHeight) If $g_DlgBoxTimeout <> 0 Then $g_DlgBoxTimerId = _Timer_SetTimer(HWnd($wParam), 1000, "_UpdateTime") EndIf EndIf Case 5 ;5=HCBT_ACTIVATE If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class For $i = 1 To $g__MaxDlgItemId ;~ ConsoleWrite($i & " - " & $iSearch & " - " & _WinAPI_GetDlgItemText($wParam, $i) & @CRLF) If IsHWnd(_WinAPI_GetDlgItem($wParam, $i)) Then If $g_DlgBoxTimeout > 0 Then If $g__aDlgBoxBtnText[$iSearch] = Default Then $g__aDlgBoxBtnText[$iSearch] = _WinAPI_GetDlgItemText($wParam, $i) If $iSearch == $g_DlgBoxTimeCtrlNum - 1 Then $g_DlgBoxTimeCtrlId = $i If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch] & " [" & $g_DlgBoxTimeout & "]") Else If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch]) EndIf Else If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch]) EndIf $iSearch += 1 ;Vorzeitiges Abbrechen der Schleife deaktiviert ;~ If $iSearch >= UBound($ahBtn) Then ExitLoop EndIf Next EndIf ;Bugfix: OK-Button wechselt von ID1 nach ID2 wenn er alleine angezeigt wird!??? If $iSearch = 1 And $g_DlgBoxTimeCtrlId = 1 Then $g_DlgBoxTimeCtrlId = 2 Case 4 ;4=HCBT_DESTROYWND If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class _Timer_KillTimer(HWnd($wParam), $g_DlgBoxTimerId) $g_DlgBoxTimeout = 0 EndIf EndSwitch Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndFunc ;==>__DlgBox_CbtHookProc Func _UpdateTime($hWnd, $iMsg, $iIDTimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer, $iTime $g_DlgBoxTimeout -= 1 _WinAPI_SetDlgItemText($hWnd, $g_DlgBoxTimeCtrlId, $g__aDlgBoxBtnText[$g_DlgBoxTimeCtrlNum - 1] & " [" & $g_DlgBoxTimeout & "]") If $g_DlgBoxTimeout <= 0 Then WinClose($hWnd) EndIf EndFunc ;==>_UpdateTime Func __DlgBox_UnregisterHook() _WinAPI_UnhookWindowsHookEx($g__hHookDlgBox) DllCallbackFree($g__hProcDlgBox) EndFunc ;==>__DlgBox_UnregisterHook 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 Func _WinAPI_GetDlgItemText($hDlg, $nIDDlgItem) Local $aRet = DllCall('user32.dll', "uint", "GetDlgItemTextW", _ "hwnd", $hDlg, _ "int", $nIDDlgItem, _ "wstr", "", _ "int", 1000) Return $aRet[3] EndFunc ;==>_WinAPI_GetDlgItemText