Code: Select all
; GLOBAL SETTINGS ===============================================================================================================
#NoEnv
#SingleInstance Force
SetBatchLines -1
; SCRIPT ========================================================================================================================
OnMessage(0x0044, "OnMsgBox")
MsgBox % "text"
OnMessage(0x0044, "")
OnMessage(0x4444, "OnMessageBox")
DllCall("user32\PostMessage", "ptr", A_ScriptHwnd, "uint", 0x4444, "ptr", 1337, "ptr", 0)
DllCall("user32\MessageBox", "ptr", 0, "str", "text", "str", "title", "uint", 0)
OnMessage(0x4444, "")
; FUNCTIONS =====================================================================================================================
OnMsgBox(wParam, lParam, msg, hWnd)
{
MsgBox % wParam " | " lParam " | " msg " | " hWnd
}
OnMessageBox(wParam, lParam, msg, hWnd)
{
MsgBox % wParam " | " lParam " | " msg " | " hWnd
}
Code: Select all
; GLOBAL SETTINGS ===============================================================================================================
#NoEnv
#SingleInstance Force
SetBatchLines -1
; GUI ===========================================================================================================================
Gui, +hWndhMyGUI
Gui, Margin, 10, 10
Gui, Add, Button, xm-1 ym w402 h200 gBUTTON_MSGBOX, % "Click me!"
Gui, Add, Edit, xm y+9 w400 0x801 vMyEdit
Gui, Show, AutoSize
GuiDisableMove(hMyGUI)
GuiDisableCloseButton(hMyGUI)
return
; SCRIPT ========================================================================================================================
BUTTON_MSGBOX:
ret := MessageBox(hMyGUI, "Random Title", "YES or NO?", 0x24)
GuiControl,, MyEdit, % (ret = 7) ? "NO!" : "YES!"
return
; FUNCTIONS =====================================================================================================================
MessageBox(handle, title, text, options)
{
WndHook := DllCall("SetWindowsHookEx", "int", 12, "ptr", RegisterCallback("CallWndRetProc", ""), "ptr", 0, "uint", DllCall("GetCurrentThreadId"), "ptr") ; WH_CALLWNDPROCRET := 12
ret := DllCall("user32\MessageBox", "ptr", handle, "str", text, "str", title, "uint", options)
if (WndHook)
DllCall("UnhookWindowsHookEx", "ptr", WndHook)
return ret
}
GuiDisableMove(handle)
{
hMenu := DllCall("user32\GetSystemMenu", "ptr", handle, "int", false, "ptr")
DllCall("user32\RemoveMenu", "ptr", hMenu, "uint", 0xf010, "uint", 0)
return DllCall("user32\DrawMenuBar", "ptr", handle)
}
GuiDisableCloseButton(handle)
{
hMenu := DllCall("user32\GetSystemMenu", "ptr", handle, "int", false, "ptr")
DllCall("user32\EnableMenuItem", "ptr", hMenu, "uint", 0xf060, "uint", 0x3)
return DllCall("user32\DrawMenuBar", "ptr", handle)
}
; CALLBACKS =====================================================================================================================
CallWndRetProc(code, wParam, lParam)
{
;critical 1000
if (code >= 0) { ; code >= HC_ACTION := 0
if (NumGet(lParam+0, A_PtrSize * 3, "uint") = 0x0110) { ; cwpmessage = WM_INITDIALOG := 0x0110
cwplparam := NumGet(lParam+0, A_PtrSize, "ptr"), cwphwnd := NumGet(lParam+0, A_PtrSize * 4, "ptr")
if (cwplparam && DllCall("GetWindowLong" (A_PtrSize = 8 ? "Ptr" : ""), "ptr", cwphwnd, "int", -21, "ptr") = cwplparam) ; GWLP_USERDATA := -21
if (NumGet(cwplparam+0, "uint") = A_PtrSize * 10) ; MSGBOXPARAMS := A_PtrSize * 10
GuiDisableMove(cwphwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", code, "ptr", wParam, "ptr", lParam, "ptr")
}
; EXIT ==========================================================================================================================
GuiEscape:
GuiClose:
ExitApp
; ===============================================================================================================================