forked from linxinhong/menuz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MZCommand.ahk
67 lines (67 loc) · 1.51 KB
/
MZCommand.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#SingleInstance,Force
#NoTrayIcon
DetectHiddenWindows On
SetTitleMatchMode 2
Global ParamString := Object()
If 0 > 0
{
Idx := 0
Loop,%0%
{
Param := %A_Index%
If A_Index = 1
{
MZC_Mode(Param)
If RegExMatch(param,"i)/m")
{
IsMode := True ;Mode
Continue
}
If RegExMatch(param,"i)/d")
{
IsDebugGUI := True ;Debug
Continue
}
}
idx++
ParamString[idx] := param
}
ParamString[0] := idx
If IsMode
MZC_Mode(ParamString[1])
If IsDebugGUI
MZC_DebugGUI()
}
MZC_Mode(Mode)
{
If RegExMatch(Mode,"^\{[^\{\}]*\}$")
{
SendMZC := "MZCommand:" Mode
Send_WM_COPYDATA(SendMZC)
exit
}
}
MZC_DebugGUI()
{
Count := ParamString[0]
Loop,%Count%
DebugString .= ParamString[A_Index]
SendMZC := "MZCommand:DebugGUI:" DebugString
Send_WM_COPYDATA(SendMZC)
exit
}
Send_WM_COPYDATA(ByRef StringToSend, ByRef TargetScriptTitle="MenuZ.ahk ahk_class AutoHotkey")
{
VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)
SizeInBytes := (StrLen(StringToSend) + 1) * (A_IsUnicode ? 2 : 1)
NumPut(SizeInBytes, CopyDataStruct, A_PtrSize)
NumPut(&StringToSend, CopyDataStruct, 2*A_PtrSize)
Prev_DetectHiddenWindows := A_DetectHiddenWindows
Prev_TitleMatchMode := A_TitleMatchMode
DetectHiddenWindows On
SetTitleMatchMode 2
SendMessage, 0x4a, 0, &CopyDataStruct,, %TargetScriptTitle%
DetectHiddenWindows %Prev_DetectHiddenWindows%
SetTitleMatchMode %Prev_TitleMatchMode%
return ErrorLevel
}