Code: Select all
WshShell := ComObjCreate("WScript.Shell")
Exec := ObjBindMethod(WshShell, "Exec")
%Exec%("calc.exe")
; alternative MsgBox
Popup := ObjBindMethod(WshShell, "Popup")
%Popup%("Hello World",, A_ScriptName)
; current process ID
A_ScriptPid := Func("DllCall").Bind("GetCurrentProcessId", "Ptr", 0)
%Popup%( "A_ScriptPid = " . %A_ScriptPid%() )
; count of key-value pairs
ObjCount := Func("NumGet").Bind(4 * A_PtrSize)
obj := {a:"Auto", h:"Hot", k:"key"}
%Popup%( "ObjCount = " . %ObjCount%(&obj) ) ; must pass address
StrUpper := Func("Format").Bind("{:Us}")
%Popup%( %StrUpper%("autohotkey") )
StrLower := Func("Format").Bind("{:Ls}")
%Popup%( %StrLower%("AUTOHOTKEY") )
StrTitle := Func("Format").Bind("{:Ts}")
%Popup%( %StrTitle%("the quick brown fox") )
DecToHex := Func("Format").Bind("0x{:X}")
%Popup%( "57007 = " . %DecToHex%(57007) )
IsWinVisible := Func("DllCall").Bind("IsWindowVisible", "Ptr")
%Popup%( %IsWinVisible%(A_ScriptHwnd + 0) ) ; must pass hWnd
IsWindow := Func("DllCall").Bind("IsWindow", "Ptr")
%Popup%( %IsWindow%(A_ScriptHwnd + 0) )
sc := ComObjCreate("ScriptControl")
sc.Language := "JScript"
JsEval := ObjBindMethod(sc, "Eval")
%Popup%( "1 + 1 = " . %JsEval%("1 + 1") )
; Readable OnMessage(es)
OnWinDestroy := Func("OnMessage").Bind(0x02)
%OnWinDestroy%("WM_DESTROY")
ExitApp