Last active
November 16, 2024 21:43
-
-
Save nperovic/0b9a511eda773f9304813a6ad9eec137 to your computer and use it in GitHub Desktop.
Apply dark theme to your built-in MsgBox and InputBox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************ | |
* @description Apply dark theme to the built-in MsgBox. | |
* @file Dark_MsgBox.ahk | |
* @link https://gist.github.com/nperovic/0b9a511eda773f9304813a6ad9eec137 | |
* @author Nikola Perovic | |
* @date 2024/06/09 | |
* @version 1.1.0 | |
***********************************************************************/ | |
#Requires AutoHotkey v2.1-alpha.13 | |
#Module Dark_MsgBox | |
Import AHK | |
#DllLoad gdi32.dll | |
/** | |
* Display the specified text in a small window containing one or more buttons (such as'Yes' and'No'). | |
* @param Options indicates the type of message box and possible button combinations. If it is empty or omitted, the default is 0. Please refer to the table below for the allowed values. In addition, you can specify zero or more of the following options: | |
* | |
* Owner: To specify the owner window for the message box, use the word Owner followed by HWND (window ID). | |
* | |
* T: Timeout. If the user does not close the message box within the specified time, to make the message box close automatically, please use the letter T followed by the timeout seconds, which can include a decimal point. If the value exceeds 2147483 (24.8 days), it will be Set to 2147483. If the message box times out, the return value is the word Timeout. | |
* | |
* 0x0 confirm | |
* | |
* 0x1 Confirm/Cancel | |
* | |
* 0x2 abort/retry/ignore | |
* | |
* 0x3 Yes/No/Cancel | |
* | |
* 0x4 yes/no | |
* | |
* 0x5 Retry/Cancel | |
* | |
* 0x6 cancel/retry/continue | |
* | |
* 0x10 Stop/error icon. | |
* | |
* 0x20 question mark icon. | |
* | |
* 0x30 exclamation point icon. | |
* | |
* 0x40 star icon (information). | |
* | |
* 0x100 makes the second button the default button. | |
* | |
* 0x200 makes the third button the default button. | |
* | |
* 0x300 Make the fourth button the default. A Help button is required | |
* | |
* 0x1000 system mode (always on top) | |
* | |
* 0x2000 mission mode | |
* | |
* 0x40000 to the top (WS_EX_TOPMOST style) (similar to the system mode, but the title bar icon is omitted) | |
* | |
* 0x4000 Add a help button (please refer to the remarks below) | |
* | |
* 0x80000 Let the text be displayed right-aligned. | |
* | |
* 0x100000 is used for Hebrew/Arabic right-to-left reading order. | |
* @returns When called from an expression, MsgBox returns one of the following strings to indicate which button the user pressed: | |
* OK, Cancel, Yes, No, Abort, Retry, Ignore, TryAgain, Continue, Timeout | |
*/ | |
MsgBox(Text?, Title?, Options?, IconPath?) => DarkMsgBox(AHK.MsgBox, Text?, Title?, Options?, IconPath?) | |
/** | |
* Display an input box, asking the user to enter a string. | |
* @param Options is a case-insensitive string option, and each option is separated from the last option with a space or tab. | |
* | |
* Xn Yn: The X and Y coordinates of the dialog box. For example, X0 Y0 places the window in the upper left corner of the desktop. If any of the coordinates is omitted, the dialog box will be centered in that dimension. Any coordinate can be a negative number to make The dialog box is partially or completely off the desktop (or on a secondary monitor in a multi-monitor setup). | |
* | |
* Wn Hn: The width and height of the client area of the dialog box, excluding the title bar and border. For example, W200 H100. | |
* | |
* T: Specify the timeout time in seconds. For example, T10.0 is 10 seconds. If this value exceeds 2147483 (24.8 days), then it will be set to 2147483. After the timeout period is reached, the input box window will be closed automatically at the same time Set Result to the word "Timeout". Value will still contain what the user entered. | |
* | |
* Password: shield the user's input. To specify which character to use, as shown in this example: Password | |
*/ | |
InputBox(Prompt?, Title?, Options?, Default?) => DarkMsgBox(AHK.InputBox, Prompt?, Title?, Options?, Default?) | |
export default class DarkMsgBox | |
{ | |
; for v2.1.alpha.9 or later | |
class RECT { | |
left: i32, top: i32, right: i32, bottom: i32 | |
} | |
static Call(_this, params*) { | |
static WM_COMMNOTIFY := 0x44 | |
static WM_INITDIALOG := 0x0110 | |
iconNumber := 1 | |
iconFile := "" | |
if (params.length = (_this.MaxParams + 2)) | |
iconNumber := params.Pop() | |
if (params.length = (_this.MaxParams + 1)) | |
iconFile := params.Pop() | |
SetThreadDpiAwarenessContext(-3) | |
if InStr(_this.Name, "MsgBox") | |
OnMessage(WM_COMMNOTIFY, ON_WM_COMMNOTIFY, -1) | |
else | |
OnMessage(WM_INITDIALOG, ON_WM_INITDIALOG, -1) | |
return _this(params*) | |
ON_WM_INITDIALOG(wParam, lParam, msg, hwnd) | |
{ | |
OnMessage(WM_INITDIALOG, ON_WM_INITDIALOG, 0) | |
WNDENUMPROC(hwnd) | |
} | |
ON_WM_COMMNOTIFY(wParam, lParam, msg, hwnd) | |
{ | |
DetectHiddenWindows(true) | |
if (msg = 68 && wParam = 1027) | |
OnMessage(0x44, ON_WM_COMMNOTIFY, 0), | |
EnumThreadWindows(GetCurrentThreadId(), CallbackCreate(WNDENUMPROC), 0) | |
} | |
WNDENUMPROC(hwnd, *) | |
{ | |
static SM_CICON := "W" SysGet(11) " H" SysGet(12) | |
static SM_CSMICON := "W" SysGet(49) " H" SysGet(50) | |
static ICON_BIG := 1 | |
static ICON_SMALL := 0 | |
static WM_SETICON := 0x80 | |
static WS_CLIPCHILDREN := 0x02000000 | |
static WS_CLIPSIBLINGS := 0x04000000 | |
static WS_EX_COMPOSITED := 0x02000000 | |
static WS_VSCROLL := 0x00200000 | |
static winAttrMap := Map(2, 2, 4, 0, 10, true, 17, true, 20, true, 38, 4, 35, 0x2b2b2b) | |
SetWinDelay(-1) | |
SetControlDelay(-1) | |
DetectHiddenWindows(true) | |
if !WinExist("ahk_class #32770 ahk_id" hwnd) | |
return 1 | |
WinSetStyle("+" (WS_CLIPCHILDREN | WS_CLIPSIBLINGS)) | |
WinSetExStyle("+" (WS_EX_COMPOSITED)) | |
SetWindowTheme(hwnd, "DarkMode_Explorer") | |
if iconFile { | |
hICON_SMALL := LoadPicture(iconFile, SM_CSMICON " Icon" iconNumber, &handleType) | |
hICON_BIG := LoadPicture(iconFile, SM_CICON " Icon" iconNumber, &handleType) | |
PostMessage(WM_SETICON, ICON_SMALL, hICON_SMALL) | |
PostMessage(WM_SETICON, ICON_BIG, hICON_BIG) | |
} | |
for dwAttribute, pvAttribute in winAttrMap | |
DwmSetWindowAttribute(hwnd, dwAttribute, pvAttribute) | |
GWL_WNDPROC(hwnd, hICON_SMALL?, hICON_BIG?) | |
return 0 | |
} | |
GWL_WNDPROC(winId := "", hIcons*) | |
{ | |
static SetWindowLong := DllCall.Bind(A_PtrSize = 8 ? "SetWindowLongPtr" : "SetWindowLong", "ptr",, "int",, "ptr",, "ptr") | |
static BS_FLAT := 0x8000 | |
static BS_BITMAP := 0x0080 | |
static DPI := (A_ScreenDPI / 96) | |
static WM_CLOSE := 0x0010 | |
static WM_CTLCOLORBTN := 0x0135 | |
static WM_CTLCOLORDLG := 0x0136 | |
static WM_CTLCOLOREDIT := 0x0133 | |
static WM_CTLCOLORSTATIC := 0x0138 | |
static WM_DESTROY := 0x0002 | |
static WM_SETREDRAW := 0x000B | |
DetectHiddenWindows(true) | |
SetControlDelay(-1) | |
btns := [] | |
btnHwnd := "" | |
for ctrl in WinGetControlsHwnd(winId) | |
{ | |
classNN := ControlGetClassNN(ctrl) | |
SetWindowTheme(ctrl, !InStr(classNN, "Edit") ? "DarkMode_Explorer" : "DarkMode_CFD") | |
if !InStr(classNN, "B") | |
continue | |
btns.Push(btnHwnd := ctrl) | |
} | |
WindowProcOld := SetWindowLong(winId, -4, CallbackCreate(WNDPROC)) | |
WNDPROC(hwnd, uMsg, wParam, lParam) | |
{ | |
SetWinDelay(-1) | |
SetControlDelay(-1) | |
switch uMsg { | |
case WM_CTLCOLORSTATIC: | |
{ | |
hbrush := SelectObject(wParam, GetStockObject(18)) | |
SetDCBrushColor(wParam, 0x2b2b2b) | |
SetBkMode(wParam, 0) | |
SetTextColor(wParam, 0xFFFFFF) | |
for _hwnd in btns | |
PostMessage(WM_SETREDRAW,,,_hwnd) | |
GetClientRect(winId, rcC := this.RECT()) | |
ControlGetPos(, &btnY,, &btnH, btnHwnd) | |
hdc := GetDC(winId) | |
rcC.top := btnY - (rcC.bottom - (btnY+btnH)) | |
rcC.bottom *= 2 | |
rcC.right *= 2 | |
SetBkMode(hdc, 0) | |
SelectObject(hdc, hbrush := GetStockObject(18)) | |
SetDCBrushColor(hdc, 0x202020) | |
FillRect(hdc, rcC, hbrush) | |
ReleaseDC(winId, hdc) | |
for _hwnd in btns | |
PostMessage(WM_SETREDRAW, 1,,_hwnd) | |
return hbrush | |
} | |
case WM_CTLCOLORBTN, WM_CTLCOLORDLG, WM_CTLCOLOREDIT: | |
{ | |
SelectObject(wParam, hbrush := GetStockObject(18)) | |
SetDCBrushColor(wParam, 0x2b2b2b) | |
SetBkMode(wParam, 0) | |
SetTextColor(wParam, 0xFFFFFF) | |
return hbrush | |
} | |
case WM_DESTROY: | |
{ | |
for v in hIcons | |
(v??0) && DestroyIcon(v) | |
}} | |
return CallWindowProc(WindowProcOld, hwnd, uMsg, wParam, lParam) | |
} | |
} | |
CallWindowProc(lpPrevWndFunc, hWnd, uMsg, wParam, lParam) => DllCall("CallWindowProc", "Ptr", lpPrevWndFunc, "Ptr", hwnd, "UInt", uMsg, "Ptr", wParam, "Ptr", lParam) | |
DestroyIcon(hIcon) => DllCall("DestroyIcon", "ptr", hIcon) | |
/** @see — https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute */ | |
DWMSetWindowAttribute(hwnd, dwAttribute, pvAttribute, cbAttribute := 4) => DllCall("Dwmapi\DwmSetWindowAttribute", "Ptr" , hwnd, "UInt", dwAttribute, "Ptr*", &pvAttribute, "UInt", cbAttribute) | |
DeleteObject(hObject) => DllCall('Gdi32\DeleteObject', 'ptr', hObject, 'int') | |
EnumThreadWindows(dwThreadId, lpfn, lParam) => DllCall("User32\EnumThreadWindows", "uint", dwThreadId, "ptr", lpfn, "uptr", lParam, "int") | |
FillRect(hDC, lprc, hbr) => DllCall("User32\FillRect", "ptr", hDC, "ptr", lprc, "ptr", hbr, "int") | |
GetClientRect(hWnd, lpRect) => DllCall("User32\GetClientRect", "ptr", hWnd, "ptr", lpRect, "int") | |
GetCurrentThreadId() => DllCall("Kernel32\GetCurrentThreadId", "uint") | |
GetDC(hwnd := 0) => DllCall("GetDC", "ptr", hwnd, "ptr") | |
GetStockObject(fnObject) => DllCall('Gdi32\GetStockObject', 'int', fnObject, 'ptr') | |
GetWindowRect(hWnd, lpRect) => DllCall("User32\GetWindowRect", "ptr", hWnd, "ptr", lpRect, "uptr") | |
ReleaseDC(hWnd, hDC) => DllCall("User32\ReleaseDC", "ptr", hWnd, "ptr", hDC, "int") | |
SelectObject(hdc, hgdiobj) => DllCall('Gdi32\SelectObject', 'ptr', hdc, 'ptr', hgdiobj, 'ptr') | |
SetBkColor(hdc, crColor) => DllCall('Gdi32\SetBkColor', 'ptr', hdc, 'uint', crColor, 'uint') | |
SetBkMode(hdc, iBkMode) => DllCall('Gdi32\SetBkMode', 'ptr', hdc, 'int', iBkMode, 'int') | |
SetDCBrushColor(hdc, crColor) => DllCall('Gdi32\SetDCBrushColor', 'ptr', hdc, 'uint', crColor, 'uint') | |
SetTextColor(hdc, crColor) => DllCall('Gdi32\SetTextColor', 'ptr', hdc, 'uint', crColor, 'uint') | |
SetThreadDpiAwarenessContext(dpiContext) => DllCall("SetThreadDpiAwarenessContext", "ptr", dpiContext, "ptr") | |
SetWindowTheme(hwnd, pszSubAppName, pszSubIdList := "") => (!DllCall("uxtheme\SetWindowTheme", "ptr", hwnd, "ptr", StrPtr(pszSubAppName), "ptr", pszSubIdList ? StrPtr(pszSubIdList) : 0) ? true : false) | |
} | |
} | |
; Example: | |
; ipb := InputBox("Enter something here`nAnd here.", "InputBox Title") | |
; MsgBox(ipb.value, "Your Input", "0x6") | |
; ExitApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************ | |
* @description Apply dark theme to the built-in MsgBox and InputBox. | |
* @file Dark_MsgBox_v2.ahk | |
* @link https://gist.github.com/nperovic/0b9a511eda773f9304813a6ad9eec137 | |
* @author Nikola Perovic | |
* @date 2024/04/22 | |
* @version 1.1.0 | |
***********************************************************************/ | |
#Requires AutoHotkey v2 | |
#DllLoad gdi32.dll | |
/* | |
; for v2.1.alpha.9 or later | |
class POINT { | |
x: i32, y: i32 | |
} | |
class RECT { | |
left: i32, top: i32, right: i32, bottom: i32 | |
} | |
*/ | |
; for v2.0 or later | |
POINT(x := 0, y := 0) { | |
NumPut("int", x, "int", y, buf := Buffer(8)) | |
buf.DefineProp("x", {Get: NumGet.Bind(, 0, "int"), Set: IntPut.Bind(0)}) | |
buf.DefineProp("y", {Get: NumGet.Bind(, 4, "int"), Set: IntPut.Bind(4)}) | |
return buf | |
} | |
RECT(left := 0, top := 0, right := 0, bottom := 0){ | |
static ofst := Map("left", 0, "top", 4, "right", 8, "bottom", 12) | |
NumPut("int", left, "int", top, "int", right, "int", bottom, buf := Buffer(16)) | |
for k, v in ofst | |
buf.DefineProp(k, {Get: NumGet.Bind(, v, "int"), Set: IntPut.Bind(v)}) | |
return buf | |
} | |
IntPut(ofst, _, v) => NumPut("int", v, _, ofst) | |
class __MsgBox | |
{ | |
static __New() | |
{ | |
/** Thanks to geekdude & Mr Doge for providing this method to rewrite built-in functions. */ | |
static nativeMsgbox := MsgBox.Call.Bind(MsgBox) | |
static nativeInputBox := InputBox.Call.Bind(InputBox) | |
MsgBox.DefineProp("Call", {Call: BoxEx}) | |
InputBox.DefineProp("Call", {Call: BoxEx}) | |
BoxEx(_this, params*) | |
{ | |
static WM_COMMNOTIFY := 0x44 | |
static WM_INITDIALOG := 0x0110 | |
iconNumber := 1 | |
iconFile := "" | |
if (params.length = (_this.MaxParams + 2)) | |
iconNumber := params.Pop() | |
if (params.length = (_this.MaxParams + 1)) | |
iconFile := params.Pop() | |
SetThreadDpiAwarenessContext(-4) | |
if (_this.Name = "MsgBox") | |
OnMessage(WM_COMMNOTIFY, ON_WM_COMMNOTIFY, -1) | |
else | |
OnMessage(WM_INITDIALOG, ON_WM_INITDIALOG, -1) | |
return native%_this.Name%(params*) | |
ON_WM_INITDIALOG(wParam, lParam, msg, hwnd) | |
{ | |
OnMessage(WM_INITDIALOG, ON_WM_INITDIALOG, 0) | |
WNDENUMPROC(hwnd) | |
} | |
ON_WM_COMMNOTIFY(wParam, lParam, msg, hwnd) | |
{ | |
DetectHiddenWindows(true) | |
if (msg = 68 && wParam = 1027) | |
OnMessage(0x44, ON_WM_COMMNOTIFY, 0), | |
EnumThreadWindows(GetCurrentThreadId(), CallbackCreate(WNDENUMPROC), 0) | |
} | |
WNDENUMPROC(hwnd, *) | |
{ | |
static SM_CICON := "W" SysGet(11) " H" SysGet(12) | |
static SM_CSMICON := "W" SysGet(49) " H" SysGet(50) | |
static ICON_BIG := 1 | |
static ICON_SMALL := 0 | |
static WM_SETICON := 0x80 | |
static WS_CLIPCHILDREN := 0x02000000 | |
static WS_CLIPSIBLINGS := 0x04000000 | |
static WS_EX_COMPOSITED := 0x02000000 | |
static WS_VSCROLL := 0x00200000 | |
static winAttrMap := Map(2, 2, 4, 0, 10, true, 17, true, 20, true, 38, 2, 35, 0x2b2b2b) ; 34, 0xFFFFFFFE, | |
Critical() | |
SetWinDelay(-1) | |
SetControlDelay(-1) | |
DetectHiddenWindows(true) | |
if !WinExist("ahk_class #32770 ahk_id" hwnd) | |
return 1 | |
WinSetStyle("+" (WS_CLIPCHILDREN | WS_CLIPSIBLINGS)) | |
WinSetExStyle("+" (WS_EX_COMPOSITED)) | |
SetWindowTheme(hwnd, "DarkMode_Explorer") | |
if iconFile { | |
hICON_SMALL := LoadPicture(iconFile, SM_CSMICON " Icon" iconNumber, &handleType) | |
hICON_BIG := LoadPicture(iconFile, SM_CICON " Icon" iconNumber, &handleType) | |
PostMessage(WM_SETICON, ICON_SMALL, hICON_SMALL) | |
PostMessage(WM_SETICON, ICON_BIG, hICON_BIG) | |
} | |
for dwAttribute, pvAttribute in winAttrMap | |
DwmSetWindowAttribute(hwnd, dwAttribute, pvAttribute) | |
GWL_WNDPROC(hwnd, hICON_SMALL?, hICON_BIG?) | |
return 0 | |
} | |
GWL_WNDPROC(winId := "", hIcons*) | |
{ | |
static SetWindowLong := DllCall.Bind(A_PtrSize = 8 ? "SetWindowLongPtr" : "SetWindowLong", "ptr",, "int",, "ptr",, "ptr") | |
static BS_FLAT := 0x8000 | |
static BS_BITMAP := 0x0080 | |
static DPI := (A_ScreenDPI / 96) | |
static WM_CLOSE := 0x0010 | |
static WM_CTLCOLORBTN := 0x0135 | |
static WM_CTLCOLORDLG := 0x0136 | |
static WM_CTLCOLOREDIT := 0x0133 | |
static WM_CTLCOLORSTATIC := 0x0138 | |
static WM_DESTROY := 0x0002 | |
static WM_SETREDRAW := 0x000B | |
DetectHiddenWindows(true) | |
SetControlDelay(-1) | |
btns := [] | |
btnHwnd := hbrush1 := hbrush2 := "" | |
for ctrl in WinGetControlsHwnd(winId) | |
{ | |
classNN := ControlGetClassNN(ctrl) | |
SetWindowTheme(ctrl, !InStr(classNN, "Edit") ? "DarkMode_Explorer" : "DarkMode_CFD") | |
if !InStr(classNN, "B") | |
continue | |
ControlSetStyle("+" (BS_FLAT | BS_BITMAP), ctrl) | |
btns.Push(btnHwnd := ctrl) | |
} | |
WindowProcOld := SetWindowLong(winId, -4, CallbackCreate(WNDPROC)) | |
WNDPROC(hwnd, uMsg, wParam, lParam) | |
{ | |
Critical(-1) | |
DetectHiddenWindows(true) | |
SetWinDelay(-1) | |
SetControlDelay(-1) | |
if !hbrush1 | |
hbrush1 := CreateSolidBrush(0x202020) | |
if !hbrush2 | |
hbrush2 := CreateSolidBrush(0x2b2b2b) | |
switch uMsg { | |
case WM_CTLCOLORSTATIC: | |
{ | |
SelectObject(wParam, hbrush2) | |
SetBkMode(wParam, 0) | |
SetTextColor(wParam, 0xFFFFFF) | |
SetBkColor(wParam, 0x2b2b2b) | |
for _hwnd in btns | |
PostMessage(WM_SETREDRAW,,,_hwnd) | |
GetWindowRect(winId, rcW := RECT()) | |
GetClientRect(winId, rcC := RECT()) | |
GetWindowRect(btnHwnd, rcBtn := RECT()) | |
pt := POINT() | |
pt.y := rcW.bottom - rcBtn.bottom | |
ScreenToClient(winId, pt) | |
hdc := GetWindowDC(winId) | |
rcC.top := rcBtn.top + pt.y -2 | |
rcC.bottom *= 2 | |
rcC.right *= 2 | |
SetBkMode(hdc, 0) | |
FillRect(hdc, rcC, hbrush1) | |
ReleaseDC(winId, hdc) | |
for _hwnd in btns | |
PostMessage(WM_SETREDRAW, 1,,_hwnd) | |
return hbrush2 | |
} | |
case WM_CTLCOLORDLG, WM_CTLCOLOREDIT: | |
{ | |
SelectObject(wParam, hbrush2) | |
SetBkMode(wParam, 0) | |
SetTextColor(wParam, 0xFFFFFF) | |
SetBkColor(wParam, 0x2b2b2b) | |
return hbrush2 | |
} | |
case WM_CTLCOLORBTN: | |
{ | |
SelectObject(wParam, hbrush1) | |
SetBkMode(wParam, 0) | |
SetTextColor(wParam, 0xFFFFFF) | |
SetBkColor(wParam, 0x202020) | |
return hbrush2 | |
} | |
case WM_DESTROY: | |
{ | |
for v in [hbrush1, hbrush2] | |
(v && DeleteObject(v)) | |
for v in hIcons | |
(v??0) && DestroyIcon(v) | |
}} | |
return CallWindowProc(WindowProcOld, hwnd, uMsg, wParam, lParam) | |
} | |
} | |
} | |
CallWindowProc(lpPrevWndFunc, hWnd, uMsg, wParam, lParam) => DllCall("CallWindowProc", "Ptr", lpPrevWndFunc, "Ptr", hwnd, "UInt", uMsg, "Ptr", wParam, "Ptr", lParam) | |
ClientToScreen(hWnd, lpPoint) => DllCall("User32\ClientToScreen", "ptr", hWnd, "ptr", lpPoint, "int") | |
CreateSolidBrush(crColor) => DllCall('Gdi32\CreateSolidBrush', 'uint', crColor, 'ptr') | |
DestroyIcon(hIcon) => DllCall("DestroyIcon", "ptr", hIcon) | |
/** @see — https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute */ | |
DWMSetWindowAttribute(hwnd, dwAttribute, pvAttribute, cbAttribute := 4) => DllCall("Dwmapi\DwmSetWindowAttribute", "Ptr" , hwnd, "UInt", dwAttribute, "Ptr*", &pvAttribute, "UInt", cbAttribute) | |
DeleteObject(hObject) => DllCall('Gdi32\DeleteObject', 'ptr', hObject, 'int') | |
EnumThreadWindows(dwThreadId, lpfn, lParam) => DllCall("User32\EnumThreadWindows", "uint", dwThreadId, "ptr", lpfn, "uptr", lParam, "int") | |
FillRect(hDC, lprc, hbr) => DllCall("User32\FillRect", "ptr", hDC, "ptr", lprc, "ptr", hbr, "int") | |
GetClientRect(hWnd, lpRect) => DllCall("User32\GetClientRect", "ptr", hWnd, "ptr", lpRect, "int") | |
GetCurrentThreadId() => DllCall("Kernel32\GetCurrentThreadId", "uint") | |
GetWindowDC(hwnd) => DllCall("User32\GetWindowDC", "ptr", hwnd, "ptr") | |
GetWindowRect(hWnd, lpRect) => DllCall("User32\GetWindowRect", "ptr", hWnd, "ptr", lpRect, "uptr") | |
GetWindowRgn(hWnd, hRgn) => DllCall("User32\GetWindowRgn", "ptr", hWnd, "ptr", hRgn, "int") | |
GetWindowRgnBox(hWnd, hRgn) => DllCall("User32\GetWindowRgnBox", "ptr", hWnd, "ptr", hRgn, "int") | |
ReleaseDC(hWnd, hDC) => DllCall("User32\ReleaseDC", "ptr", hWnd, "ptr", hDC, "int") | |
ScreenToClient(hWnd, lpPoint) => DllCall("User32\ScreenToClient", "ptr", hWnd, "ptr", lpPoint, "int") | |
SelectObject(hdc, hgdiobj) => DllCall('Gdi32\SelectObject', 'ptr', hdc, 'ptr', hgdiobj, 'ptr') | |
SetBkColor(hdc, crColor) => DllCall('Gdi32\SetBkColor', 'ptr', hdc, 'uint', crColor, 'uint') | |
SetBkMode(hdc, iBkMode) => DllCall('Gdi32\SetBkMode', 'ptr', hdc, 'int', iBkMode, 'int') | |
SetTextColor(hdc, crColor) => DllCall('Gdi32\SetTextColor', 'ptr', hdc, 'uint', crColor, 'uint') | |
SetThreadDpiAwarenessContext(dpiContext) => DllCall("SetThreadDpiAwarenessContext", "ptr", dpiContext, "ptr") | |
SetWindowTheme(hwnd, pszSubAppName, pszSubIdList := "") => (!DllCall("uxtheme\SetWindowTheme", "ptr", hwnd, "ptr", StrPtr(pszSubAppName), "ptr", pszSubIdList ? StrPtr(pszSubIdList) : 0) ? true : false) | |
} | |
} |
Can it achieve automatic disappearance after a certain delay? Similar to ToolTip, it also supports display at specified positions.
@GmavionR
You can use T
+ seconds in the option for automatic disappearance. Like this:
#Requires AutoHotkey v2
MsgBox("HELLO", "Title", "T5")
In this example, the MsgBox
will disappear after 5 seconds and returns "timeout".
To make the MsgBox
display at specified positions:
#Requires AutoHotkey v2
SetMsgBoxPos(0, 0)
MsgBox("123", "title")
SetMsgBoxPos(x, y)
{
OnMessage(0x44, OnMsg, -1)
OnMsg(wParam, lParam, msg, hwnd)
{
DetectHiddenWindows(true)
SetWinDelay(-1)
if WinWait("ahk_class #32770",, 5)
WinMove(x, y)
OnMessage(0x44, OnMsg, 0)
}
}
For further details, please refer to the official document: CLICK HERE
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can it achieve automatic disappearance after a certain delay? Similar to ToolTip, it also supports display at specified positions.