MG_ScreenEdge.ahk

;===============================================================================
;
; MouseGestureL.ahk - Screen Edge Recognition Module
;
; Created by lukewarm
; Modified by Pyonkichi
;===============================================================================
MG_Edge_Monitor_Set()
 
Goto, MG_ScrenEdge_End
 
;-------------------------------------------------------------------------------
; Enable or Disable Screen Edge Recognition Process
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Edge_Monitor_Set(on=1)
{
global
if (on)
{
MG_CornerX := (MG_CornerX > 0) ? MG_CornerX : 1
MG_CornerY := (MG_CornerY > 0) ? MG_CornerY : 1
SetTimer, MG_Edge_Monitor, %MG_EdgeInterval%
}
else
{
SetTimer, MG_Edge_Monitor, OFF
}
}
 
 
;-------------------------------------------------------------------------------
; Screen Edge Recognition Process
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Edge_Monitor:
MG_Edge_Monitor()
return
MG_Edge_Monitor()
{
local ptX, ptY, scrL, scrT, scrR, scrB, scrW, scrH
CoordMode, Mouse, Screen
MouseGetPos, ptX, ptY
;...........................................................................
; Get screen rectangule
if (MG_EdgeIndiv)
{
MG_GetMonitorRect(ptX, ptY, scrL, scrT, scrR, scrB)
scrW := scrR - scrL
scrH := scrB - scrT
scrR--, scrB--
}
else
{
SysGet, scrL, 76
SysGet, scrT, 77
SysGet, scrW, 78
SysGet, scrH, 79
scrR := scrL + scrW - 1
scrB := scrT + scrH - 1
}
MG_Edge_State := ""
;...........................................................................
; Left side
if (ptX == scrL)
{
if (MG_EdgeIndiv && MG_MonitorExists(ptX-1, ptY)) {
; Another monitor exists in left side
}
else if (MG_Edge_CLT_Enabled && ptY>=scrT && ptY<(scrT+MG_CornerY))
{
if (!MG_EdgeIndiv || !MG_MonitorExists(scrL, scrT-1)) {
MG_Edge_State=CLT
}
}
else if (MG_Edge_CLB_Enabled && ptY>(scrB-MG_CornerY) && ptY<=scrB)
{
if (!MG_EdgeIndiv || !MG_MonitorExists(scrL, scrB+1)) {
MG_Edge_State=CLB
}
}
else if (MG_Edge_EL1_Enabled && ptY<(scrT+scrH/3)) {
MG_Edge_State=EL1
}
else if (MG_Edge_EL2_Enabled && ptY>=(scrT+scrH/3) && ptY<(scrT+scrH*2/3)) {
MG_Edge_State=EL2
}
else if (MG_Edge_EL3_Enabled && ptY>=(scrT+scrH*2/3)) {
MG_Edge_State=EL3
}
else if (MG_Edge_ELA_Enabled && ptY<(scrT+scrH/2)) {
MG_Edge_State=ELA
}
else if (MG_Edge_ELB_Enabled && ptY>=(scrT+scrH/2)) {
MG_Edge_State=ELB
}
else if (MG_Edge_EL_Enabled) {
MG_Edge_State=EL
}
}
;...........................................................................
; Right side
else if (ptX == scrR)
{
if (MG_EdgeIndiv && MG_MonitorExists(ptX+1, ptY)) {
; Another monitor exists in right side
}
else if (MG_Edge_CRT_Enabled && ptY>=scrT && ptY<(scrT+MG_CornerY))
{
if (!MG_EdgeIndiv || !MG_MonitorExists(scrR, scrT-1)) {
MG_Edge_State=CRT
}
}
else if (MG_Edge_CRB_Enabled && ptY>(scrB-MG_CornerY) && ptY<=scrB)
{
if (!MG_EdgeIndiv || !MG_MonitorExists(scrR, scrB+1)) {
MG_Edge_State=CRB
}
}
else if (MG_Edge_ER1_Enabled && ptY<(scrT+scrH/3)) {
MG_Edge_State=ER1
}
else if (MG_Edge_ER2_Enabled && ptY>=(scrT+scrH/3) && ptY<(scrT+scrH*2/3)) {
MG_Edge_State=ER2
}
else if (MG_Edge_ER3_Enabled && ptY>=(scrT+scrH*2/3)) {
MG_Edge_State=ER3
}
else if (MG_Edge_ERA_Enabled && ptY<(scrT+scrH/2)) {
MG_Edge_State=ERA
}
else if (MG_Edge_ERB_Enabled && ptY>=(scrT+scrH/2)) {
MG_Edge_State=ERB
}
else if (MG_Edge_ER_Enabled) {
MG_Edge_State=ER
}
}
;...........................................................................
; Upper side
else if (ptY == scrT)
{
if (MG_EdgeIndiv && MG_MonitorExists(ptX, ptY-1)) {
; Another monitor exists in upper side
}
else if (MG_Edge_CLT_Enabled && ptX>=scrL && ptX<(scrL+MG_CornerX))
{
if (!MG_EdgeIndiv || !MG_MonitorExists(scrL-1, scrT)) {
MG_Edge_State=CLT
}
}
else if (MG_Edge_CRT_Enabled && ptX>(scrR-MG_CornerX) && ptX<=scrR)
{
if (!MG_EdgeIndiv || !MG_MonitorExists(scrR+1, scrT)) {
MG_Edge_State=CRT
}
}
else if (MG_Edge_ET1_Enabled && ptX<(scrL+scrW/3)) {
MG_Edge_State=ET1
}
else if (MG_Edge_ET2_Enabled && ptX>=(scrL+scrW/3) && ptX<(scrL+scrW*2/3)) {
MG_Edge_State=ET2
}
else if (MG_Edge_ET3_Enabled && ptX>=(scrL+scrW*2/3)) {
MG_Edge_State=ET3
}
else if (MG_Edge_ETA_Enabled && ptX<(scrL+scrW/2)) {
MG_Edge_State=ETA
}
else if (MG_Edge_ETB_Enabled && ptX>=(scrL+scrW/2)) {
MG_Edge_State=ETB
}
else if (MG_Edge_ET_Enabled) {
MG_Edge_State=ET
}
}
;...........................................................................
; Lower side
else if (ptY == scrB)
{
if (MG_EdgeIndiv && MG_MonitorExists(ptX, ptY+1)) {
; Another monitor exists in lower side
}
else if (MG_Edge_CLB_Enabled && ptX>=scrL && ptX<(scrL+MG_CornerX))
{
if (!MG_EdgeIndiv || !MG_MonitorExists(scrL-1, scrB)) {
MG_Edge_State=CLB
}
}
else if (MG_Edge_CRB_Enabled && ptX>(scrR-MG_CornerX) && ptX<=scrR)
{
if (!MG_EdgeIndiv || !MG_MonitorExists(scrR+1, scrB)) {
MG_Edge_State=CRB
}
}
else if (MG_Edge_EB1_Enabled && ptX<(scrL+scrW/3)) {
MG_Edge_State=EB1
}
else if (MG_Edge_EB2_Enabled && ptX>=(scrL+scrW/3) && ptX<(scrL+scrW*2/3)) {
MG_Edge_State=EB2
}
else if (MG_Edge_EB3_Enabled && ptX>=(scrL+scrW*2/3)) {
MG_Edge_State=EB3
}
else if (MG_Edge_EBA_Enabled && ptX<(scrL+scrW/2)) {
MG_Edge_State=EBA
}
else if (MG_Edge_EBB_Enabled && ptX>=(scrL+scrW/2)) {
MG_Edge_State=EBB
}
else if (MG_Edge_EB_Enabled) {
MG_Edge_State=EB
}
}
;...........................................................................
; Not Edge
else
{
if (MG_Edge_Active)
{
MG_Edge_State := MG_Edge_Active
MG_Edge_Active := ""
MG_TriggerUp(MG_Edge_State)
}
MG_Edge_State := ""
}
;...........................................................................
; Process trigger-down actions
if (!MG_Edge_Active && MG_Edge_State && MG_Edge_State!=MG_Edge_Active)
{
MG_Edge_Active := MG_Edge_State
SetTimer, MG_Edge_TriggerTimer, -1
}
}
 
;-------------------------------------------------------------------------------
; Check wheter monitor exists in specified coordinates
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_MonitorExists(ptX, ptY)
{
pt := (ptY<<32) | (ptX & 0xffffffff)
return DllCall("user32.dll\MonitorFromPoint", "UInt64",pt, "UInt",0, "Ptr")
}
 
;-------------------------------------------------------------------------------
; Process trigger-down actions
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Edge_TriggerTimer:
MG_TriggerDown(MG_Edge_Active)
return
 
 
MG_ScrenEdge_End:

 

MG_CommonLib.ahk

;===============================================================================
;
; MouseGestureL.ahk - Common Functions Library
;
; Created by Pyonkichi
;===============================================================================
#Requires AutoHotkey v1.1.25+
MG_Version := 1.40
MG_InitCommonGlobals()
Goto MG_CommonLibEnd
 
;-------------------------------------------------------------------------------
; Initialize common global variables
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_InitCommonGlobals()
{
global
MG_DirConfig  := A_ScriptDir "\Config\"
MG_DirLang   := A_ScriptDir "\Languages\"
MG_DirPlugins := A_ScriptDir "\Plugins\"
MG_DirButtons := A_ScriptDir "\Components\Buttons\"
MG_DirScrEdge := MG_DirButtons "ScreenEdges\"
MG_DirUserBtn := MG_DirConfig "UserButtons\"
MG_DirAHK   := A_ScriptDir "\AutoHotkey\"
MG_IconFile   := A_ScriptDir "\Components\MouseGestureL.icl"
MG_ReplaceStr := "###REPLACE###"
MG_DefTargetName := "Default"
 
MG_SaveModificationObj := Func("SaveModification")
MG_TgDelim := "/"
MG_RuleNames =
(LTrim Join|
WClass
WClass_[NPTBR][PTBR]?
CClass
CClass_[NPTBR][PTBR]?
Title
Title_[NPTBR][PTBR]?
Exe
Exe_[NPTBR][PTBR]?
Custom
Custom_N
Include
Include_N
)
if (A_Is64bitOS) {
EnvGet, A_ProgramFilesX86, ProgramFiles(x86)
} else {
A_ProgramFilesX86 := A_ProgramFiles
}
}
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Menu commands
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Reload Gesture Configurations
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Reload()
{
RunWait, %A_AhkPath% "%A_ScriptDir%\MG_Edit.ahk" /ini2ahk
Reload
}
 
;-------------------------------------------------------------------------------
; Edit Gesture Configurations
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Edit()
{
global
if (MG_EditCommand) {
Run, %MG_EditCommand%
return
}
MG_SearchPlugins()
local t1:=0, t2:=0
FileGetTime, t1, %MG_DirConfig%MG_Config.ahk
RunWait, %A_AhkPath% "%A_ScriptDir%\MG_Edit.ahk"
FileGetTime, t2, %MG_DirConfig%MG_Config.ahk
if (t2 > t1) {
Reload
CheckConfigurationError()
}
}
 
;-------------------------------------------------------------------------------
; Show Help Document
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_ShowHelp()
{
global
IfWinExist, MouseGestureL-Help ahk_class HH Parent
{
WinActivate
}
else if(FileExist(A_ScriptDir . "\Docs\" . MC_HelpFile)) {
Run, %A_ScriptDir%\Docs\%MC_HelpFile%
}
else {
MsgBox, %MC_LngMessage001%
}
}
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Configurations
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Check whether configuration files exist
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CheckConfigFiles()
{
local szNewIni, szOldIni, bExists
 
szNewIni := MG_DirConfig "MouseGestureL.ini"
szOldIni := A_ScriptDir "\MouseGesture.ini"
bExists := true
 
if (FileExist(MG_DirConfig) != "D") {
FileCreateDir, %MG_DirConfig%
}
if (!FileExist(szNewIni)) {
if (FileExist(szOldIni)) {
FileCopy, %szOldIni%, %szNewIni%
}
bExists := false
}
if (!MG_IsEdit) {
if (!bExists) {
MG_Edit()
}
else if (!FileExist(MG_DirConfig "MG_Config.ahk")) {
MG_Reload()
}
}
return bExists
}
 
;-------------------------------------------------------------------------------
; Load Ini File
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_LoadIniFile(szIniData="")
{
global
Target_Count  := 0
Gesture_Count := 0
if (!szIniData) {
FileRead, szIniData, %MG_DirConfig%MouseGestureL.ini
}
MG_LoadIni(szIniData)
Config_IniFileVersion := MG_Version
}
 
;-------------------------------------------------------------------------------
; Convert ini string to variables
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_LoadIni(szIni, ByRef tpos=0, ByRef gpos=0)
{
global
local szLine, com, SName, tidx, tname, cnt, gidx, rcount, acount, bChild
, bGes, parent, lv, tstart, lvdiff, bImpT, bImpG , LastIdx, nIgnore, aryTmp
 
szIni .= "`n[EndOfIni]`n"
SName := ""
tstart := Target_Count + 1
bImpT:= bImpG := bChild := false
nIgnore := 0
LastIdx :=
if (!MG_ActvtExclud.MaxIndex()) {
MG_ActvtExclud :=
}
Loop, parse, szIni, `n, `r%A_Tab%%A_Space%
{
;-----------------------------------------------------------------------
; Read one line : 行データ取得
;-----------------------------------------------------------------------
szLine := A_LoopField
;.......................................................................
; Start comments : 範囲コメント開始
if (RegExMatch(szLine, "^\s*\/\*")) {
if (!RegExMatch(szLine, "\*\/\s*$")){
com := 1
}
}
;.......................................................................
; End comments : 範囲コメント終了
else if (RegExMatch(szLine, "\*\/\s*$")) {
com := 0
}
;.......................................................................
; Skip other comments : その他コメントはスキップ
else if (RegExMatch(szLine, "^\s*#")||com) {
}
;-----------------------------------------------------------------------
; Section : セクション
;-----------------------------------------------------------------------
else if (RegExMatch(szLine, "^\[(.+)\]$", $)) {
if (SName == "") {
; Section has not been found.
}
;.......................................................................
  ; Previous section is gesture : 前のセクションがジェスチャーだった場合
else if (bGes) {
if (GestureIndexOf(SName)) {
cnt := 1
Loop {
cnt++
tname := SName . " (" . cnt . ")"
if (!GestureIndexOf(tname)) {
SName := tname
break
}
}
}
Gesture_%gidx%_Count := acount
if (!Gesture_%gidx%_Name) {
Gesture_%gidx%_Name := SName
Gesture_Count++
bImpG := true
}
}
;.......................................................................
; Previous section is target : 前のセクションがターゲットだった場合
else if (SName!="Settings" && SName!="ActivationExcluded") {
if (lv==1 && TargetIndexOf(SName)) {
cnt := 1
Loop {
cnt++
tname := SName . " (" . cnt . ")"
if (!TargetIndexOf(tname)) {
SName := tname
break
}
}
}
Target_%tidx%_Count := rcount
if (!Target_%tidx%_Name) {
Target_%tidx%_Name := SName
Target_Count++
LastIdx[lv] := tidx
bImpT := true
}
}
;.......................................................................
SName := $1
tidx := Target_Count + 1
Target_%tidx%_Name := ""
Target_%tidx%_Icon := 0
Target_%tidx%_IsAnd := 0
Target_%tidx%_Level := 1
Target_%tidx%_Parent := ""
Target_%tidx%_NotInh := 0
rcount := 0
gidx := Gesture_Count + 1
Gesture_%gidx%_Name := ""
Gesture_%gidx%_Patterns := ""
Gesture_%gidx%_Default := ""
acount := 0
bGes := false
lv := 1
}
;-----------------------------------------------------------------------
; Entry : エントリ
;-----------------------------------------------------------------------
else if (RegExMatch(szLine, "^(.+?)\s*=\s*(.*?)$", $)) {
if (SName = "Settings") {
Config_%$1% := $2
}
;.......................................................................
; Excluded targets for MG_ActivatePrevWin() function
else if (SName = "ActivationExcluded") {
if (RegExMatch($2, "^{(.*?)\t(.*?)\t(.*?)}$", $) && ($1 || $2 || $3)) {
aryTmp := Array($1, $2, $3)
nIgnore++
MG_ActvtExclud.InsertAt(nIgnore, aryTmp)
}
}
;.......................................................................
; Target rule : ターゲットルール
else if (RegExMatch($1, "^(" . MG_RuleNames . ")$")) {
if (!MG_RuleExists(tidx, $1, $2)) {
rcount++
Target_%tidx%_%rcount%_Type := $1
Target_%tidx%_%rcount%_Value := $2
}
}
;.......................................................................
; Target icon : ターゲットのアイコン
else if (MG_hImageList && $1="Icon") {
Target_%tidx%_IconFile := $2
Target_%tidx%_Icon := MG_SerchSameIcon($2)
if (!Target_%tidx%_Icon) {
RegExMatch($2, "^(.+?)\s*,\s*(.*?)$", $)
Target_%tidx%_Icon := IL_Add(MG_hImageList, MG_VarInStr($1), $2)
}
}
;.......................................................................
; Target rule "And" mode : ターゲットルールANDモード
else if ($1 = "And") {
Target_%tidx%_IsAnd := $2
}
;.......................................................................
; Target rule "Exclude from default gesture targets"
else if ($1 = "ExcludeDefault") {
Target_%tidx%_IsExDef := $2
}
;.......................................................................
; Target nesting level
else if ($1 = "Level") {
lv := $2 - 1
if (LastIdx[lv]) {
Target_%tidx%_Parent := LastIdx[lv]
} else if (!bChild) {
bChild := true
Target_%tidx%_Parent := (tpos > 1) ? tpos : Target_Count
} else {
lv := $2 + lvdiff - 1
Target_%tidx%_Parent := LastIdx[lv]
}
parent := Target_%tidx%_Parent
lv := Target_%parent%_Level + 1
if (tstart == tidx) {
lvdiff := lv - $2
}
Target_%tidx%_Level := lv
}
;.......................................................................
; Target rule "Don't inherit the parent conditions"
else if ($1 = "NotInherit") {
Target_%tidx%_NotInh := $2
}
;.......................................................................
; Gesture : ジェスチャー
else if ($1 = "G") {
bGes := true
if ($2) {
Join(Gesture_%gidx%_Patterns, $2)
}
}
;.......................................................................
; Bound Action : 割り当てアクション
else if (bGes) {
if (!MG_ActionExists(gidx, $1)) {
if (Config_IniFileVersion < 1.20) {
$2 := RegExReplace($2, "(?<!\t)\t", "<MG_CR>")
}
acount++
Gesture_%gidx%_%acount%_Target := $1
Gesture_%gidx%_%acount%_Action := $2
}
}
}
}
tpos := bImpT ? tpos : 0
gpos := bImpG ? gpos : 0
}
 
;-------------------------------------------------------------------------------
; Check whether specified rule exists
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_RuleExists(iTarget, szType, szValue)
{
global
Loop, % Target_%iTarget%_Count
{
if *1 {
return true
}
}
return false
}
 
;-------------------------------------------------------------------------------
; Check whether specified action exists
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_ActionExists(iGesture, szTarget)
{
global
Loop, % Gesture_%iGesture%_Count
{
if (Gesture_%iGesture%_%A_Index%_Target = szTarget) {
return A_Index
}
}
return 0
}
 
;-------------------------------------------------------------------------------
; Retrieve Target Index by Name
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
TargetIndexOf(name)
{
local idx:=1, ret:=0, lv
 
if (name == MG_DefTargetName) {
return 1
}
Loop, Parse, name, %MG_TgDelim%
{
if (!A_LoopField) {
break
}
lv := A_Index
while (idx <= Target_Count) {
if *2 {
ret:=idx
break
}
idx++
}
idx++
}
return ret
}
 
;-------------------------------------------------------------------------------
; Retrieve Gesture Index by Name
; Implemented by lukewarm
;-------------------------------------------------------------------------------
GestureIndexOf(name)
{
global
Loop, %Gesture_Count%
{
if (Gesture_%A_Index%_Name = name) {
return A_Index
}
}
return 0
}
 
;-------------------------------------------------------------------------------
; Retrieve Gesture Index by Gesture String
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_FindGesture(szGesture)
{
global
Loop, %Gesture_Count%
{
local idxGes := A_Index
Loop, Parse, Gesture_%A_Index%_Patterns, `n
{
if (A_LoopField && (A_LoopField = szGesture)) {
return idxGes
}
}
}
return 0
}
 
;-------------------------------------------------------------------------------
; Serch Target Icon Filename
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SerchSameIcon(szIconFile)
{
global
Loop, %Target_Count%
{
if (Target_%A_Index%_IconFile = szIconFile) {
return Target_%A_Index%_Icon
}
}
return 0
}
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Gesture Conditions
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Regisger Custom Condition Category
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_AddConditionCategory(key, name)
{
global
if (!MG_IsEdit
|| CustomExpressions_%category%_Count)
{
return
}
Menu, CustomExpressions_%key%, Add
Menu, CustomExpressions_%key%, DeleteAll
Menu, CustomExpressions, Add, %name%, :CustomExpressions_%key%
}
 
;-------------------------------------------------------------------------------
; Regisger Custom Condition
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_AddCustomCondition(category, name="", value="")
{
local cnt, szCommand
if (!MG_IsEdit) {
return
}
Menu, CustomExpressions_%category%, Add, %name%, CustomExpressionsMenuSelect
cnt := CustomExpressions_%category%_Count
cnt := cnt ? cnt+1 : 1
CustomExpressions_%category%_Count := cnt
CustomExpressions_%category%_%cnt% := value
return
 
;---------------------------------------------------------------------------
; The menu item has been selected
CustomExpressionsMenuSelect:
szCommand := %A_ThisMenu%_%A_ThisMenuItemPos%
if (IsFunc(szCommand)) {
Func(szCommand).()
}
else if (IsLabel(szCommand)) {
GoSub, %szCommand%
}
else {
MG_SetRuleValue(szCommand)
}
return
}
 
;-------------------------------------------------------------------------------
; Set Rule Value
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_SetRuleValue(val) {
GuiControl, MEW_Main:, ERuleValue, %val%
}
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Gesture Actions
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Regisger Action Category
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_AddActionCategory(key="Others", name="???")
{
global
if (!MG_IsEdit) {
return
}
local idx := GetActionCategoryIdx(key)
if (idx) {
ActionCategory%idx%_Name := name
}
else {
if (key = "Others") {
idx := "Temp"
}
else {
ActionCategory_Count++
idx := ActionCategory_Count
}
ActionCategory%idx%_Count := 0
ActionCategory%idx%_Key   := key
ActionCategory%idx%_Name  := name
}
GuiControl, MEW_Main:, DDLActionCategory, `n
}
 
;-------------------------------------------------------------------------------
; Regisger Action to Template
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_AddActionTemplate(category, name, script)
{
global
if (!MG_IsEdit) {
return
}
ActionCategory1_Count++
ActionTitle1_%ActionCategory1_Count% := name
ActionTemplate1_%ActionCategory1_Count% := script
 
local idx := GetActionCategoryIdx(category)
if (!idx) {
MG_AddActionCategory(category)
idx := (category = "Others") ? "Temp" : ActionCategory_Count
}
ActionCategory%idx%_Count++
local cnt := ActionCategory%idx%_Count
ActionTitle%idx%_%cnt% := name
ActionTemplate%idx%_%cnt% := script
}
 
;-------------------------------------------------------------------------------
; Get Action Category Index by Key
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
GetActionCategoryIdx(key)
{
global
if *3 {
szFileName := "English.ahk"
}
Goto MGW_LangApply
}
; Retrieving name of the stored language files
iSel := 0
szDDL := ""
objFileList := []
Loop, %MG_DirLang%*.ahk
{
if (A_LoopFileName != "MG_Language.ahk") {
objFileList.InsertAt(A_Index, A_LoopFileName)
szFileName := RegExReplace(A_LoopFileName, ".ahk")
if (szFileName = MG_Language) {
iSel := A_Index
}
szDispName := ""
file := FileOpen(A_LoopFileFullPath, "r", "UTF-8")
if (file) {
szBuf := file.Read(file.Length)
file.Close
if (RegExMatch(szBuf, "m)^.*MC_LanguageName.*=(.+).*$", $)) {
szDispName := $1
}
}
if (szDispName == "") {
szDispName := szFileName
}
szDDL .= szDispName . "|"
}
}
; Choose Language dialog box
Gui, MGW_Lng:New
Gui, MGW_Lng:-MaximizeBox -MinimizeBox +HWNDhWnd
Gui, MGW_Lng:Add, Text, x10 y10, Choose your language:
Gui, MGW_Lng:Add, DropDownList, VddlLang xp+0 y+10 w180 AltSubmit, %szDDL%
Gui, MGW_Lng:Add, Button, gOnLngSelected x+-168 y+10 w80 Default, OK
Gui, MGW_Lng:Add, Button, gOnLngCanceled x+8 yp+0 w80, &Cancel
GuiControl, MGW_Lng:Choose, ddlLang, %iSel%
Gui, MGW_Lng:Show, , Choose Language
 
WinWaitClose, ahk_id %hWnd%
return
 
;---------------------------------------------------------------------------
; Selected
OnLngSelected:
GuiControlGet, iSel, MGW_Lng:, ddlLang
szFileName := objFileList[iSel]
Loop, % objFileList.MaxIndex() {
objFileList.RemoveAt(A_Index)
}
MGW_LangApply:
file := FileOpen(MG_DirLang . szFileName, "r", "UTF-8")
if (file) {
szBuf := file.Read(file.Length)
file.Close
if (!RegExMatch(szBuf, "m)^[\s\t]*MG_Language\s*:=\s*RegExReplace"))
{
MsgBox, ERROR : Language file is invalid.
Goto, OnLngCanceled
}
file := FileOpen(MG_DirConfig "MG_Language.ahk", "w `n", "UTF-8")
if (!file) {
MsgBox, ERROR : Failed in file writing.
Goto, OnLngCanceled
}
file.Write("#" . "Include %A_ScriptDir%\Languages\" . szFileName . "`n")
file.Close
FileDelete, %MG_DirLang%MG_Language.ahk
}
Reload
 
;---------------------------------------------------------------------------
; Canceled
OnLngCanceled:
MGW_LngGuiClose:
MGW_LngGuiEscape:
if (fChoose) {
Gui, MGW_Lng:Destroy
return
} else {
ExitApp
}
}
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Plugins
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Search Plugins
; return=1 : Plugin Include Script has been Updated
; return=0 : Plugin Include Script has Not been Changed
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SearchPlugins()
{
local szInc, szCur, file
;...........................................................................
; Search Plugin Script Files
szInc := ""
Loop, %MG_DirPlugins%*.ahk
{
if (A_LoopFileName != "MG_Plugin.ahk")
{
szInc .= "#" . "Include *i %A_ScriptDir%\Plugins\" . A_LoopFileName . "`n"
}
}
if (szInc == "") {
return 0
}
;...........................................................................
; Check if Plugin Files are Added or Removed
file := FileOpen(MG_DirConfig "MG_Plugins.ahk", "r `n", "UTF-8")
if (!file) {
file := FileOpen(MG_DirPlugins "MG_Plugin.ahk", "r `n", "UTF-8")
}
if (file)
{
szCur := file.Read(file.Length)
file.Close
if (szCur == szInc) {
return 0
}
}
;...........................................................................
; Write Plugin Include Script
file := FileOpen(MG_DirConfig "MG_Plugins.ahk", "w `n", "UTF-8")
if (!file) {
return 0
}
file.Write(szInc)
file.Close
FileDelete, %MG_DirPlugins%MG_Plugin.ahk
return 1
}
 
;-------------------------------------------------------------------------------
; Regisger Plugin Menu
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_AddPluginMenu(szName="", szCommand="")
{
global
if (MG_IsEdit) {
return
}
MG_PluginMenuCount++
MG_PluginMenu%MG_PluginMenuCount%_Name   := szName
MG_PluginMenu%MG_PluginMenuCount%_Command := szCommand
}
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Gesture pattern rendering functions
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Create Font
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CreateFont(szFace, nSize, nWeight=0, nQuality=0)
{
local nHeight := -(nSize * MG_ScreenDPI // 72)
 
return DllCall("CreateFont"
,"Int",nHeight ; nHeight
,"Int",0 ; nWidth
,"Int",0 ; nEscapement
,"Int",0 ; nOrientation
,"Int",nWeight ; nWeight
,"UInt",0 ; fdwItalic
,"UInt",0 ; fdwUnderline
,"UInt",0 ; fdwStrikeOut
,"UInt",(szFace="Wingdings" ? 2 : 1) ; fdwCharset
,"UInt",0 ; fdwOutPrecision
,"UInt",0 ; fdwClipPrecision
,"UInt",nQuality ; fdwQuality
,"UInt",0 ; fdwPitchAndFamily
,"Str",szFace ; pszFaceName
,"Ptr")
}
 
;-------------------------------------------------------------------------------
; Draw Gesture Pattern
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_DrawGesture(hDC, ptX, ptY, szGesture, ByRef strW=0, ByRef strH=0, fMeasure=0, nGesLen=0)
{
global MG_BtnNames, MG_AdNaviNI2, MG_hFntBtn, MG_hFntDir, MG_AdNaviSize
static DirD:=0xEA, DirL:=0xE7, DirR:=0xE8, DirU:=0xE9
static Dir1:=0xED, Dir2:=0xEA, Dir3:=0xEE, Dir4:=0xE7, Dir6:=0xE8, Dir7:=0xEB, Dir8:=0xE9, Dir9:=0xEC
 
if (!fMeasure) {
hRgn := DllCall("CreateRectRgn", "Int",ptX, "Int",ptY, "Int",ptX+strW, "Int",ptY+strH, "Ptr")
DllCall("SelectClipRgn", "Ptr",hDC, "Ptr",hRgn)
}
hFntOld := DllCall("SelectObject", "Ptr",hDC, "Ptr",MG_hFntBtn, "Ptr")
VarSetCapacity(size, 8, 0)
max:=StrLen(szGesture), pos:=1, preFont:=1, nowX:=ptX, strH:=0
nHeight := MG_AdjustToDPI(MG_AdNaviSize)
while (pos <= max)
{
if (SubStr(szGesture, pos, 1) == "_") {
newFont := 1
szDraw := "_"
offset := 1
shift := fDown ? 0 : -nHeight*5//4
fDown := 0
}
else {
shift := 0
fDown := 0
Loop, % MG_BtnNames.MaxIndex() {
if (MG_BtnNames[A_Index] && InStr(SubStr(szGesture, pos), MG_BtnNames[A_Index]) == 1) {
newFont := 1
szDraw := MG_BtnNames[A_Index]
offset := StrLen(MG_BtnNames[A_Index])
fDown := 1
break
}
}
if (!fDown) {
newFont := 2
dir := "Dir" . SubStr(szGesture, pos, 1)
szDraw := Chr(%dir%)
offset := 1
shift := nHeight//4
shift -= (dir="DirU"||dir="Dir8") ? nHeight//6 : 0
shift += (dir="DirD"||dir="Dir2") ? nHeight//6 : 0
}
}
if (preFont != newFont) {
preFont := newFont
DllCall("SelectObject", "Ptr",hDC, "Ptr",(newFont==1 ? MG_hFntBtn : MG_hFntDir))
}
if (!fMeasure) {
DllCall("TextOut", "Ptr",hDC, "Int",nowX, "Int",ptY+shift, "Str",szDraw, "Int",StrLen(szDraw))
}
DllCall("GetTextExtentPoint32", "Ptr",hDC, "Str",szDraw, "Int",StrLen(szDraw), "Ptr",&size)
nowX += NumGet(size, 0, "UInt")
h := NumGet(size, 4, "UInt")
if (h > strH) {
strH := h
}
pos += offset
if (pos == nGesLen+1) {
DllCall("SetTextColor", "Ptr",hDC, "UInt",MG_AdNaviNI2)
}
}
strW := nowX - ptX
DllCall("SelectObject", "Ptr",hDC, "Ptr",hFntOld)
if (!fMeasure) {
DllCall("SelectClipRgn", "Ptr",hDC, "Ptr",0)
DllCall("DeleteObject", "Ptr",hRgn)
}
}
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; General functions
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Combine strings with delimiter
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
Join(ByRef list, value, delim="`n") {
list := list ? (list . delim . value) : value
return list
}
 
;-------------------------------------------------------------------------------
; Replace Variables in String
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_VarInStr(str) {
out := str
while (RegExMatch(out, ".*%(.+?)%.*", $)) {
out := RegExReplace(out, "%" $1 "%", %$1%)
}
return out
}
 
;-------------------------------------------------------------------------------
; Check whether the operating system is recent one
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_IsNewOS() {
return (A_OSVersion!="WIN_NT4" && A_OSVersion!="WIN_2000"
&& A_OSVersion!="WIN_XP"  && A_OSVersion!="WIN_2003")
}
 
;-------------------------------------------------------------------------------
; Call specified function if it is needed
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CallIfUsed(func, conditions, param:="")
{
local file, buf, pos
if (file := FileOpen(MG_DirConfig "MG_Config.ahk", "r", "UTF-8")) {
buf := file.Read(file.Length)
file.Close
if (RegExMatch(buf, conditions)) {
Func(func).(param)
}
}
}
 
;-------------------------------------------------------------------------------
; Execute a program as normal user
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_RunAsUser(szTarget, szWorkDir="", szWinStat="", bWait=false)
{
szTarget := MG_VarInStr(szTarget)
szWorkDir := MG_VarInStr(szWorkDir)
if (A_IsAdmin && MG_IsNewOS()) {
if (MG_CreateProcessAsUser(szTarget, szWorkDir, szWinStat, bWait)) {
return
}
}
if (bWait) {
RunWait, %szTarget%, %szWorkDir%, % szWinStat . " UseErrorLevel"
} else {
Run, %szTarget%, %szWorkDir%, % szWinStat . " UseErrorLevel"
}
}
 
;-------------------------------------------------------------------------------
; Create process as normal user
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CreateProcessAsUser(szTarget, szWorkDir="", szWinStat="", bWait=false)
{
; Get process handle of the shell
local hProc:=0, hWnd:=0, pid:=0
WinGet, hWnd, ID, Program Manager ahk_class Progman
if (hWnd) {
WinGet, pid, PID, % "ahk_id " hWnd
hProc := DllCall("OpenProcess", UInt,0x0400 , UInt,1, UInt,pid, Ptr)
}
if (!hProc) {
return false
}
; Duplicate user token
local res, htkUser:=0, htkCopy:=0
VarSetCapacity(htkUser, A_PtrSize, 0)
VarSetCapacity(htkCopy, A_PtrSize, 0)
res := DllCall("advapi32.dll\OpenProcessToken", Ptr,hProc, UInt,0x000E, PtrP,htkUser, UInt)
DllCall("CloseHandle", Ptr,hProc)
if (!res) {
return false
}
res := DllCall("advapi32.dll\DuplicateTokenEx", Ptr,htkUser, UInt,0x02000000, Ptr,0, Int,3, Int,1, PtrP,htkCopy, UInt)
DllCall("CloseHandle", Ptr,htkUser)
if (!res || !htkCopy) {
return false
}
; Create process with user token
local size, sinfo, pinfo, stat, ofs
size := 4*9 + 2*2 + A_PtrSize*7 + (A_PtrSize//8*4)
VarSetCapacity(sinfo, size, 0)
NumPut(size, sinfo, 0, "UInt")
ofs := 4*8 + A_PtrSize*3 + (A_PtrSize//8*4)
NumPut(1, sinfo, ofs, "UInt")
stat := (szWinStat="Max") ? 3
: (szWinStat="Min") ? 7
: (szWinStat="Hide") ? 0 : 1
ofs += 4
NumPut(stat, sinfo, ofs, "UShort")
 
size := 4*2 + A_PtrSize*2
VarSetCapacity(pinfo, size, 0)
pid := 0
szWorkDir := szWorkDir ? szWorkDir : A_ScriptDir
if (DllCall("advapi32.dll\CreateProcessWithTokenW", Ptr,htkCopy, UInt,0, Ptr,0, Str,szTarget
,UInt,0x00000400, Ptr,0, Str,szWorkDir, Ptr,&sinfo, Ptr,&pinfo, UInt)) {
DllCall("CloseHandle", Ptr,NumGet(pinfo, A_PtrSize, "Ptr"))
DllCall("CloseHandle", Ptr,NumGet(pinfo, 0, "Ptr"))
ofs := A_PtrSize * 2
pid := NumGet(pinfo, ofs, "UInt")
}
DllCall("CloseHandle", Ptr,htkCopy)
if (!pid) {
return false
}
if (bWait) {
DetectHiddenWindows, On
WinWait, % "ahk_pid " pid
WinWaitClose, % "ahk_pid " pid
DetectHiddenWindows, Off
}
return true
}
 
;-------------------------------------------------------------------------------
; Get monitor rectangle that includes specified coordinates
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_GetMonitorRect(ptX, ptY, ByRef monL=0, ByRef monT=0, ByRef monR=0, ByRef monB=0, fWork=false)
{
pt := (ptY<<32) | (ptX & 0xffffffff)
hMon := DllCall("MonitorFromPoint", "UInt64",pt, "UInt",2, "Ptr")
VarSetCapacity(infMon, 40, 0)
NumPut(40, infMon, 0, "UInt")
res := DllCall("GetMonitorInfo", "Ptr",hMon, "Ptr",&infMon, "UInt")
offset := fWork ? 20 : 4
monL := NumGet(infMon, offset+ 0, "Int")
monT := NumGet(infMon, offset+ 4, "Int")
monR := NumGet(infMon, offset+ 8, "Int")
monB := NumGet(infMon, offset+12, "Int")
}
 
;-------------------------------------------------------------------------------
; Adjust size value to screen DPI
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_AdjustToDPI(size, dpiNew=0, dpiBase=0) {
global MG_ScreenDPI
if (dpiNew == 0) {
dpiNew := MG_ScreenDPI
}
if (dpiBase == 0) {
dpiBase := 96
}
return size * dpiNew // dpiBase
}
 
;-------------------------------------------------------------------------------
; Get screen DPI from cursor position
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_GetDpiFromPoint(x, y)
{
pt := (y<<32) | (x & 0xffffffff)
hMon := DllCall("MonitorFromPoint", UInt64,pt, UInt,1, Ptr)
VarSetCapacity(dpiX, 4, 0)
VarSetCapacity(dpiY, 4, 0)
DllCall("Shcore.dll\GetDpiForMonitor", UPtr,hMon, Int,0, IntP,dpiX, IntP,dpiY)
return dpiX ? dpiX : A_ScreenDPI
}
 
;-------------------------------------------------------------------------------
; Get screen DPI from specified window
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_GetDpiFromWindow(hWnd:=0)
{
global MG_HWND
if (!hWnd) {
hWnd := MG_HWND
}
hMon := DllCall("MonitorFromWindow", Ptr,hWnd, UInt,2, Ptr)
VarSetCapacity(dpiX, 4, 0)
VarSetCapacity(dpiY, 4, 0)
DllCall("Shcore.dll\GetDpiForMonitor", UPtr,hMon, Int,0, IntP,dpiX, IntP,dpiY)
return dpiX
}
 
;-------------------------------------------------------------------------------
; Get module filename from window handle
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_GetExeName(hWnd, bPath=false)
{
local szExe, hChild
 
WinGet, szExe, ProcessName, ahk_id %hWnd%
if (szExe = "ApplicationFrameHost.exe") {
hChild := DllCall("FindWindowExW", Ptr,hWnd, Ptr,0, Str,"Windows.UI.Core.CoreWindow", Ptr,0, Ptr)
if (hChild) {
hWnd := hChild
}
}
if (bPath) {
WinGet, szExe, ProcessPath, ahk_id %hWnd%
} else {
WinGet, szExe, ProcessName, ahk_id %hWnd%
}
return szExe
}
 
;-------------------------------------------------------------------------------
; Check whether specified window is activation target
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_IsActivationTarget(hWnd, bIncRegWnd:=true)
{
local dwStyle, dwExStyle, szTitle, szClass
 
WinGet, dwStyle, Style, ahk_id %hWnd%
WinGet, dwExStyle, ExStyle, ahk_id %hWnd%
if *4 {
return false
}
}
return true
}
 
;-------------------------------------------------------------------------------
; Wait Error Message
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
CheckConfigurationError()
{
global MC_LngButton001, MC_LngButton002, MC_LngMessage002
WinWait, MouseGestureL.ahk ahk_class #32770, Error
if (ErrorLevel==0) {
ControlGetText, szMsg1, Static1
ControlGetText, szMsg2, Static2
WinClose
Gui, MGW_Err:New
Gui, MGW_Err:+HWNDhWnd
Gui, MGW_Err:Add, Text, x10 y10, % MC_LngMessage002 . szMsg1 . szMsg2
Gui, MGW_Err:Add, Button, gOnSendClipboard x+-250 y+16 w160 h26, %MC_LngButton002%
Gui, MGW_Err:Add, Button, gOnMsgClosed x+10 yp+0 w80 h26, %MC_LngButton001%
Gui, MGW_Err:Show, ,
WinWaitClose, ahk_id %hWnd%
}
return
 
;---------------------------------------------------------------------------
; Copy to Clipboard
OnSendClipboard:
Clipboard := szMsg1 . szMsg2
Gui, MGW_Err:Destroy
return
 
;---------------------------------------------------------------------------
; Canceled
OnMsgClosed:
MGW_ErrGuiClose:
MGW_ErrGuiEscape:
Gui, MGW_Err:Destroy
return
}
 
MG_CommonLibEnd:

 

*1:Target_%iTarget%_%A_Index%_Type  = szType)

&& (Target_%iTarget%_%A_Index%_Value = szValue

*2:Target_%idx%_Name == A_LoopField)

&& (Target_%idx%_Level == lv

*3:key = "Others") && ActionCategoryTemp_Key) {

return "Temp"
}
Loop, %ActionCategory_Count%
{
if (key = ActionCategory%A_Index%_Key) {
return A_Index
}
}
return 0
}
 
;-------------------------------------------------------------------------------
; Add Action Script
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_AddActionScript(szScript, szDesc="", pos="")
{
global
if (szDesc) {
szScript := ";" . szDesc . "`n" . szScript
} else {
szScript := ";" ActionTitle%DDLActionCategory%_%DDLActionTemplate% . szDesc "`n" szScript
}
Gui, MEW_Main:Submit, NoHide
if (pos = "top") {
EAction := szScript "`n" EAction
} else {
Join(EAction, szScript)
}
GuiControl, MEW_Main:, EAction, %EAction%
MG_SaveModificationObj.("Modified", "EAction")
}
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Languages
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Check and Select Language
; fChoose : 0 = Determine whether language module has been included
;   1 = Show "Choose Language" dialog box
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CheckLanguage(fChoose=0)
{
local szFileName, szDispName, szDDL, szBuf, objFileList, iLng, iSel, file, hWnd
static tblLang := [ [ "Japanese.ahk", "0411" ]
   , [ "Chinese.ahk" , "0804", "0C04", "1004", "0404" ] ]
 
; Create Config folder
if (FileExist(MG_DirConfig) != "D") {
FileCreateDir, %MG_DirConfig%
}
; Determination whether language module has been included
if (!fChoose) {
if (MG_Language) {
return
}
; MG_Language.ahk does not exist -> Select language automatically by LCID
szFileName := ""
MG_ChkLngLoop:
Loop, % tblLang.MaxIndex() {
iLng := A_Index
Loop, % tblLang[iLng].MaxIndex()-1 {
if (A_Language = tblLang[iLng][A_Index+1]) {
szFileName := tblLang[iLng][1]
break MG_ChkLngLoop
}
}
}
if (!szFileName || !FileExist(MG_DirLang . szFileName

*4:dwStyle&0x08000000) || !(dwStyle&0x10000000) || (dwExStyle&0x00000080)

|| ((dwStyle&0x80000000) && !(dwStyle&0x20C80000))) {
return false
}
WinGetClass, szClass, ahk_id %hWnd%
if (szClass = "TApplication") {
return false
}
if (!bIncRegWnd) {
return true
}
Loop, % MG_ActvtExclud.MaxIndex()
{
szTitle := MG_ActvtExclud[A_Index][1]
szTitle .= MG_ActvtExclud[A_Index][2] ? " ahk_class " MG_ActvtExclud[A_Index][2] : ""
szTitle .= MG_ActvtExclud[A_Index][3] ? " ahk_exe " MG_ActvtExclud[A_Index][3] : ""
if (hWnd = WinExist(szTitle

Japanese.ahk

;===============================================================================
;
; MouseGestureL.ahk - Language Definition Module
; << 日本語 >>
; Created by Pyonkichi
;===============================================================================
;-------------------------------------------------------------------------------
; 共通文字列定義
;-------------------------------------------------------------------------------
; 言語名
MC_LanguageName = 日本語
 
; ヘルプファイル
MC_HelpFile = MouseGestureL_JPN.chm
 
; ボタン
MC_LngButton001 = 閉じる
MC_LngButton002 = クリップボードへコピー
 
; メッセージ
MC_LngMessage001 = ヘルプファイルが見つかりません。
MC_LngMessage002 =
(LTrim
設定に問題があるようです。
下記のエラーメッセージから問題箇所を特定し、設定画面より修正を行ってください。
エラーの原因を特定できない場合は、バックアップより設定ファイルの復旧を行ってください。
----------------------------------------------------------------------`n`n
)
 
if (MG_IsEdit) {
Goto SetEdit
}
;-------------------------------------------------------------------------------
; アプリケーション用文字列定義
;-------------------------------------------------------------------------------
; メニュー
MG_LngMenu001 = AutoHotkey(&K)
MG_LngMenu002 = ジェスチャー有効(&E)
MG_LngMenu003 = ナビ表示(&G)
MG_LngMenu004 = 設定(&C)...
MG_LngMenu005 = 拡張スクリプト編集(&U)
MG_LngMenu006 = 操作ログをコピー(&P)
MG_LngMenu007 = プラグインフォルダを開く(&O)
MG_LngMenu008 = プラグイン(&P)
MG_LngMenu009 = 言語(&L)...
MG_LngMenu010 = ヘルプ(&H)
MG_LngMenu011 = バージョン情報(&A)
MG_LngMenu012 = 再起動(&R)
MG_LngMenu013 = 終了(&X)
MG_LngMenu014 = マウスジェスチャー(&M)
 
MG_LngTooltip001 = ジェスチャー有効
MG_LngTooltip002 = ジェスチャー無効
MG_LngTooltip003 = ナビON
MG_LngTooltip004 = ナビOFF
 
; その他文字列
MG_LngOthers001 =
(LTrim
;===============================================================================
;
;
; ・起動時の初期化処理や、ジェスチャー実行時に呼び出されるサブルーチン、
;  関数などを定義できます。
; ・設定画面内の各種リストのサイズなども変更できます。
; ・内容を書き換えた場合はスクリプトをリロードしてください。
;
;===============================================================================
 
)
MG_LngOthers002 = ユーザー定義の初期化処理
MG_LngOthers003 = ユーザー定義関数、サブルーチン
MG_LngOthers004 = MouseGestureL.ahk
MG_LngOthers005 = MG_Edit.ahk
MG_LngOthers006 = MouseGestureL.ahk、MG_Edit.ahk共通
MG_LngOthers007 = MouseGestureL.ahkの初期化処理完了後に実行したい処理を以下に記述
MG_LngOthers008 = MG_Edit.ahkの初期化処理完了後に実行したい処理を以下に記述
 
Goto EndLanguage
 
;-------------------------------------------------------------------------------
; MG_Edit用文字列定義
;-------------------------------------------------------------------------------
SetEdit:
 
; トリガー操作
Button_LB = 左ボタン
Button_RB = 右ボタン
Button_MB = 中央ボタン
Button_X1B = 第4ボタン
Button_X2B = 第5ボタン
Button_WU = ホイール上回転
Button_WD = ホイール下回転
Button_LT = 左チルト
Button_RT = 右チルト
Button_ET = 画面上端に接触(全体)
Button_ETA = 画面上端に接触(左半分)
Button_ETB = 画面上端に接触(右半分)
Button_ET1 = 画面上端に接触(左1/3)
Button_ET2 = 画面上端に接触(中央1/3)
Button_ET3 = 画面上端に接触(右1/3)
Button_EB = 画面下端に接触(全体)
Button_EBA = 画面下端に接触(左半分)
Button_EBB = 画面下端に接触(右半分)
Button_EB1 = 画面下端に接触(左1/3)
Button_EB2 = 画面下端に接触(中央1/3)
Button_EB3 = 画面下端に接触(右1/3)
Button_EL = 画面左端に接触(全体)
Button_ELA = 画面左端に接触(上半分)
Button_ELB = 画面左端に接触(下半分)
Button_EL1 = 画面左端に接触(上1/3)
Button_EL2 = 画面左端に接触(中央1/3)
Button_EL3 = 画面左端に接触(下1/3)
Button_ER = 画面右端に接触(全体)
Button_ERA = 画面右端に接触(上半分)
Button_ERB = 画面右端に接触(下半分)
Button_ER1 = 画面右端に接触(上1/3)
Button_ER2 = 画面右端に接触(中央1/3)
Button_ER3 = 画面右端に接触(下1/3)
Button_CRT = 画面右上角に接触
Button_CLT = 画面左上角に接触
Button_CRB = 画面右下角に接触
Button_CLB = 画面左下角に接触
 
; アクションの種類
ActionType001 = 全て
ActionType002 = 入力エミュレーション
ActionType003 = スクロール
ActionType004 = ウィンドウ制御
ActionType005 = プロセス制御
ActionType006 = アプリケーション制御
ActionType007 = サウンド制御
ActionType008 = スクリプト制御
ActionType009 = ナビ・軌跡
ActionType010 = 同クラスのウィンドウの一括制御
ActionType100 = その他
 
; アクション名
ActionName001 = キー操作を発生させる
ActionName002 = マウスクリックを発生させる
ActionName003 = ホイール回転を発生させる
ActionName004 = カーソルを移動
ActionName011 = スクロール
ActionName012 = ドラッグスクロール
ActionName021 = ウィンドウをアクティブ化
ActionName022 = ウィンドウを最小化
ActionName023 = ウィンドウを最大化
ActionName024 = ウィンドウを元の状態に戻す
ActionName025 = ウィンドウを閉じる
ActionName026 = ウィンドウを最背面に送る
ActionName027 = ウィンドウを最前面化する
ActionName028 = ウィンドウの最前面化を解除
ActionName029 = ウィンドウの最前面化/解除の切り替え
ActionName030 = ウィンドウの位置とサイズを変更
ActionName031 = ウィンドウの透明度を変更
ActionName032 = ウィンドウの半透明化を解除
ActionName033 = 以前のアクティブウィンドウを復元
ActionName034 = ウィンドウを移動
ActionName041 = 同クラスのウィンドウを全て最小化
ActionName042 = 同クラスのウィンドウを全て閉じる
ActionName043 = 同クラスのウィンドウを等間隔に並べる
ActionName051 = プログラムを起動
ActionName052 = プロセスを強制終了
ActionName061 = ツールバーボタンのコマンドを実行
ActionName062 = メニューバーのコマンドを実行
ActionName071 = ボリューム変更
ActionName072 = 音声のミュート
ActionName073 = サウンドを再生
ActionName081 = ジェスチャーの認識を打ち切る
ActionName082 = 追加ジェスチャーの入力を待つ
ActionName083 = 時間待ち
ActionName084 = 指定時間の経過後に実行
ActionName085 = 指定時間の経過後にボタンを放したら実行
ActionName086 = ボタンを放すまで繰り返す
ActionName087 = ジェスチャーの認識終了後に実行
ActionName088 = 他のアクションが未発動の場合に実行
ActionName089 = ボタンリリース時のデフォルト動作を実行
ActionName090 = ボタンリリース時のデフォルト動作をキャンセル
ActionName091 = タイムアウトを無効にする
ActionName092 = ジェスチャーの入力状態を保存
ActionName093 = アクティブウィンドウをターゲットにする
ActionName101 = ナビの表示を停止
ActionName102 = ナビの表示を再開
ActionName103 = 軌跡の表示を停止
ActionName104 = 軌跡の表示を再開
ActionName105 = ツールチップナビに文字列を表示
ActionName901 = クリップボードに文字列をコピー
ActionName902 = PostMessage
ActionName903 = SendMessage
 
; アクションコメント
ActionComment001 = ジェスチャー入力直後の動作
ActionComment002 = 指定時間経過後の動作
ActionComment003 = ボタンを押している間繰り返す動作
ActionComment004 = ボタンを放したときの動作
ActionComment005 = 指定時間の経過後にボタンを放したときの動作
ActionComment006 = ジェスチャーの認識終了後に実行する動作
ActionComment007 = 他のアクションが未発動の場合に実行する動作
ActionComment011 = ###REPLACE###を押す
ActionComment012 = ###REPLACE###を押し続ける
ActionComment013 = ###REPLACE###を放す
ActionComment014:=" (###REPLACE###回)"
ActionComment021 = ###REPLACE###クリック
ActionComment022 = ###REPLACE###を押す
ActionComment023 = ###REPLACE###を放す
ActionComment031 = ホイール↑回転
ActionComment032 = ホイール↓回転
ActionComment033:=" (###REPLACE###ステップ)"
ActionComment041 = ジェスチャー入力開始位置へカーソルを移動
ActionComment042 = ジェスチャー入力開始位置から ###REPLACE### へカーソルを移動
ActionComment043 = ジェスチャー入力完了位置から ###REPLACE### へカーソルを移動
ActionComment044 = 現在位置から ###REPLACE### へカーソルを移動
ActionComment045 = ###REPLACE### へカーソルを移動
ActionComment051 = 上ページスクロール
ActionComment052 = 下ページスクロール
ActionComment053 = 左ページスクロール
ActionComment054 = 右ページスクロール
ActionComment055:=" (###REPLACE###行)"
ActionComment056:=" (###REPLACE###ページ)"
ActionComment061 = ウィンドウ位置/サイズ変更 (###REPLACE###)
ActionComment062 = ウィンドウを###REPLACE###へ移動
ActionComment071 = 同クラスのウィンドウを縦等間隔に並べる
ActionComment072 = 同クラスのウィンドウを横等間隔に並べる
ActionComment073 = 同クラスのウィンドウをタイル状に並べる
 
; ダイアログBOXのキャプション
ME_LngCapt001 = MouseGestureL
ME_LngCapt002 = MouseGestureL 設定
ME_LngCapt003 = 削除確認
ME_LngCapt004 = 上書き確認
ME_LngCapt005 = トリガーボタンの定義
ME_LngCapt006 = スクリプトエディタの指定
ME_LngCapt007 = トリガー操作別の矢印色
ME_LngCapt008 = 矩形領域設定
ME_LngCapt009 = タスク切り替え時に除外するウィンドウ
ME_LngCapt010 = タスクリスト
ME_LngCapt011 = アクションの追加
ME_LngCapt012 = キー入力
ME_LngCapt013 = キーストローク直接編集
ME_LngCapt014 = マウスクリックの設定
ME_LngCapt015 = ホイール回転の設定
ME_LngCapt016 = カーソル移動の設定
ME_LngCapt017 = スクロールの設定
ME_LngCapt018 = ドラッグスクロールの設定
ME_LngCapt019 = ウィンドウ位置とサイズの設定
ME_LngCapt020 = ウィンドウ移動先の設定
ME_LngCapt022 = 実行ファイルの指定
ME_LngCapt023 = サウンドファイルの指定
ME_LngCapt024 = 送信メッセージの設定
ME_LngCapt025 = アイコンファイルの選択
ME_LngCapt026 = 同クラスのウィンドウを全て最小化
ME_LngCapt027 = 同クラスのウィンドウを全て閉じる
ME_LngCapt028 = 同クラスのウィンドウを等間隔に並べる
 
; タブ
ME_LngTab001 = メイン`nターゲット`nジェスチャー`n認識設定`nナビ`n軌跡・ログ`nその他
 
; メニュー
ME_LngMenu000 = (なし)
ME_LngMenu001 = ウィンドウの部位
ME_LngMenu002 = タイトルバー
ME_LngMenu003 = タイトルバーのアイコン
ME_LngMenu004 = 最小化ボタン
ME_LngMenu005 = 最大化ボタン
ME_LngMenu006 = 閉じるボタン
ME_LngMenu007 = ヘルプボタン
ME_LngMenu008 = メニューバー
ME_LngMenu009 = 縦スクロールバー
ME_LngMenu010 = 横スクロールバー
ME_LngMenu011 = 枠
ME_LngMenu012 = リサイズ可能な枠
ME_LngMenu013 = その他の領域
ME_LngMenu014 = ツリー/リストの項目上
ME_LngMenu015 = マウスカーソル
ME_LngMenu016 = 通常(矢印)
ME_LngMenu017 = 縦線(テキスト欄など)
ME_LngMenu018 = 指(リンクなど)
ME_LngMenu019 = 砂時計
ME_LngMenu020 = 十字
ME_LngMenu021 = 禁止
ME_LngMenu022 = 矢印+砂時計
ME_LngMenu023 = 矢印+疑問符
ME_LngMenu024 = 4方向矢印
ME_LngMenu025 = 上下矢印
ME_LngMenu026 = 左右矢印
ME_LngMenu027 = \矢印
ME_LngMenu028 = /矢印
ME_LngMenu029 = 垂直矢印
ME_LngMenu030 = 上記標準カーソルのどれか
ME_LngMenu031 = 不明(ソフト固有など)
ME_LngMenu032 = ウィンドウ状態
ME_LngMenu033 = 最大化
ME_LngMenu034 = 通常
ME_LngMenu035 = 半透明
ME_LngMenu036 = 不透明
ME_LngMenu037 = 最前面
ME_LngMenu038 = 非最前面
ME_LngMenu039 = キーボード状態
ME_LngMenu040 = Shiftキー押し下げ
ME_LngMenu041 = Shiftキー非押し下げ
ME_LngMenu042 = Ctrlキー押し下げ
ME_LngMenu043 = Ctrlキー非押し下げ
ME_LngMenu044 = Altキー押し下げ
ME_LngMenu045 = Altキー非押し下げ
ME_LngMenu046 = 矩形領域判定
ME_LngMenu047 = ウィンドウ相対座標
ME_LngMenu048 = スクリーン絶対座標
ME_LngMenu049 = 画面端接触認識
ME_LngMenu050 = 新しいボタンを作成
ME_LngMenu101 = ターゲットの設定(&T) Enter
ME_LngMenu102 = 新規ターゲット(&N) Ctrl+N
ME_LngMenu103 = サブターゲットを追加(&S)
ME_LngMenu104 = ジェスチャーを追加(&A)
ME_LngMenu105 = 削除(&D) Delete
ME_LngMenu106 = 複製(&P) Ctrl+D
ME_LngMenu107 = クリップボードへコピー(&C) Ctrl+C
ME_LngMenu108 = クリップボードからインポート(&I) Ctrl+V
ME_LngMenu109 = 上へ移動(&U) Shift+↑
ME_LngMenu110 = 下へ移動(&O) Shift+↓
ME_LngMenu111 = 名前順で並べ替え(&R)
ME_LngMenu112 = サブターゲットを折りたたむ(&F) Ctrl+F
ME_LngMenu113 = ジェスチャーの割り当て(&G) Enter
ME_LngMenu121 = 新規ジェスチャーを定義(&N)
ME_LngMenu122 = ジェスチャーの設定(&G) Enter
ME_LngMenu123 = 他のジェスチャーに変更(&C)
ME_LngMenu124 = 他のターゲットへコピー(&T)
ME_LngMenu125 = アクションをテキストエディタで編集(&E) Ctrl+Enter
ME_LngMenu141 = 新規ジェスチャー(&N) Ctrl+N
ME_LngMenu142 = 編集...(&E)
ME_LngMenu151 = ターゲットの変更(&T)
 
; スタティックテキスト
ME_LngText001 = ターゲット:
ME_LngText002 = ジェスチャー:
ME_LngText003 = ターゲットの優先順位:
ME_LngText004 = アクションスクリプト:
ME_LngText005 = カテゴリ:
ME_LngText006 = アクション:
ME_LngText011 = 名称:
ME_LngText012 = 種別:
ME_LngText013 = 値:
ME_LngText014 = 判定方法:
ME_LngText021 = トリガー操作:
ME_LngText022 = カーソル移動:
ME_LngText023 = 説明:
ME_LngText024 = ボタン名:
ME_LngText025 = キー文字列:
ME_LngText026 = デフォルトアクション:
ME_LngText027 = 高
ME_LngText028 = 低
ME_LngText029 = ジェスチャーパターンの末尾は特殊な設定をする場合を除き、アンダースコア " _ " で閉じてください。`n末尾のアンダースコアはマウスボタンの解放を意味し、「ボタンを放す」ボタンを押すと付加されます。`n`n`t【×】   ###REPLACE###`n`t【〇】   ###REPLACE###_`n`n仕様を理解した上で意図的に定義したジェスチャーであれば、この警告は無視してください。
ME_LngText100 = ジェスチャー認識処理の間隔 (ms):
ME_LngText101 = 通常ストローク:
ME_LngText102 = 4方向モードの「LL」「RR」:
ME_LngText103 = 4方向モードの「UU」「DD」:
ME_LngText104 = 8方向モードの長距離ストローク:
ME_LngText105 = 第1ストローク:
ME_LngText106 = 縦横移動の後:
ME_LngText107 = 斜め移動の後:
ME_LngText108 = ジェスチャータイムアウト判定を開始するカーソル移動量:
ME_LngText109 = ボタンを押している間に認識が打ち切られるまでの時間 (ms):`n( 0 でタイムアウトなし )
ME_LngText110 = ボタンを放した後に追加ジェスチャーの入力を許容する時間 (ms):
ME_LngText111 = 接触認識処理の間隔 (ms):
ME_LngText112 = コーナーの認識範囲:
ME_LngText113 = 横:
ME_LngText114 = 縦:
ME_LngText115 = タイムアウト後にトリガーボタンを強制解放するまでの時間 (秒):`n( 0 で強制解放処理を無効化 )
ME_LngText200 = ナビの種類:
ME_LngText201 = 表示更新間隔 (ms):
ME_LngText202 = ナビが消えるまでの時間 (ms):
ME_LngText203 = 矢印の色 (RRGGBB):
ME_LngText204 = 背景色 (RRGGBB):
ME_LngText205 = 矢印の透明度 (0~255):
ME_LngText206 = 矢印のサイズ:
ME_LngText207 = 矢印の間隔:
ME_LngText208 = 縁から矢印までの余白:
ME_LngText209 = カーソルからの距離:`n( -1 で開始位置に固定 )
ME_LngText210 = 矢印の色:
ME_LngText300 = 文字の色 (RRGGBB):
ME_LngText301 = 未確定文字の色 (RRGGBB):
ME_LngText302 = ウィンドウの背景色 (RRGGBB):
ME_LngText303 = ウィンドウの透明度 (0~255):
ME_LngText304 = 文字のサイズ:
ME_LngText305 = フォント名:
ME_LngText306 = 表示位置:
ME_LngText307 = 左側余白:
ME_LngText308 = 右側余白:
ME_LngText309 = 上側余白:
ME_LngText310 = 下側余白:
ME_LngText311 = ウィンドウの角の丸み:
ME_LngText312 = カーソルからの距離:`n( -1 で開始位置に固定 )
ME_LngText313 = 画面端からの距離X:
ME_LngText314 = 画面端からの距離Y:
ME_LngText400 = 軌跡の色 (RRGGBB):
ME_LngText401 = 軌跡の透明度 (0~255):
ME_LngText402 = 軌跡の太さ:
ME_LngText403 = 軌跡の描画を開始するカーソル移動量:
ME_LngText404 = 表示更新間隔 (ms):
ME_LngText421 = X座標:
ME_LngText422 = Y座標:
ME_LngText423 = ログの表示行数:
ME_LngText424 = ログウィンドウの横幅:
ME_LngText451 = ジェスチャー有効/無効の切り替え:
ME_LngText452 = ナビON/OFFの切り替え:
ME_LngText453 = MouseGestureLを再起動:
ME_LngText455 = 高さの制限 ( 0 で無制限 ):
ME_LngText501 = 横幅:
ME_LngText502 = 高さ:
ME_LngText503 = ※横幅と高さは「 0 」でウィンドウ全体の横幅、高さになります。
ME_LngText504 = 対象:
ME_LngText505 = 基準コーナー:
ME_LngText506 = 判定座標:
ME_LngText521 = キーを入力してください:
ME_LngText522 = マウスボタン:
ME_LngText523 = 操作状態:
ME_LngText524 = 入力回数:
ME_LngText525 = 操作状態:
ME_LngText526 = クリック回数:
ME_LngText527 = ホイールの回転量:
ME_LngText528 = 基点:
ME_LngText529 = スクロール方向:
ME_LngText530 = スクロール量:
ME_LngText531 = ボタンを押したままカーソルを移動させるとスクロールする機能です。
ME_LngText532 = ※この機能はボタンが押されている状態のジェスチャーへ割り当ててください。
ME_LngText533 = 垂直方向のマウス感度:
ME_LngText534 = 水平方向のマウス感度:
ME_LngText535 = (値が小さいほど高感度)
ME_LngText536 = スクロール方向:
ME_LngText537 = スクロール操作:
ME_LngText541 = ウィンドウの左上座標とサイズを指定してください。
ME_LngText542 = ・ 空白のままにした項目は変更されません。
ME_LngText543 = ・「相対値指定」をチェックすると、現在のウィンドウ位置、および`n ウィンドウサイズに対する増減値の指定となります。
ME_LngText544 = ・「相対値指定」をチェックして分数を指定すると、現在のウィンドウ`n 位置、およびウィンドウサイズに対する比率指定となります。
ME_LngText545 = ・「相対値指定」のチェックを外して分数を指定すると、デスクトップ`n のサイズに対する比率指定となります。`n (横幅と高さを「1/1」にしたい場合は、「 0 」を指定してください)
ME_LngText546 = 左座標:
ME_LngText547 = 上座標:
ME_LngText548 = 横幅:
ME_LngText549 = 高さ:
ME_LngText551 = コマンドライン:
ME_LngText552 = 作業フォルダ:
ME_LngText553 = 実行時の大きさ:
ME_LngText554 = 特権レベル:
ME_LngText556 = プログラム (*.exe)
ME_LngText557 = サウンドファイル (*.wav;*.mid)
ME_LngText558 = アイコンファイル (*.ico;*.exe;*.dll;*.cpl;*.icl)
ME_LngText561 = メッセージ:
ME_LngText562 = wParam:
ME_LngText563 = lParam:
ME_LngText571 = 以下を設定することでウィンドウタイトルによるフィルタリングができます。 (省略可)
ME_LngText572 = 含まれる文字列:
ME_LngText573 = 除外する文字列:
ME_LngText581 = 並べる方向:
ME_LngText582 = 画面の左側:
ME_LngText583 = 画面の右側:
ME_LngText584 = 画面の上側:
ME_LngText585 = 画面の下側:
ME_LngText591 = ウィンドウの移動先を選択してください。
ME_LngText592 = ・ 移動先に「元の位置」を選択すると、本コマンドで直前に`n 移動させたウィンドウを、移動前の位置へ戻します。
ME_LngText593 = ・ マルチディスプレイ環境では、モニター番号を指定することで`n サブモニターへ移動できます。
ME_LngText594 = ・ オフセット量の指定で、移動先位置の微調整ができます。
ME_LngText595 = 移動先:
ME_LngText596 = モニター番号:
ME_LngText597 = X座標:
ME_LngText598 = Y座標:
 
; ボタン
ME_LngButton001 = OK
ME_LngButton002 = キャンセル
ME_LngButton003 = ヘルプ
ME_LngButton004 = クリップボードからインポート
ME_LngButton005 = ジェスチャーを追加
ME_LngButton006 = アクションを適用
ME_LngButton007 = 追加
ME_LngButton008 = 更新
ME_LngButton009 = 変更
ME_LngButton010 = 入力補助
ME_LngButton011 = 削除
ME_LngButton012 = ボタンを押す
ME_LngButton013 = ボタンを放す
ME_LngButton014 = ジェスチャー末尾の1ステップを削除
ME_LngButton015 = スタートアップに登録
ME_LngButton016 = スタートアップから削除
ME_LngButton017 = トリガー操作別の矢印色の設定
ME_LngButton018 = 直接編集
ME_LngButton019 = 特殊キー
ME_LngButton020 = 参照...
ME_LngButton021 = アイコン適用
ME_LngButton022 = タスク切り替え時に除外するウィンドウを指定
ME_LngButton023 = 実行中のタスクから選択...
ME_LngButton024 = 選択
 
; ドロップダウンリスト
ME_LngDropDown001 = ウィンドウクラス`nコントロールクラス`n実行ファイル名`nタイトル`nカスタム条件式`n他のターゲットと一致
ME_LngDropDown002 = 完全一致`n部分一致`n前方一致`n後方一致`n正規表現
ME_LngDropDown003 = ツールチップ`n矢印ナビ1`n矢印ナビ2`nアドバンスドナビ`nリアルナビ
ME_LngDropDown004 = カーソル位置`nスクリーン左上`nスクリーン右上`nスクリーン左下`nスクリーン右下
ME_LngDropDown005 = スクリーン左上`nスクリーン右上`nスクリーン左下`nスクリーン右下`n座標指定
ME_LngDropDown101 = ターゲットウィンドウ内の相対座標`nターゲットコントロール内の相対座標`nスクリーン絶対座標
ME_LngDropDown102 = 左上`n右上`n左下`n右下
ME_LngDropDown103 = ジェスチャー開始座標`nジェスチャー終了座標
ME_LngDropDown201 = 左ボタン`n右ボタン`n中央ボタン`n第4ボタン`n第5ボタン
ME_LngDropDown202 = 通常ストローク`n押し下げ`n押し上げ
ME_LngDropDown203 = クリック`n押し下げ`n押し上げ
ME_LngDropDown204 = ジェスチャー入力開始位置`nジェスチャー入力完了位置`n現在のカーソル位置
ME_LngDropDown205 = 上スクロール`n下スクロール`n左スクロール`n右スクロール
ME_LngDropDown206 = カーソルの移動方向へスクロール`nカーソルの移動方向と逆へスクロール
ME_LngDropDown207 = カーソルを移動させた分だけスクロール`nボタンを放すまで自動スクロール
ME_LngDropDown208 = 通常のウィンドウ`n最小化`n最大化`n非表示
ME_LngDropDown209 = ユーザー権限で実行`n管理者権限で実行
ME_LngDropDown210 = 縦方向`n横方向`n縦横両方向
ME_LngDropDown211 = 画面の中央`n画面の左端`n画面の上端`n画面の右端`n画面の下端`n画面の左上`n画面の右上`n画面の左下`n画面の右下`n元の位置
 
; リストビューのカラムタイトル
ME_LngListView001 = 種別`n値
ME_LngListView002 = ジェスチャー`nアクション
ME_LngListView003 = ターゲット`nアクション
ME_LngListView004 = トリガー操作`n矢印の色
ME_LngListView005 = タイトル`nウィンドウクラス`n実行ファイル名
 
; グループBOX
ME_LngGroupBox001 = 認識処理の基本設定
ME_LngGroupBox002 = ジェスチャーの入力とみなされるカーソル移動量
ME_LngGroupBox003 = 斜め移動の認識範囲(角度)
ME_LngGroupBox004 = タイムアウト
ME_LngGroupBox005 = 画面端接触認識
ME_LngGroupBox006 = 拡張マウスボタンの動作
ME_LngGroupBox007 = 共通設定
ME_LngGroupBox008 = 矢印ナビ
ME_LngGroupBox009 = アドバンスドナビ
ME_LngGroupBox010 = 軌跡
ME_LngGroupBox011 = 操作ログ
ME_LngGroupBox012 = ホットキー
ME_LngGroupBox013 = スクリプトの編集に使用するテキストエディタ
ME_LngGroupBox014 = スタートアップ
ME_LngGroupBox015 = タスク切り替え
ME_LngGroupBox016 = その他
ME_LngGroupBox017 = アイコン
ME_LngGroupBox018 = 判定条件
ME_LngGroupBox019 = ターゲットルール
ME_LngGroupBox101 = ホイールの回転方向
ME_LngGroupBox102 = ウィンドウを配置したくない領域の指定
ME_LngGroupBox103 = 移動先座標のオフセット量
 
; チェックBOX
ME_LngCheckBox001 = 不一致
ME_LngCheckBox002 = 親ターゲットの条件を継承しない
ME_LngCheckBox003 = 8方向モード
ME_LngCheckBox004 = アクティブウィンドウをターゲットにする
ME_LngCheckBox005 = ディスプレイごとに領域を分割する
ME_LngCheckBox006 = 中央ボタンのデフォルト動作を無効化する
ME_LngCheckBox007 = 第4ボタンのデフォルト動作を無効化する
ME_LngCheckBox008 = 第5ボタンのデフォルト動作を無効化する
ME_LngCheckBox009 = 起動時からナビを有効化する
ME_LngCheckBox010 = 背景を透過させる
ME_LngCheckBox011 = トリガーボタンの押下時からナビを表示
ME_LngCheckBox012 = ジェスチャーの軌跡を表示する
ME_LngCheckBox013 = ジェスチャー操作のログを表示する
ME_LngCheckBox014 = 軌跡をオーバーラップウィンドウに描画する
ME_LngCheckBox015 = トレイメニューをサブメニュー化する
ME_LngCheckBox016 = ダイアログBOXの高さをアイテムの登録数に合わせて調節する
ME_LngCheckBox017 = 未定義ジェスチャーの入力後に本来のマウス操作を再現しない
ME_LngCheckBox018 = 修飾キーの押下状態を無視する
ME_LngCheckBox019 = 今後はこのメッセージを表示しない
ME_LngCheckBox020 = トリガー操作を常時フック処理する
ME_LngCheckBox021 = デフォルトジェスチャーを適用しない
ME_LngCheckBox101 = Shift
ME_LngCheckBox102 = Ctrl
ME_LngCheckBox103 = Alt
ME_LngCheckBox110 = 絶対座標
ME_LngCheckBox111 = ページスクロール
ME_LngCheckBox112 = 相対値指定
ME_LngCheckBox113 = Aeroウィンドウの枠幅分を自動調整
 
ME_LngRadioBtn001 = どれかに一致
ME_LngRadioBtn002 = 全てに一致
ME_LngRadioBtn101 = ↑回転
ME_LngRadioBtn102 = ↓回転
 
; メッセージ
ME_LngMessage001 = 「###REPLACE###」
ME_LngMessage002 = 、
ME_LngMessage003 = にはジェスチャー###REPLACE###が割り当てられています。`n
ME_LngMessage004 = はターゲット###REPLACE###に含まれています。`n
ME_LngMessage005 = `n削除してよろしいですか?
ME_LngMessage006 = このジェスチャーにはアクションが割り当てられています。`n削除してよろしいですか?
ME_LngMessage007 = コピー先には既にジェスチャー「 ###REPLACE### 」が割り当てられています。`nこのアクションで上書きしますか?
ME_LngMessage011 = ボタン名に使用できるのは英数字のみです。
ME_LngMessage012 = このボタン名は予約されています。
ME_LngMessage013 = 既に同じ名前のボタンがあります。`n上書きしますか?
ME_LngMessage014 = 既に同じキーを使ったボタンがあります。`n置き換えますか?
ME_LngMessage015 = 標準ボタンに使用されているボタン名です。`n標準ボタンの定義を変更しますか?
ME_LngMessage016 = 標準ボタンとして定義済みです。
ME_LngMessage017 = 選択されているボタンを削除しますか?
ME_LngMessage021 = 登録済みのジェスチャーを###REPLACE###方向モードに変換しますか?
ME_LngMessage022 = `n`n※斜め方向への移動操作は削除されます
ME_LngMessage031 = スタートアップ時に管理者権限で起動しますか?
ME_LngMessage032 = スタートアップに登録しました。
ME_LngMessage033 = スタートアップから削除しました。
ME_LngMessage101 = アプリケーションのメニューバー内の項目を選択します。`n`n ・メニュー項目は「 , 」区切りで、最大6階層辿った先まで指定できます。`n ・対応できないアプリケーションもあります。`n`n  【例】編集,コピー`n`nメニューの項目名を指定してください:
ME_LngMessage102 = 起動するプログラムやファイル、URLなどを指定してください。
ME_LngMessage104 = 不透明度を指定してください。`n`n  0(透明) ~ 255(不透明)
ME_LngMessage105 = 直前にアクティブ化されていたウィンドウを再度アクティブ化します。`nタイムアウト値に指定された時間が経過する前に再度実行すれば、`nより以前のアクティブウィンドウまで遡って復元されます。`n`nタイムアウト値(ms):
ME_LngMessage106 = 以下の何れかを指定してください。`n`n    0 ~ 100`t: 音量を直接指定`n   +1 ~ +100`t: 音量の増加量を指定`n   -1 ~ -100`t: 音量の減少量を指定:
ME_LngMessage107 = 以下の何れかを指定してください。`n`n     1 : ミュートON`n     0 : ミュートOFF`n     + : ミュートON/OFFの切り替え
ME_LngMessage108 = 再生するサウンドファイルのパス名を指定してください。`n`n・OSがサポートしていない形式のサウンドファイルは再生できません。
ME_LngMessage109 = 一度ボタンが放された後、タイムアウトするまでは、次のボタン押し`n下げ操作を同ジェスチャーの続きとして受け付けるようにします。`n`n ・この処理はボタンを放した時のアクションに割り当ててください。`n`n 【例】右ダブルクリック`n  1. RB__のアクションにこの処理を割り当てる`n  2. RB__RB__のアクションに右ダブルクリック時の動作を割り当てる`n`nタイムアウト値(ミリ秒)を指定してください:
ME_LngMessage110 = 指定された時間だけスクリプトの実行を停止し、待ち時間が経過`nした後に続きを実行します。`n`n ・時間待ちの間はジェスチャーを受け付けなくなります。`n  長い時間を待つ場合は「ジェスチャーの認識終了後に実行」`n  を利用してください。`n`n待ち時間(ミリ秒)を指定してください:
ME_LngMessage111 = ジェスチャーの入力後、指定された時間が経過してから処理を実行します。`n`n ・ボタン押し下げ操作のアクションに割り当てることで、ボタン長押し時`n  の動作を割り当てられます。`n ・シングルクリックのアクションを、ダブルクリックしなかったときにだけ実行`n  させることができます。`n`n 【例】中央ボタンのダブルクリック時に、シングルクリックへの割り当て`n    動作が発動しないようにする`n  1. MB__のアクションにこの処理を割り当て、「 else { 」の下に`n    シングルクリック時の動作を記述する`n  2. MB__MB__のアクションにダブルクリック時の動作を割り当てる`n`n待ち時間(ミリ秒)を指定してください:
ME_LngMessage112 = ジェスチャーの入力後、指定された時間が経過してから`nボタンを放した時点で処理を実行します。`n`n ・この処理はボタンが押されている状態のジェスチャーへ`n  割り当ててください。`n`n待ち時間(ミリ秒)を指定してください:
ME_LngMessage113 = ボタンが放されるまで、指定間隔で処理を繰り返します。`n`n ・この処理はボタンが押されている状態のジェスチャーへ`n  割り当ててください。`n`n繰り返し間隔(ミリ秒)を指定してください:
ME_LngMessage114 = ジェスチャーの認識処理が完了した後で処理を実行します。`n`n ・この処理は割り当てアクションの中でメッセージBOXを`n  表示させるなど、スクリプトの流れが長時間停止する`n  場合に利用します。`n
ME_LngMessage115 = ジェスチャーの入力後、マウスボタンを放したときにマウス操作に応じた本来の動作を実行します。`n`n ・右ボタンをトリガーとしたジェスチャーが発動した場合、右ボタンを放したときにコンテキストメニュー`n  は表示されませんが、この関数を実行した場合は表示されるようになります。`n`n ・割り当てアクションの中にif文があり、所定の条件を満たしていないときには通常の操作とみな`n  してコンテキストメニューを表示させたい、といった場合はelse側でこの関数を呼び出します。`n
ME_LngMessage116 = ジェスチャーの入力後、マウスボタンを放したときにマウス操作に応じた本来の動作をキャンセルします。`n`n 【使用例】`n  1. 右ボタンをトリガーとしたジェスチャーに次のようなアクションを割り当てる。`n  2. MG_Timer()関数を利用して、後続のジェスチャーが発動しなかったことを条件に`n    所定の処理を遅延実行する。`n`n  上記の設定ではアクションが遅延実行される前にコンテキストメニューが表示されます。`n  これを防止するにはジェスチャー入力直後の処理でこの関数を呼び出してください。`n
ME_LngMessage117 = 指定された文字列をツールチップナビに表示します。`n`n ・この機能はボタンが押されている状態のジェスチャーへ`n  割り当ててください。`n ・ツールチップナビが無効になっている場合は機能しません。`n ・複数行の文字列を表示する場合は、OKボタンを押して`n  から( )内の文字列を編集してください。`n`n表示させる文字列を入力してください:
ME_LngMessage118 = 指定された文字列をクリップボードにセットします。`n`n ・タブは``t、 改行は``nです。`n ・複数行の文字列をコピーする場合は、OKボタンを押して`n  から( )内の文字列を編集してください。`n`nコピーする文字列を入力してください:
ME_LngMessage119 = キー操作を表す文字列を入力してください。`n`n  【書式】 +^!#{キー名} + :Shift  ^ :Ctrl`n ! :Alt  # :Windowsキー`n`n ・単一文字のキーは{ }で囲まなくてもOKです。`n ・単一の大文字はShiftキーとの同時押しと解釈されます。`n ・{キー名 Down}でキーの押し下げのみ、{キー名 Up}で押し上げのみとなります。`n ・マウスのクリックはボタンごとにそれぞれ、{LButton}、{RButton}、{MButton}、`n  {XButton1}、{XButton2}と記述します。`n ・複数のキーを連続指定することで、連続したキー操作を発生させることができます。
 
ME_LngTooltip001 = 削除
ME_LngTooltip002 = クリア
ME_LngTooltip003 = テキストエディタで編集
ME_LngTooltip011 = ターゲットを追加
ME_LngTooltip012 = 上へ移動
ME_LngTooltip013 = 下へ移動
ME_LngTooltip014 = 名前順で並べ替え
ME_LngTooltip015 = 複製
ME_LngTooltip016 = サブターゲットを表示
ME_LngTooltip017 = サブターゲットを折りたたむ
ME_LngTooltip021 = ジェスチャーを追加
ME_LngTooltip101 = 「###REPLACE###」をクリップボードへコピーしました。
ME_LngTooltip102 = 設定をインポートしました。
ME_LngTooltip103 = 取得したいウィンドウを右クリック
ME_LngTooltip104 = 対象ボタンを右クリック
ME_LngTooltip105 = ドラッグして領域を選択
 
; フォント
ME_AdNaviFont = メイリオ
ME_ScriptFont = MS ゴシック
ME_ScriptSize =
 
; その他文字列
ME_LngOthers001 = デフォルト
ME_LngOthers002  = ジェスチャー無効
ME_LngOthers003 = ターゲット
ME_LngOthers004 = なし
ME_LngOthers005
ME_LngOthers006 = 部分一致
ME_LngOthers007 = 前方一致
ME_LngOthers008 = 後方一致
ME_LngOthers009 = 正規表現
ME_LngOthers010 = 不一致
ME_LngOthers011 = 部分不一致
ME_LngOthers012 = 前方不一致
ME_LngOthers013 = 後方不一致
ME_LngOthers014 = 正規表現不一致
ME_LngOthers015  = << トリガー操作の追加 >>
 
;-------------------------------------------------------------------------------
; デフォルト設定
;-------------------------------------------------------------------------------
ME_PresetItems =
(%
 
Icon=%A_WinDir%\system32\inetcpl.cpl,6
Exe=iexplore.exe
Exe=msedge.exe
Exe=chrome.exe
Exe=firefox.exe
 
Icon=%A_WinDir%\explorer.exe,1
WClass=CabinetWClass
WClass=ExploreWClass
WClass=Progman
WClass=WorkerW
 
[アイコン]
Icon=%A_WinDir%\explorer.exe,1
Level=2
Custom=MG_TreeListHitTest()
 
[RB_]
G=RB_
Default=;アクティブ化<MG_CR>if (MG_WClass != "Chrome_WidgetWin_2") {<MG_CR><MG_TAB>MG_WinActivate()<MG_CR>}
エクスプローラー/アイコン=;ジェスチャーキャンセル<MG_CR>MG_Abort()
 
[RB_LB_]
G=RB_LB__
Default=;ウィンドウを閉じる<MG_CR>PostMessage, 0x0010
 
[RB_←]
G=RB_L_
Default=;戻る<MG_CR>Send, !{Left}
 
[RB_→]
G=RB_R_
Default=;進む<MG_CR>Send, !{Right}
 
[RB_↑]
G=RB_U_
Default=;先頭へジャンプ<MG_CR>Send, ^{Home}
 
[RB_↓]
G=RB_D_
Default=;最後へジャンプ<MG_CR>Send, ^{End}
 
[RB_←↑]
G=RB_LU_
 
[RB_←↓]
G=RB_LD_
 
[RB_→↑]
G=RB_RU_
Default=;直前のアクティブウィンドウを復元<MG_CR>MG_ActivatePrevWin()
 
[RB_→↓]
G=RB_RD_
Default=;最小化<MG_CR>PostMessage, 0x0112, 0xF020, 0
 
[RB_↑←]
G=RB_UL_
 
[RB_↑→]
G=RB_UR_
 
[RB_↓←]
G=RB_DL_
 
[RB_↓→]
G=RB_DR_
)
 
;-------------------------------------------------------------------------------
EndLanguage:
MG_Language := RegExReplace(A_LineFile, "m)^.+\\|\.ahk$")
 

MG_Config

MG_IniFileVersion=1.40
MG_8Dir=0
MG_ActiveAsTarget=0
MG_Interval=20
MG_AlwaysHook=1
MG_PrvntCtxtMenu=1
MG_Threshold=12
MG_LongThresholdX=800
MG_LongThresholdY=600
MG_LongThreshold=700
MG_TimeoutThreshold=12
MG_Timeout=1000
MG_DGInterval=0
MG_TmReleaseTrigger=3
MG_ORangeDefault=3
MG_ORangeA=3
MG_ORangeB=3
MG_EdgeInterval=20
MG_EdgeIndiv=0
MG_CornerX=1
MG_CornerY=1
MG_DisableDefMB=0
MG_DisableDefX1B=0
MG_DisableDefX2B=0
MG_UseNavi=1
MG_UseExNavi=3
MG_NaviInterval=10
MG_NaviPersist=0
MG_ExNaviTransBG=1
MG_ExNaviFG=000000
MG_ExNaviBG=FFFFFF
MG_ExNaviTranspcy=255
MG_ExNaviSize=24
MG_ExNaviSpacing=2
MG_ExNaviPadding=4
MG_ExNaviMargin=8
MG_AdNaviFG=FFFFFF
MG_AdNaviNI=7F7F7F
MG_AdNaviBG=000000
MG_AdNaviTranspcy=220
MG_AdNaviSize=11
MG_AdNaviFont=メイリオ
MG_AdNaviPosition=0
MG_AdNaviPaddingL=6
MG_AdNaviPaddingR=6
MG_AdNaviPaddingT=3
MG_AdNaviPaddingB=3
MG_AdNaviRound=2
MG_AdNaviMargin=14
MG_AdNaviSpaceX=2
MG_AdNaviSpaceY=2
MG_AdNaviOnClick=0
MG_ShowTrail=0
MG_DrawTrailWnd=1
MG_TrailColor=0000FF
MG_TrailTranspcy=255
MG_TrailWidth=3
MG_TrailStartMove=3
MG_TrailInterval=10
MG_ShowLogs=0
MG_LogPosition=4
MG_LogPosX=0
MG_LogPosY=0
MG_LogMax=20
MG_LogSizeW=400
MG_LogInterval=500
MG_LogFG=FFFFFF
MG_LogBG=000000
MG_LogTranspcy=100
MG_LogFontSize=10
MG_LogFont=MS UI Gothic
MG_EditCommand=
MG_HotkeyEnable=PgUp
MG_HotkeyNavi=
MG_HotkeyReload=
MG_ScriptEditor=
MG_TraySubmenu=0
MG_AdjustDlg=0
MG_DlgHeightLimit=800
MG_FoldTarget=0
MG_DisableWarning=0
MG_ActvtExclud := []
MG_MaxLength=8
MG_Triggers=RB
MG_SubTriggers=LB_WU_WD_A_B_C_D_S
 
 
Goto, MG_RB_End
 
MG_RB_Enable:
if (!MG_AlwaysHook) {
MG_RB_HookEnabled := Func("MG_IsHookEnabled_RB")
Hotkey, If, % MG_RB_HookEnabled
}
Hotkey, *RButton, MG_RB_DownHotkey, On
Hotkey, *RButton up, MG_RB_UpHotkey, On
Hotkey, If
MG_RB_Enabled := 1
return
 
MG_RB_Disable:
Hotkey, *RButton, MG_RB_DownHotkey, Off
Hotkey, *RButton up, MG_RB_UpHotkey, Off
MG_RB_Enabled := 0
return
 
MG_RB_DownHotkey:
MG_TriggerDown("RB")
return
 
MG_RB_UpHotkey:
MG_TriggerUp("RB")
return
 
MG_RB_Down:
MG_SendButton("RB", "RButton", "Down")
return
 
MG_RB_Up:
MG_SendButton("RB", "RButton", "Up")
return
 
MG_RB_Check:
MG_CheckButton("RB", "RButton")
return
 
MG_RB_End:
 
 
Goto, MG_LB_End
 
MG_LB_Enable:
if (!MG_AlwaysHook) {
MG_LB_HookEnabled := Func("MG_IsHookEnabled_LB")
Hotkey, If, % MG_LB_HookEnabled
}
Hotkey, *LButton, MG_LB_DownHotkey, On
Hotkey, *LButton up, MG_LB_UpHotkey, On
Hotkey, If
MG_LB_Enabled := 1
return
 
MG_LB_Disable:
Hotkey, *LButton, MG_LB_DownHotkey, Off
Hotkey, *LButton up, MG_LB_UpHotkey, Off
MG_LB_Enabled := 0
return
 
MG_LB_DownHotkey:
MG_TriggerDown("LB")
return
 
MG_LB_UpHotkey:
MG_TriggerUp("LB")
return
 
MG_LB_Down:
MG_SendButton("LB", "LButton", "Down")
return
 
MG_LB_Up:
MG_SendButton("LB", "LButton", "Up")
return
 
MG_LB_Check:
MG_CheckButton("LB", "LButton")
return
 
MG_LB_End:
 
 
Goto, MG_WU_End
 
MG_WU_Enable:
if (!MG_AlwaysHook) {
MG_WU_HookEnabled := Func("MG_IsHookEnabled_WU")
Hotkey, If, % MG_WU_HookEnabled
}
Hotkey, *WheelUp, MG_WU_Hotkey, On
Hotkey, If
MG_WU_Enabled := 1
return
 
MG_WU_Disable:
Hotkey, *WheelUp, MG_WU_Hotkey, Off
MG_WU_Enabled := 0
return
 
MG_WU_Hotkey:
MG_ButtonPress("WU")
return
 
MG_WU_Press:
MG_SendButton("WU", "WheelUp")
return
 
MG_WU_End:
 
 
Goto, MG_WD_End
 
MG_WD_Enable:
if (!MG_AlwaysHook) {
MG_WD_HookEnabled := Func("MG_IsHookEnabled_WD")
Hotkey, If, % MG_WD_HookEnabled
}
Hotkey, *WheelDown, MG_WD_Hotkey, On
Hotkey, If
MG_WD_Enabled := 1
return
 
MG_WD_Disable:
Hotkey, *WheelDown, MG_WD_Hotkey, Off
MG_WD_Enabled := 0
return
 
MG_WD_Hotkey:
MG_ButtonPress("WD")
return
 
MG_WD_Press:
MG_SendButton("WD", "WheelDown")
return
 
MG_WD_End:
 
 
;Description = A
Goto, MG_A_End
 
MG_A_Enable:
if (!MG_AlwaysHook) {
MG_A_HookEnabled := Func("MG_IsHookEnabled_A")
Hotkey, If, % MG_A_HookEnabled
}
Hotkey, a, MG_A_DownHotkey, On
Hotkey, a up, MG_A_UpHotkey, On
Hotkey, If
MG_A_Enabled := 1
return
 
MG_A_Disable:
Hotkey, a, MG_A_DownHotkey, Off
Hotkey, a up, MG_A_UpHotkey, Off
MG_A_Enabled := 0
return
 
MG_A_DownHotkey:
MG_TriggerDown("A")
return
 
MG_A_UpHotkey:
MG_TriggerUp("A")
return
 
MG_A_Down:
MG_SendButton("A", "a", "Down")
return
 
MG_A_Up:
MG_SendButton("A", "a", "Up")
return
 
MG_A_Check:
MG_CheckButton("A", "a")
return
 
MG_A_End:
 
 
;Description = B
Goto, MG_B_End
 
MG_B_Enable:
if (!MG_AlwaysHook) {
MG_B_HookEnabled := Func("MG_IsHookEnabled_B")
Hotkey, If, % MG_B_HookEnabled
}
Hotkey, b, MG_B_DownHotkey, On
Hotkey, b up, MG_B_UpHotkey, On
Hotkey, If
MG_B_Enabled := 1
return
 
MG_B_Disable:
Hotkey, b, MG_B_DownHotkey, Off
Hotkey, b up, MG_B_UpHotkey, Off
MG_B_Enabled := 0
return
 
MG_B_DownHotkey:
MG_TriggerDown("B")
return
 
MG_B_UpHotkey:
MG_TriggerUp("B")
return
 
MG_B_Down:
MG_SendButton("B", "b", "Down")
return
 
MG_B_Up:
MG_SendButton("B", "b", "Up")
return
 
MG_B_Check:
MG_CheckButton("B", "b")
return
 
MG_B_End:
 
 
;Description = C
Goto, MG_C_End
 
MG_C_Enable:
if (!MG_AlwaysHook) {
MG_C_HookEnabled := Func("MG_IsHookEnabled_C")
Hotkey, If, % MG_C_HookEnabled
}
Hotkey, c, MG_C_DownHotkey, On
Hotkey, c up, MG_C_UpHotkey, On
Hotkey, If
MG_C_Enabled := 1
return
 
MG_C_Disable:
Hotkey, c, MG_C_DownHotkey, Off
Hotkey, c up, MG_C_UpHotkey, Off
MG_C_Enabled := 0
return
 
MG_C_DownHotkey:
MG_TriggerDown("C")
return
 
MG_C_UpHotkey:
MG_TriggerUp("C")
return
 
MG_C_Down:
MG_SendButton("C", "c", "Down")
return
 
MG_C_Up:
MG_SendButton("C", "c", "Up")
return
 
MG_C_Check:
MG_CheckButton("C", "c")
return
 
MG_C_End:
 
 
;Description = D
Goto, MG_D_End
 
MG_D_Enable:
if (!MG_AlwaysHook) {
MG_D_HookEnabled := Func("MG_IsHookEnabled_D")
Hotkey, If, % MG_D_HookEnabled
}
Hotkey, d, MG_D_DownHotkey, On
Hotkey, d up, MG_D_UpHotkey, On
Hotkey, If
MG_D_Enabled := 1
return
 
MG_D_Disable:
Hotkey, d, MG_D_DownHotkey, Off
Hotkey, d up, MG_D_UpHotkey, Off
MG_D_Enabled := 0
return
 
MG_D_DownHotkey:
MG_TriggerDown("D")
return
 
MG_D_UpHotkey:
MG_TriggerUp("D")
return
 
MG_D_Down:
MG_SendButton("D", "d", "Down")
return
 
MG_D_Up:
MG_SendButton("D", "d", "Up")
return
 
MG_D_Check:
MG_CheckButton("D", "d")
return
 
MG_D_End:
 
 
;Description = s
Goto, MG_S_End
 
MG_S_Enable:
if (!MG_AlwaysHook) {
MG_S_HookEnabled := Func("MG_IsHookEnabled_S")
Hotkey, If, % MG_S_HookEnabled
}
Hotkey, s, MG_S_DownHotkey, On
Hotkey, s up, MG_S_UpHotkey, On
Hotkey, If
MG_S_Enabled := 1
return
 
MG_S_Disable:
Hotkey, s, MG_S_DownHotkey, Off
Hotkey, s up, MG_S_UpHotkey, Off
MG_S_Enabled := 0
return
 
MG_S_DownHotkey:
MG_TriggerDown("S")
return
 
MG_S_UpHotkey:
MG_TriggerUp("S")
return
 
MG_S_Down:
MG_SendButton("S", "s", "Down")
return
 
MG_S_Up:
MG_SendButton("S", "s", "Up")
return
 
MG_S_Check:
MG_CheckButton("S", "s")
return
 
MG_S_End:
 
 
Goto, MG_Config_End
 
 
MG_IsDisable() {
global
return (0)
}
 
MG_IsTarget1() {
global
return *1
}
 
MG_IsTarget2() {
global
return *2
}
 
MG_IsTarget3() {
global
return (MG_IsTarget2() && *3
}
 
MG_IsTarget5() {
global
return *4
}
 
MG_IsTarget6() {
global
return *5
}
 
MG_IsTarget7() {
global
return *6
}
 
MG_IsTarget8() {
global
return *7
}
 
MG_IsExDefault() {
return (0)
}
 
MG_Gesture_RB_:
if (!MG_IsExDefault()) {
;アクティブ化
if (MG_WClass != "Chrome_WidgetWin_2") {
MG_WinActivate()
}
}
return
 
MG_GetAction_RB_:
if (!MG_IsExDefault()) {
MG_ActionStr := "アクティブ化"
}
return
 
MG_Gesture_RB_A_:
if (!MG_IsExDefault()) {
;デフォルト再生速度
Send, !d
}
return
 
MG_GetAction_RB_A_:
if (!MG_IsExDefault()) {
MG_ActionStr := "デフォルト再生速度"
}
return
 
MG_Gesture_RB_C_:
if (!MG_IsExDefault()) {
;倍速
send,!a
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
send,!s
}
return
 
MG_GetAction_RB_C_:
if (!MG_IsExDefault()) {
MG_ActionStr := "倍速"
}
return
 
MG_Gesture_RB_LB__:
if (MG_IsTarget7()) {
;数式を挿入
Send, +!-
} else if (MG_IsTarget1()) {
;タブを閉じる
Send, ^w
} else if (!MG_IsExDefault()){
;Alt F4
Send, !{F4}
}
return
 
MG_GetAction_RB_LB__:
if (MG_IsTarget7()) {
MG_ActionStr := "数式を挿入"
} else if (MG_IsTarget1()) {
MG_ActionStr := "タブを閉じる"
} else if (!MG_IsExDefault()){
MG_ActionStr := "Alt F4"
}
return
 
MG_Gesture_RB_WD__:
if (!MG_IsExDefault()) {
;ウィンドウの位置を下に移動
WinRestore
MG_WinMove("0", "0.5", "0", "0.5", 0,,,1)
}
return
 
MG_GetAction_RB_WD__:
if (!MG_IsExDefault()) {
MG_ActionStr := "ウィンドウの位置を下に移動"
}
return
 
MG_Gesture_RB_WU__:
if (!MG_IsExDefault()) {
;ウィンドウ位置を上に移動
WinRestore
MG_WinMove("0", "0.1", "0", "0.40", 0,,,1)
}
return
 
MG_GetAction_RB_WU__:
if (!MG_IsExDefault()) {
MG_ActionStr := "ウィンドウ位置を上に移動"
}
return
 
MG_Gesture_RB_L_:
if (MG_IsTarget5()) {
;戻る
Send, ^z
} else if (MG_IsTarget6()) {
;Ctrl+Zを押す
Send, ^z
} else if (MG_IsTarget8()) {
;前のチャート組
Send, {Shift}+{F5}
} else if (!MG_IsExDefault()){
;左のタブへ移動
Send, ^+{tab}
}
return
 
MG_GetAction_RB_L_:
if (MG_IsTarget5()) {
MG_ActionStr := "戻る"
} else if (MG_IsTarget6()) {
MG_ActionStr := "Ctrl+Zを押す"
} else if (MG_IsTarget8()) {
MG_ActionStr := "前のチャート組"
} else if (!MG_IsExDefault()){
MG_ActionStr := "左のタブへ移動"
}
return
 
MG_Gesture_RB_LU_:
if (!MG_IsExDefault()) {
;ウィンドウ位置/サイズ変更 (W=0.33, H=1)
MG_WinMove("0", "0", "0.33", "0", 0,,,0)
}
return
 
MG_GetAction_RB_LU_:
if (!MG_IsExDefault()) {
MG_ActionStr := "ウィンドウ位置/サイズ変更 (W=0.33, H=1)"
}
return
 
MG_Gesture_RB_LR_:
if (MG_IsTarget4()) {
;上書き保存
Send, ^s
} else if (MG_IsTarget5()) {
;上書き保存
Send, ^s
} else if (MG_IsTarget6()) {
;セクションの実行
Send, ^{Enter}
} else if (!MG_IsExDefault()){
;広告を削除
Send, !q
Send, !q
}
return
 
MG_GetAction_RB_LR_:
if (MG_IsTarget4()) {
MG_ActionStr := "上書き保存"
} else if (MG_IsTarget5()) {
MG_ActionStr := "上書き保存"
} else if (MG_IsTarget6()) {
MG_ActionStr := "セクションの実行"
} else if (!MG_IsExDefault()){
MG_ActionStr := "広告を削除"
}
return
 
MG_Gesture_RB_LRL:
MG_Gesture_RB_LRL_:
if (!MG_IsExDefault()) {
}
return
 
MG_GetAction_RB_LRL:
MG_GetAction_RB_LRL_:
if (!MG_IsExDefault()) {
}
return
 
MG_Gesture_RB_LD_:
if (!MG_IsExDefault()) {
}
return
 
MG_GetAction_RB_LD_:
if (!MG_IsExDefault()) {
MG_ActionStr := ""
}
return
 
MG_Gesture_RB_U_:
if (!MG_IsExDefault()) {
;ウィンドウを最大化
WinMaximize
}
return
 
MG_GetAction_RB_U_:
if (!MG_IsExDefault()) {
MG_ActionStr := "ウィンドウを最大化"
}
return
 
MG_Gesture_RB_UL_:
if (!MG_IsExDefault()) {
;等速
send,!d
}
return
 
MG_GetAction_RB_UL_:
if (!MG_IsExDefault()) {
MG_ActionStr := "等速"
}
return
 
MG_Gesture_RB_UR_:
if (!MG_IsExDefault()) {
;2倍速
send,!a
}
return
 
MG_GetAction_RB_UR_:
if (!MG_IsExDefault()) {
MG_ActionStr := "2倍速"
}
return
 
MG_Gesture_RB_UD_:
if (!MG_IsExDefault()) {
;別モニターに移動
WinMaximize
Send, {Shift}+#+{Right}
}
return
 
MG_GetAction_RB_UD_:
if (!MG_IsExDefault()) {
MG_ActionStr := "別モニターに移動"
}
return
 
MG_Gesture_RB_UDUD_:
if (MG_IsTarget5()) {
;数式挿入
Send, !;
} else {
MG_Cancel()
}
return
 
MG_GetAction_RB_UDUD_:
if (MG_IsTarget5()) {
MG_ActionStr := "数式挿入"
} else {
MG_ActionStr := ""
}
return
 
MG_Gesture_RB_R_:
if (MG_IsTarget4()) {
;カット
Send, ^b
} else if (MG_IsTarget5()) {
;進む
Send, ^y
} else if (MG_IsTarget8()) {
;次のチャート組
Send, ^{F5}
} else if (!MG_IsExDefault()){
;右のタブへ移動
Send, ^{tab}
}
return
 
MG_GetAction_RB_R_:
if (MG_IsTarget4()) {
MG_ActionStr := "カット"
} else if (MG_IsTarget5()) {
MG_ActionStr := "進む"
} else if (MG_IsTarget8()) {
MG_ActionStr := "次のチャート組"
} else if (!MG_IsExDefault()){
MG_ActionStr := "右のタブへ移動"
}
return
 
MG_Gesture_RB_RL_:
if (MG_IsTarget1()) {
;Ctrl+Tを押す
Send, ^t
} else if (!MG_IsExDefault()){
;chromeを開く
Send, #+2
}
return
 
MG_GetAction_RB_RL_:
if (MG_IsTarget1()) {
MG_ActionStr := "Ctrl+Tを押す"
} else if (!MG_IsExDefault()){
MG_ActionStr := "chromeを開く"
}
return
 
MG_Gesture_RB_RU_:
if (!MG_IsExDefault()) {
}
return
 
MG_GetAction_RB_RU_:
if (!MG_IsExDefault()) {
MG_ActionStr := ""
}
return
 
 
MG_Gesture_RB_RD_:
if (!MG_IsExDefault()) {
}
return
 
MG_GetAction_RB_RD_:
if (!MG_IsExDefault()) {
MG_ActionStr := ""
}
return
 
MG_Gesture_RB_D_:
if (!MG_IsExDefault()) {
;ウィンドウを最小化
WinMinimize
}
return
 
MG_GetAction_RB_D_:
if (!MG_IsExDefault()) {
MG_ActionStr := "ウィンドウを最小化"
}
return
 
MG_Gesture_RB_DL_:
if (!MG_IsExDefault()) {
;ウィンドウを画面の左端へ移動
Send, #{Left}
}
return
 
MG_GetAction_RB_DL_:
if (!MG_IsExDefault()) {
MG_ActionStr := "ウィンドウを画面の左端へ移動"
}
return
 
MG_Gesture_RB_DU_:
if (!MG_IsExDefault()) {
;ウインドウの切り替え
If(MG_timer(5000))
    Send, {altdown}{tab}
else
    Send, {altup}
}
return
 
MG_GetAction_RB_DU_:
if (!MG_IsExDefault()) {
MG_ActionStr := "ウインドウの切り替え"
}
return
 
MG_Gesture_RB_DUD_:
if (!MG_IsExDefault()) {
}
return
 
MG_GetAction_RB_DUD_:
if (!MG_IsExDefault()) {
}
return
 
MG_Gesture_RB_DR_:
if (!MG_IsExDefault()) {
;ウィンドウを画面の右端へ移動
Send, #{Right}
}
return
 
MG_GetAction_RB_DR_:
if (!MG_IsExDefault()) {
MG_ActionStr := "ウィンドウを画面の右端へ移動"
}
return
 
MG_Gesture_RB_B_:
if (!MG_IsExDefault()) {
;2倍速
send,!a
}
return
 
MG_GetAction_RB_B_:
if (!MG_IsExDefault()) {
MG_ActionStr := "2倍速"
}
return
 
MG_Gesture_RB_S_:
if (!MG_IsExDefault()) {
;2倍速
send,!a
}
return
 
MG_GetAction_RB_S_:
if (!MG_IsExDefault()) {
MG_ActionStr := "2倍速"
}
return
 
 
MG_IsHookEnabled_RB() {
global
MG_TriggerCount ? : MG_GetMousePosInfo()
return (MG_RB_Enabled && (MG_TriggerCount || (!MG_IsDisable())))
}
 
MG_IsHookEnabled_LB() {
global
return (MG_LB_Enabled && MG_TriggerCount)
}
 
MG_IsHookEnabled_WU() {
global
return (MG_WU_Enabled && MG_TriggerCount)
}
 
MG_IsHookEnabled_WD() {
global
return (MG_WD_Enabled && MG_TriggerCount)
}
 
MG_IsHookEnabled_A() {
global
return (MG_A_Enabled && MG_TriggerCount)
}
 
MG_IsHookEnabled_B() {
global
return (MG_B_Enabled && MG_TriggerCount)
}
 
MG_IsHookEnabled_C() {
global
return (MG_C_Enabled && MG_TriggerCount)
}
 
MG_IsHookEnabled_D() {
global
return (MG_D_Enabled && MG_TriggerCount)
}
 
MG_IsHookEnabled_S() {
global
return (MG_S_Enabled && MG_TriggerCount)
}
 
 
PgUp::MG_ToggleEnable()
Hotkey, PgUp,, P8
 
 
MG_Config_end:

*1:MG_Exe="iexplore.exe") || (MG_Exe="msedge.exe") || (MG_Exe="chrome.exe") || (MG_Exe="firefox.exe"

*2:MG_WClass="CabinetWClass") || (MG_WClass="ExploreWClass") || (MG_WClass="Progman") || (MG_WClass="WorkerW"

*3:MG_TreeListHitTest())))

}
 
MG_IsTarget4() {
global
return ((MG_WClass="Qt5152QWindowIcon"

*4:MG_WClass="PPTFrameClass"

*5:MG_WClass="SunAwtFrame"

*6:MG_WClass="OpusApp"

*7:MG_WClass="MetaQuotes::MetaTrader::4.00"

;===============================================================================
;
; MouseGestureL.ahk - Main Script
; Created by lukewarm
; Modified by Pyonkichi
;===============================================================================
;-------------------------------------------------------------------------------
; Initialization Process
;-------------------------------------------------------------------------------
MG_Init:
#MaxHotkeysPerInterval 2000
#WinActivateForce
Process, Priority,, High
StringCaseSense, Off
#Include %A_ScriptDir%\Components\MG_CommonLib.ahk
Menu, Tray, Icon, %MG_IconFile%
MG_IsEdit := 0
MG_PluginMenuCount := 0
MG_IsDisableObj := Func("MG_IsDisable")
#Include *i %A_ScriptDir%\Config\MG_Language.ahk
#Include *i %A_ScriptDir%\Config\MG_Plugins.ahk
#Include *i %A_ScriptDir%\Plugins\MG_Plugin.ahk
#Include *i %A_ScriptDir%\Config\MG_Config.ahk
#Include *i %A_ScriptDir%\Config\MG_User.ahk
MG_CheckLanguage()
if (MG_SearchPlugins()) {
Reload
}
MG_CheckConfigFiles()
MG_RegisterMenu()
MG_InitGlobals()
MG_Enable()
MG_InitNavi()
MG_InitTrail()
MG_InitLog()
MG_CallIfUsed("MG_SetWinEventHook", "MG_ActivatePrevWin")
MG_DmyObj := Object("base", Object("__Delete", "MG_EndOperation"))
SetTimer, MG_CancelMode, 1000
if (IsFunc("MG_PostInit")) {
Func("MG_PostInit").()
}
if (A_ThisLabel = "MG_Init") {
return
} else {
Goto,MG_End
}
 
;-------------------------------------------------------------------------------
; Register Menu
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_RegisterMenu()
{
global
if (MG_TraySubmenu) {
MG_MenuName := "MGMenu"
}
else {
MG_MenuName := "Tray"
Menu, StdMenu, Standard
Menu, Tray, NoStandard
Menu, Tray, Add, %MG_LngMenu001%, :StdMenu
Menu, Tray, Add,
}
Menu, %MG_MenuName%, Add, %MG_LngMenu002%, MG_ToggleEnable
Menu, %MG_MenuName%, Add, %MG_LngMenu003%, MG_NaviToggleEnable
Menu, %MG_MenuName%, Add,
Menu, %MG_MenuName%, Add, %MG_LngMenu004%, MG_Edit
Menu, %MG_MenuName%, Add, %MG_LngMenu005%, MG_EditUser
if (MG_ShowLogs) {
Menu, %MG_MenuName%, Add, %MG_LngMenu006%, MG_CopyLogs
}
if (MG_PluginMenuCount)
{
Loop, %MG_PluginMenuCount% {
Menu, PluginMenu, Add, % MG_PluginMenu%A_Index%_Name, % MG_PluginMenu%A_Index%_Command
}
Menu, PluginMenu, Add,
Menu, PluginMenu, Add, %MG_LngMenu007%, MG_OpenPluginsFolder
Menu, %MG_MenuName%, Add, %MG_LngMenu008%, :PluginMenu
}
else
{
Menu, %MG_MenuName%, Add, %MG_LngMenu007%, MG_OpenPluginsFolder
}
Menu, %MG_MenuName%, Add,
Menu, %MG_MenuName%, Add, %MG_LngMenu009%, MG_ChooseLanguage
Menu, %MG_MenuName%, Add, %MG_LngMenu010%, MG_ShowHelp
Menu, %MG_MenuName%, Add, %MG_LngMenu011%, MG_ShowAboutDlg
Menu, %MG_MenuName%, Add,
Menu, %MG_MenuName%, Add, %MG_LngMenu012%, MG_Reload
Menu, %MG_MenuName%, Add, %MG_LngMenu013%, MG_Exit
if (MG_TraySubmenu)
{
if (MG_MenuParent) {
Menu, %MG_MenuParent%, Add, %MG_LngMenu014%, :MGMenu
}
else if (A_ScriptName = "MouseGestureL.ahk") {
Menu, Tray, NoStandard
Menu, Tray, Add, %MG_LngMenu014%, :MGMenu
Menu, Tray, Add,
Menu, Tray, Standard
}
}
else {
Menu, Tray, Default, %MG_LngMenu004%
}
}
 
;-------------------------------------------------------------------------------
; Initialize global variables
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_InitGlobals()
{
local cnt
 
MG_ScreenDPI := A_ScreenDPI
MG_TriggerCount := 0
MG_Active := 0
MG_Executed := 0
MG_TimedOut := 0
MG_LastTime := 0
MG_PerformDef := 0
MG_CancelDef := 0
MG_ORange := 0.3926990817
MG_ORange1 := 0
MG_ORange2 := 0.2617993878
MG_ORange3 := 0.3926990817
MG_ORange4 := 0.5235987756
MG_ORange5 := 0.7854
MG_NaviPrst := 0
MG_TrailDrawing := 0
MG_ExNaviHwnd := 0
MG_TrailHwnd := 0
cnt := 0
MG_BtnNames :=
Loop, Parse, MG_Triggers, _
{
MG_BtnNames.InsertAt(++cnt, A_LoopField)
}
Loop, Parse, MG_SubTriggers, _
{
MG_BtnNames.InsertAt(++cnt, A_LoopField)
}
if (MG_NaviInterval <= 0) {
MG_NaviInterval := 10
}
if (MG_TrailInterval <= 0) {
MG_TrailInterval := 10
}
}
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Menu Commands
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Toggle Gesture Enabled and Disabled
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_ToggleEnable()
{
global
if (MG_Enabled) {
MG_Disable()
TrayTip, MouseGestureL, %MG_LngTooltip002%
} else {
MG_Enable()
TrayTip, MouseGestureL, %MG_LngTooltip001%
}
SetTimer, MG_HideTrayTip, -1000
}
MG_HideTrayTip() {
TrayTip
}
 
;-------------------------------------------------------------------------------
; Enable Gesture
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Enable()
{
global
MG_Enabled := 1
Loop, Parse, MG_Triggers, _
GoSub, MG_%A_LoopField%_Enable
Menu, %MG_MenuName%, Check, %MG_LngMenu002%
Menu, Tray, Icon, %MG_IconFile%
if (MG_ShowTrail && MG_DrawTrailWnd) {
Gui, MGW_Trail:Show, NA
}
}
 
;-------------------------------------------------------------------------------
; Disable Gesture
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Disable()
{
global
if (MG_Active) {
SetTimer, MG_Disable, -500
} else if (MG_Enabled) {
MG_Enabled := 0
Loop, Parse, MG_Triggers, _
GoSub, MG_%A_LoopField%_Disable
Menu, %MG_MenuName%, Uncheck, %MG_LngMenu002%
Menu, Tray, Icon, %A_WinDir%\system32\shell32.dll,110
if (MG_ShowTrail && MG_DrawTrailWnd) {
Gui, MGW_Trail:Hide
}
}
}
 
;-------------------------------------------------------------------------------
; Edit User Extension Script
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_EditUser()
{
global
if (!FileExist(MG_DirConfig "MG_User.ahk"))
{
local szContents
szContents=
(LTrim
%MG_LngOthers001%
;----- %MG_LngOthers002% ------------------------------------------------
if (!MG_IsEdit) {
;...............................................................................
; %MG_LngOthers004%
 
 
 
 
 
 
 
 
} else {
;...............................................................................
; %MG_LngOthers005%
 
 
 
 
 
 
 
 
}
;...............................................................................
; %MG_LngOthers006%
 
 
 
 
 
 
 
 
;-------------------------------------------------------------------------------
Goto, MG_User_End
 
;----- %MG_LngOthers003% ----------------------------------------
 
 
 
 
 
 
 
 
 
 
;...............................................................................
MG_PostInit() {
; %MG_LngOthers007%
 
 
 
 
 
}
;...............................................................................
ME_PostInit() {
; %MG_LngOthers008%
 
 
 
 
 
}
;-------------------------------------------------------------------------------
MG_User_End:
 
)
FileAppend, %szContents%, %MG_DirConfig%MG_User.ahk, UTF-8
}
local szEditor
if (MG_ScriptEditor != "") {
szEditor := """" MG_ScriptEditor """"
}
else {
szEditor := "notepad"
}
MG_RunAsUser(szEditor " " MG_DirConfig "MG_User.ahk")
}
 
;-------------------------------------------------------------------------------
; Open Plugins Folder
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_OpenPluginsFolder() {
Run, %A_ScriptDir%\Plugins
}
 
;-------------------------------------------------------------------------------
; Show Choose Language Dialog Box
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_ChooseLanguage() {
MG_CheckLanguage(1)
}
 
;-------------------------------------------------------------------------------
; Show About Dialog Box
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_ShowAboutDlg()
{
local Bx, Bw, szWebsite
 
MG_AboutLinks := [["AboutWebIcon" , "S14 w1000" , "Webdings" , 2]
, ["AboutWebsite" , "Underline" , "" , 1]
, ["AboutMirror" , "Underline" , "" , 0]
, ["AboutConIcon" , "S12"   , "Wingdings" , 5]
, ["AboutContact" , "Underline" , "" , 4]]
MG_LinkHover := [ 0, 0, 0, 0, 0 ]
 
Gui, MGW_About:New, -MaximizeBox -MinimizeBox +LastFound HwndMG_hAbout
Gui, MGW_About:Margin, , 12
Gui, MGW_About:Add, Picture, w48 h-1, %MG_IconFile%
Gui, MGW_About:Font, S12
Gui, MGW_About:Add, Text, x+10 yp+4 vTAppName Section, MouseGestureL.ahk Version %MG_Version%
Gui, MGW_About:Font
Gui, MGW_About:Add, Text, xs+8 y+6, [ AutoHotkey Version %A_AhkVersion% ]
Gui, MGW_About:Add, Text, xs+8 y+10, Copyright (C) 2007-2008 lukewarm
Gui, MGW_About:Add, Text, xs+8 y+4,  Copyright (C) 2011-2022 Pyonkichi
Gui, MGW_About:Font, % "cBlue "MG_AboutLinks[1][2], % MG_AboutLinks[1][3]
Gui, MGW_About:Add, Text, xs+4 y+6 vAboutWebIcon gOnLinkClick, % Chr(0x7E)
Gui, MGW_About:Font
Gui, MGW_About:Font, % "cBlue "MG_AboutLinks[2][2], % MG_AboutLinks[2][3]
Gui, MGW_About:Add, Text, x+1 yp+8 vAboutWebsite gOnLinkClick, Website
Gui, MGW_About:Font
Gui, MGW_About:Add, Text, x+5, [
Gui, MGW_About:Font, % "cBlue "MG_AboutLinks[3][2], % MG_AboutLinks[3][3]
Gui, MGW_About:Add, Text, x+2 vAboutMirror gOnLinkClick, Mirror
Gui, MGW_About:Font
Gui, MGW_About:Add, Text, x+2, ]
Gui, MGW_About:Font
Gui, MGW_About:Font, % "cBlue "MG_AboutLinks[4][2], % MG_AboutLinks[4][3]
Gui, MGW_About:Add, Text, x+15 yp-2 vAboutConIcon gOnLinkClick, % Chr(0x2A)
Gui, MGW_About:Font
Gui, MGW_About:Font, % "cBlue "MG_AboutLinks[5][2], % MG_AboutLinks[5][3]
Gui, MGW_About:Add, Text, x+1 yp+2 vAboutContact gOnLinkClick, Contact
Gui, MGW_About:Font
Bw := 80
GuiControlGet, rcCtrl, MGW_About:Pos, TAppName
Bx := rcCtrlX + rcCtrlW - Bw
Gui, MGW_About:Add, Button, x%Bx% y+16 w%Bw% Default gMGW_AboutGuiClose, OK
Gui, MGW_About:Show, Autosize
OnMessage(0x0020, "OnSetcursor")
return
 
OnLinkClick:
if (A_GuiControl="AboutWebIcon" || A_GuiControl="AboutWebsite") {
Run, % "https://hp.vector.co.jp/authors/VA018351/" (MG_Language="Japanese" ? "" : "en/") "mglahk.html"
}
else if (A_GuiControl="AboutMirror") {
Run, % "http://pyonkichi.g1.xrea.com/" (MG_Language="Japanese" ? "" : "en/") "mglahk.html"
}
else if (A_GuiControl="AboutConIcon" || A_GuiControl="AboutContact") {
}
MGW_AboutGuiClose:
MGW_AboutGuiEscape:
OnMessage(0x0020, "")
Gui, MGW_About:Destroy
return
}
 
;-------------------------------------------------------------------------------
; WM_SETCURSOR Message Handler
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
OnSetcursor(wParam, lParam, uMsg, hWnd)
{
local x, y, rc, rcX, rcY, rcW, rcH, hCursor, bHov
 
if (WinExist("ahk_id " MG_hAbout) && (hWnd = MG_hAbout)) {
CoordMode, Mouse, Client
MouseGetPos, x, y
CoordMode, Mouse, Screen
hCursor := 0
bHov := [ 0, 0, 0, 0, 0 ]
Loop, % MG_AboutLinks.MaxIndex() {
GuiControlGet, rc, MGW_About:Pos, % MG_AboutLinks[A_Index][1]
if (x>=rcX && x<(rcX+rcW) && y>=rcY && y<(rcY+rcH)) {
hCursor := DllCall("LoadCursor", Ptr,0, UInt,32649, Ptr)
bHov[A_Index] := 1
if (MG_AboutLinks[A_Index][4]) {
bHov[MG_AboutLinks[A_Index][4]] := 1
}
}
}
if (!hCursor) {
hCursor := DllCall("LoadCursor", Ptr,0, UInt,32512, Ptr)
}
DllCall("SetCursor", Ptr,hCursor)
Loop, % MG_AboutLinks.MaxIndex() {
if (MG_LinkHover[A_Index] != bHov[A_Index]) {
MG_LinkHover[A_Index] := bHov[A_Index]
Gui, MGW_About:Font
Gui, MGW_About:Font, % (bHov[A_Index] ? "cRed " : "cBlue ") MG_AboutLinks[A_Index][2], % MG_AboutLinks[A_Index][3]
GuiControl, MGW_About:Font, %  MG_AboutLinks[A_Index][1]
}
}
return true
}
return false
}
 
;-------------------------------------------------------------------------------
; Exit Application
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Exit() {
ExitApp
}
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Gesture Recognition
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Get cursor position and target information
; カーソル位置・ターゲットの情報を取得
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_GetMousePosInfo()
{
global
MG_TickCount := A_TickCount
CoordMode, Mouse, Screen
MouseGetPos, MG_X, MG_Y, MG_HWND, MG_HCTL, 3
SendMessage, 0x84, 0, % MG_Y<<16|MG_X,,ahk_id %MG_HCTL%
if (ErrorLevel == 4294967295) {
MouseGetPos,,,,MG_HCTL, 2
}
MG_Cursor := MG_GetCursor()
if (MG_ActiveAsTarget) {
WinGet, MG_HWND, ID, A
MG_HCTL := MG_GetFocus()
}
IfWinExist,ahk_id %MG_HWND%,,,,{
WinGetClass, MG_WClass
WinGet, MG_PID, PID
WinGetTitle, MG_Title
MG_Exe := MG_GetExeName(MG_HWND)
}
WinGetClass, MG_CClass, ahk_id %MG_HCTL%
if (MG_CClass = "Button") {
MG_CorrectDlgCtrlHandle()
}
}
 
;-------------------------------------------------------------------------------
; Correct target control handle in a dialog box
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CorrectDlgCtrlHandle()
{
global MG_X, MG_Y, MG_HCTL, MG_WClass, MG_ActiveAsTarget
if (MG_WClass!="#32770" || !MG_IsNewOS() || MG_ActiveAsTarget) {
return
}
rc := DllCall("GlobalAlloc", "UInt",0x40, "UInt",16, "Ptr")
hParent := DllCall("GetParent", "Ptr",MG_HCTL)
hCtrl := MG_HCTL
while (hCtrl)
{
hCtrl := DllCall("FindWindowEx", "Ptr",hParent, "Ptr",hCtrl, "Ptr",0, "Ptr",0, "Ptr")
if (!hCtrl) {
break
}
DllCall("GetWindowRect", "Ptr",hCtrl, "Ptr",rc)
if (DllCall("PtInRect", "Ptr",rc, "Int64",MG_Y<<32|MG_X, "Ptr")) {
WinGet, dwStyle, Style, ahk_id %hCtrl%
if (dwStyle & 0x10000000) {
MG_HCTL := hCtrl
}
}
}
WinGetClass, MG_CClass, ahk_id %MG_HCTL%
DllCall("GlobalFree", "Ptr",rc)
}
 
;-------------------------------------------------------------------------------
; Compare Strings
; str1 : First string to be compared. 
; str2 : Second string to be compared. 
; method : Matching rule
; : 1 = Match Exact Word
; : 2 = Match Partial Word
; : 3 = Match Prefix
; : 4 = Match Suffix
; : 5 = Use Regular Expression
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_StrComp(str1, str2, method=1)
{
if (method == 2) {
return (Instr(str1, str2) != 0)
}
else if (method == 3) {
return (Instr(str1, str2) == 1)
}
else if (method == 4) {
start := StrLen(str1) - StrLen(str2) + 1
return (Instr(str1, str2, false, start) == start)
}
else if (method == 5) {
return (RegExMatch(str1, str2) != 0)
}
return (str1 = str2)
}
 
;-------------------------------------------------------------------------------
; Process trigger-down actions
; トリガー押し下げの報告を受け付け
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_TriggerDown(name)
{
global
Critical
if (!InStr(MG_CurTriggers, name . "_")) {
MG_TriggerCount++
MG_UnpressCnt%name% := 0
MG_CurTriggers := MG_CurTriggers . name "_"
if (MG_Active && MG_TimedOut) {
GoSub, MG_%name%_Down
}
else if (MG_TriggerCount==1) {
; Begin to process gesture at first trigger-down
; 最初のトリガーの場合、ジェスチャー処理を実行
if (A_TickCount > (MG_LastTime+MG_DGInterval+MG_WaitNext)) {
MG_Gesture := MG_1stTrigger := name "_"
MG_Snapshot := ""
} else {
MG_Gesture .= name "_"
}
MG_GetMousePosInfo()
MG_NowX:=MG_PreX:=MG_TX:=MG_TL:=MG_TR:=MG_X
MG_NowY:=MG_PreY:=MG_TY:=MG_TT:=MG_TB:=MG_Y
MG_TimeoutEnabled := 1
MG_PrevTime   := A_TickCount
MG_PrevGesture   := ""
MG_NaviPrstStr   := ""
if (MG_IsDisableObj.()) {
GoSub, MG_%name%_Down
}
else {
MG_StartNavi()
MG_StartTrail()
MG_Aborted:=0
MG_Check()
if (MG_Aborted) {
MG_StopNavi(0)
MG_StopTrail()
GoSub,MG_%name%_Down
} else {
MG_Recognition(1)
}
}
} else {
; Otherwise execute gesture
; それ以外の場合、ジェスチャーの発動判定
MG_Recognition()
MG_Gesture .= name "_"
MG_Check()
MG_PreX:=MG_NowX, MG_PreY:=MG_NowY, MG_PrevTime:=A_TickCount
}
}
}
 
;-------------------------------------------------------------------------------
; Process trigger-up actions
; トリガー押し上げの報告を受け付け
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_TriggerUp(name)
{
local px, py, bDef
 
Critical
if (!RegExMatch(MG_CurTriggers,"(?<=_|^)" . name . "_")) {
return
}
bDef := false
if (MG_Active && !MG_Aborted) {
MG_Recognition()
}
MG_TriggerCount := (MG_TriggerCount>0) ? (MG_TriggerCount-1) : 0
MG_CurTriggers := RegExReplace(MG_CurTriggers,"(?<=_|^)" . name . "_")
if (!MG_Active || MG_TimedOut) {
GoSub, MG_%name%_Up
}
else {
MG_Gesture .= "_"
if (!MG_Aborted) {
MG_Check()
}
if (MG_TriggerCount < 1) {
if (MG_NaviPrstStr) {
MG_NaviPrst := 1
SetTimer, MG_NaviPersistTimer, %MG_NaviPersist%
}
MG_StopNavi(0)
MG_StopTrail()
if (MG_CancelDef) {
MG_CancelDef := 0
}
else if (MG_PerformDef) {
if (MG_Executed <= MG_PerformDef) {
bDef := true
}
MG_PerformDef := 0
}
else if (!MG_Executed
&& (!MG_DisableDefMB  || (name!="MB"))
&& (!MG_DisableDefX1B || (name!="X1B"))
&& (!MG_DisableDefX2B || (name!="X2B"))
&& (!MG_PrvntCtxtMenu || (MG_Gesture==name "__"))) {
bDef := true
}
}
}
;...........................................................................
; Emulate trigger if gesture is not executed
; ジェスチャー未発動の場合、トリガー操作をエミュレート
if (bDef) {
CoordMode, Mouse, Screen
SetMouseDelay, -1
BlockInput, On
MouseGetPos, px, py
MouseMove, %MG_X%, %MG_Y%, 0
GoSub, MG_%name%_Down
MouseMove, %px%, %py%, 0
Sleep, 1
GoSub, MG_%name%_Up
BlockInput, Off
}
}
 
;-------------------------------------------------------------------------------
; Process button-press actions
; ボタン操作の報告を受け付け
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_ButtonPress(name)
{
global
if (MG_Active && MG_TimedOut) {
Gosub, MG_%name%_Press
} else {
if (!MG_Active && (A_TickCount>(MG_LastTime+MG_DGInterval+MG_WaitNext))) {
MG_GetMousePosInfo()
if (MG_IsDisableObj.()) {
Gosub, MG_%name%_Press
} else {
MG_Gesture := name "_"
MG_Snapshot := ""
MG_Aborted:=0, MG_WaitNext:=0, MG_Executed:=0, MG_TimedOut:=0, MG_TimeoutEnabled:=1
MG_NowX:=MG_PreX:=MG_X, MG_NowY:=MG_PreY:=MG_Y, MG_PrevTime:=A_TickCount
if (!MG_Check()) {
Gosub, MG_%name%_Press
}
}
} else {
MG_Recognition()
MG_Gesture .= name "_"
if (!MG_Check()) {
Gosub, MG_%name%_Press
}
MG_PreX:=MG_NowX, MG_PreY:=MG_NowY, MG_PrevTime:=A_TickCount
}
}
}
 
;-------------------------------------------------------------------------------
; Check gesture updates
; ジェスチャーが更新される度に実行
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Check(g="")
{
local ges, ex, tmp
MG_LastTime := A_TickCount
if (StrLen(MG_Gesture) > MG_MaxLength) {
; Gesture is too long
; ジェスチャーの長さが定義されている最大長を超えた
MG_Gesture := MG_Snapshot ? MG_Snapshot : MG_CurTriggers
} else {
if (g) {
ges := g
} else {
ges := MG_Gesture
}
if (IsLabel("MG_Gesture_" . ges)) {
if (MG_NaviPersist > 0) {
MG_NaviPrstStr := MG_Gesture
}
IfWinExist, ahk_id %MG_HWND%,,,,{
}
ex := MG_Executed++
(MG_ShowLogs && !g) ? MG_UpdateLogs(ges) :
if ((MG_HWND != MG_ExNaviHwnd) && (MG_HWND != MG_TrailHwnd)) {
Gosub, MG_Gesture_%ges%
} else {
MG_Cancel()
}
if (ex != MG_Executed) {
if (!g) {
MG_Gesture := MG_Snapshot ? MG_Snapshot : MG_CurTriggers
}
return 1
} else {
return (MG_WaitNext != 0)
}
}
}
MG_ShowLogs ? MG_UpdateLogs() :
return 0
}
 
;-------------------------------------------------------------------------------
; Recognition function
; 認識処理の本体
; fInit : 1 = Initialize recognition process
; 0 = Recognition only
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Recognition(fInit=0)
{
global
static px, py, plx, ply, dir, prev_dir, orange, next_timeout
local powx, powy
;...........................................................................
; Initialization of recognition process
if (fInit) {
MG_Active:=1, MG_Aborted:=0, MG_WaitNext:=0, MG_Executed:=0, MG_TimedOut:=0
px:=plx:=MG_X, py:=ply:=MG_Y, dir:="", prev_dir:=""
orange:=MG_ORange%MG_ORangeDefault%, next_timeout:=A_TickCount+MG_Timeout
MG_ScreenDPI := MG_GetDpiFromPoint(MG_X, MG_Y)
Loop,Parse,MG_SubTriggers,_
{
GoSub,MG_%A_LoopField%_Enable
}
SetTimer, MG_RecogTimer, %MG_Interval%
}
;...........................................................................
; Recognition process
CoordMode, Mouse, Screen
MouseGetPos, MG_NowX, MG_NowY
if (MG_TriggerCount < 1) {
; Release all triggers : 全てのトリガが離された
SetTimer, MG_RecogTimer, Off
MG_Active:=0, MG_TriggerCount:=0, MG_CurTriggers:=""
Loop, Parse, MG_SubTriggers, _
{
GoSub, MG_%A_LoopField%_Disable
}
MG_StopNavi(0)
MG_StopTrail()
}
else if ((MG_X-MG_NowX)**2+(MG_Y-MG_NowY)**2 < MG_TimeoutThreshold**2) {
; Tiny movement : 微小な動き
next_timeout:=A_TickCount+MG_Timeout
}
else if (!MG_TimedOut
&& (MG_Aborted
  || (MG_TimeoutEnabled && MG_Timeout && (A_TickCount>next_timeout) && !MG_Executed)))
{
; Time out when moving : 移動中にタイムアウト
MG_StopNavi(0)
MG_StopTrail()
Critical
SetMouseDelay, -1
MG_TimedOut=1
BlockInput, On
MouseMove, %MG_X%, %MG_Y%,0
Loop, Parse, MG_CurTriggers, _
{
if (A_LoopField) {
GoSub, MG_%A_LoopField%_Down
}
}
MouseMove, %MG_NowX%, %MG_NowY%, 0
BlockInput, Off
Critical, Off
}
else if (!MG_TimedOut && ((powx:=(MG_NowX-px)**2)+(powy:=(MG_NowY-py)**2) >= MG_Threshold**2)) {
; Check Normal Movement : 移動検出
if (MG_8Dir) {
if (orange > Abs(0.7853981634-Abs(ATan((MG_NowX-px)/(MG_NowY-py))))) {
dir := (MG_NowX>px) ? ((MG_NowY>py) ? 3 : 9) : ((MG_NowY>py) ? 1 : 7)
} else {
dir := (powx>powy) ? ((MG_NowX>px) ? 6 : 4) : ((MG_NowY>py) ? 2 : 8)
}
} else {
dir:= (powx>powy) ? ((MG_NowX>px) ? "R":"L") : ((MG_NowY>py) ? "D":"U")
}
; Judge Normal Movement
local fChanged := 0
if (dir != prev_dir) {
fChanged := 1
}
else {
; Check Long Movement
if (MG_8Dir) {
fChanged := ((MG_NowX-plx)**2+(MG_NowY-ply)**2 >= MG_LongThreshold**2)
} else if (powx > powy) {
fChanged := (Abs(MG_NowX-plx) >= MG_LongThresholdX)
} else {
fChanged := (Abs(MG_NowY-ply) >= MG_LongThresholdY)
}
}
; Judge Overall Movement
if (fChanged) {
MG_Gesture .= dir
if (MG_8Dir) {
if (dir & 1) {
orange := MG_ORange%MG_ORangeB%
} else {
orange := MG_ORange%MG_ORangeA%
}
}
plx:=px, ply:=py
prev_dir := MG_Check() ? "" : dir
;MG_PreX:=MG_NowX, MG_PreY:=MG_NowY, MG_PrevTime:=A_TickCount
}
MouseGetPos, px, py
next_timeout := A_TickCount+MG_Timeout
MG_PreX:=px, MG_PreY:=py, MG_PrevTime:=A_TickCount
}
}
MG_RecogTimer() {
MG_Recognition()
}
 
;-------------------------------------------------------------------------------
; Emulate the mouse button events
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SendButton(name, btn, mode="")
{
global
SetMouseDelay,-1
if (MG_%name%_Enabled) {
GoSub, MG_%name%_Disable
MG_%name%_Disabled := 1
} else {
MG_%name%_Disabled := 0
}
Send, % "{Blind}{" . btn . (mode ? " "mode : "") . "}"
if (MG_%name%_Disabled) {
GoSub, MG_%name%_Enable
}
}
 
;-------------------------------------------------------------------------------
; Check unexpected mouse button holding
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CheckButton(name, btn)
{
global
if (MG_Active && MG_TimedOut) {
MG_UnpressCnt%name%++
if (MG_UnpressCnt%name% > MG_TmReleaseTrigger) {
MG_UnpressCnt%name% := 0
MG_TriggerUp(name)
}
} else {
MG_UnpressCnt%name% := 0
}
}
 
;-------------------------------------------------------------------------------
; Cancel mode timer
; * It's for in case of failed in catching the button release events.
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CancelMode()
{
global
; Check Unpressed Mouse Buttons
if (MG_TmReleaseTrigger > 0) {
Loop, Parse, MG_CurTriggers, _
{
local szCheckSub := "MG_" .  A_LoopField . "_Check"
if (IsLabel(szCheckSub)) {
GoSub, %szCheckSub%
}
}
}
; Hide Hints and Trails
if ((!MG_Active && (A_TickCount>(MG_LastTime+MG_DGInterval+MG_WaitNext)))
|| (MG_Active && MG_TimedOut))
{
MG_StopNavi(0)
MG_StopTrail()
}
}
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Script Control Functions
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Abort the gesture
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Abort() {
global
MG_Aborted := 1
}
 
;-------------------------------------------------------------------------------
; Abort the recognition
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Cancel() {
MG_Wait(0)
}
 
;-------------------------------------------------------------------------------
; Wait for the next gesture
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Wait(ms=0) {
global
MG_Executed--
MG_WaitNext := ms
}
 
;-------------------------------------------------------------------------------
; Delayed Execution
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Timer(ms=0)
{
global
if (MG_TimerMode==-1) {
MG_TimerMode := 0
return 0
}
MG_TimerGesture := MG_Gesture
if (ms) {
if (ms>0) {
MG_TimerMode := 1
SetTimer, MG_TimerExecute, % -ms
}else{
MG_TimerMode := 2
MG_Executed--
MG_WaitNext := -ms
SetTimer, MG_TimerExecute, % ms
}
}else{
MG_TimerMode := 3
SetTimer, MG_TimerExecute, % -MG_Interval
}
return 1
}
MG_TimerExecute()
{
global
if ((MG_TimerMode==3) && MG_Active) {
SetTimer, MG_TimerExecute, % -MG_Interval
return
}
if ((MG_TimerMode!=2) || (MG_Gesture=MG_TimerGesture)) {
MG_TimerMode := -1
MG_Check(MG_TimerGesture)
} else {
MG_TimerMode := 0
}
}
 
;-------------------------------------------------------------------------------
; Execute the action when gesture recognition is finished
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Defer() {
return !MG_Timer()
}
 
;-------------------------------------------------------------------------------
; Repeatedly Execution
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_While(ms=20)
{
global
if (!MG_WhileState) {
MG_WhileGesture := MG_Gesture
MG_WhileTrrigers := MG_Triggers
MG_WhileStartTime := A_TickCount
if (ms < 1) {
MG_WhileInterval := MG_Interval
MG_WhileState := 2
}else{
MG_WhileInterval := ms
MG_WhileState := 1
}
}else if (MG_WhileState = -1) {
MG_WhileState := 0
return 0
}
SetTimer, MG_WhileExecute, % -MG_WhileInterval
return 1
}
MG_WhileExecute()
{
global
if (MG_Active && InStr(MG_Triggers, MG_WhileTrrigers)==1) {
SetTimer, MG_WhileExecute, % -MG_WhileInterval
if (MG_WhileState==1) {
MG_Check(MG_WhileGesture)
}
return
}else{
MG_WhileState := -1
MG_Check(MG_WhileGesture)
}
}
 
;-------------------------------------------------------------------------------
; Execute the action when a button is released
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Hold()
{
global
if (MG_HoldState) {
MG_HoldTrrigers := ""
return A_TickCount-MG_HoldStart
}else if (!MG_HoldTrrigers) {
MG_HoldGesture := MG_Gesture
MG_HoldTrrigers := MG_Triggers
MG_HoldStart := A_TickCount
SetTimer, MG_HoldExecute, % -MG_Interval
}
}
MG_HoldExecute()
{
global
if (MG_Active && InStr(MG_Triggers, MG_HoldTrrigers)==1) {
SetTimer, MG_HoldExecute, % -MG_Interval
}else{
MG_HoldState := 1
MG_Check(MG_HoldGesture)
MG_HoldState := 0
}
}
 
;-------------------------------------------------------------------------------
; Count the calling times
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Counter(name="",count=2)
{
global
if (!name) {
name := MG_Gesture
}
if (!MG_Counter_%name%) {
MG_Counter_%name% := 0
}
if (count < -1) {
return Mod(MG_Counter_%name%, -count)
}else if (count == -1) {
return MG_Counter_%name%
}else if (count == 1) {
MG_Counter_%name% := 0
return 0
}else if (count == 0) {
MG_Counter_%name%++
return MG_Counter_%name%
}else{
MG_Counter_%name%++
return Mod(MG_Counter_%name%, count)
}
}
 
;-------------------------------------------------------------------------------
; Perform default behavior
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_PerformDefBehavior(exe_limit=1) {
global
if (exe_limit >= 1) {
MG_PerformDef := exe_limit
MG_CancelDef  := 0
}
}
 
;-------------------------------------------------------------------------------
; Cancel default behavior
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CancelDefBehavior() {
global
MG_PerformDef := 0
MG_CancelDef  := 1
}
 
;-------------------------------------------------------------------------------
; Check if this is the first action at this gesture
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_IsFirstAction() {
global
return (MG_Executed <= 1)
}
 
;-------------------------------------------------------------------------------
; Enable timeout
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_EnableTimeout() {
global
MG_TimeoutEnabled := 1
}
 
;-------------------------------------------------------------------------------
; Disable timeout
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_DisableTimeout() {
global
MG_TimeoutEnabled := 0
}
 
;-------------------------------------------------------------------------------
; Save current gestures
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SaveGesture(ges="") {
global
MG_Snapshot := ges ? ges : MG_Gesture
}
 
;-------------------------------------------------------------------------------
; Set active window as target
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SetActiveAsTarget()
{
global
WinGet, MG_HWND, ID, A
IfWinExist, ahk_id %MG_HWND%,,,,{
WinGetClass, MG_WClass
WinGet, MG_PID, PID
WinGetTitle, MG_Title
MG_Exe := MG_GetExeName(MG_HWND)
}
if (MG_HCTL := MG_GetFocus()) {
WinGetClass, MG_CClass, ahk_id %MG_HCTL%
}
}
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Retrieving target information
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Get the handle of control which has focus
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_GetFocus()
{
size := (4*2 + A_PtrSize*6 + 4*4)
VarSetCapacity(tmp, size)
NumPut(size, tmp, 0)
pos := (4*2 + A_PtrSize)
return DllCall("GetGUIThreadInfo", "UInt",0, "Str",tmp, "UInt") ? NumGet(tmp, pos) : 0
}
 
;-------------------------------------------------------------------------------
; Get the specified information of the target window
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Win(mode) {
local n
WinGet,n,%mode%,ahk_id %MG_HWND%
return n
}
 
;-------------------------------------------------------------------------------
; Get the X-coordinate of the target window
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_WinX(hwnd=0) {
global MG_HWND
WinGetPos,X,,,,ahk_id %MG_HWND%
return X
}
 
;-------------------------------------------------------------------------------
; Get the Y-coordinate of the target window
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_WinY(hwnd=0) {
global MG_HWND
WinGetPos,,Y,,,ahk_id %MG_HWND%
return Y
}
 
;-------------------------------------------------------------------------------
; Get the width of the target window
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_WinW(hwnd=0) {
global MG_HWND
WinGetPos,,,W,,ahk_id %MG_HWND%
return W
}
 
;-------------------------------------------------------------------------------
; Get the height of the target window
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_WinH(hwnd=0) {
global MG_HWND
WinGetPos,,,,H,ahk_id %MG_HWND%
return H
}
 
;-------------------------------------------------------------------------------
; Get the X-coordinate of the target control
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_ControlX() {
global MG_HCTL
ControlGetPos,X,,,,,ahk_id %MG_HCTL%
return X
}
 
;-------------------------------------------------------------------------------
; Get the Y-coordinate of the target control
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_ControlY() {
global MG_HCTL
ControlGetPos,,Y,,,,ahk_id %MG_HCTL%
return Y
}
 
;-------------------------------------------------------------------------------
; Get the width of the target control
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_ControlW() {
global MG_HCTL
ControlGetPos,,,W,,,ahk_id %MG_HCTL%
return W
}
 
;-------------------------------------------------------------------------------
; Get the height of the target control
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_ControlH() {
global MG_HCTL
ControlGetPos,,,,H,,ahk_id %MG_HCTL%
return H
}
 
;-------------------------------------------------------------------------------
; Hittest the target window
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_HitTest(c=0)
{
global
if (c) {
SendMessage,0x84,0,% MG_Y<<16|MG_X,,ahk_id %MG_HCTL%
}else{
SendMessage,0x84,0,% MG_Y<<16|MG_X,,ahk_id %MG_HWND%
}
return (ErrorLevel<8)
? ((ErrorLevel<4)
? ((ErrorLevel<2)
? (ErrorLevel=0 ? "Nowhere" : (c ? "Client" : MG_HitTest(1)))
: (ErrorLevel=2 ? "Caption" : "SysMenu"))
: ((ErrorLevel<6)
? (ErrorLevel=4 ? "SizeBox" : "Menu")
: (ErrorLevel=6 ? "HScroll" : "VScroll")))
: ((ErrorLevel<10)
? ((ErrorLevel=8) ? "MinButton" : "MaxButton")
: ((ErrorLevel<18) ? "SizeBorder" : (ErrorLevel= 18 ? "Border" : (ErrorLevel=20 ? "CloseButton" : "HelpButton"))))
}
 
;-------------------------------------------------------------------------------
; Hittest the target ListView
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_LvHitTest()
{
global MG_PID, MG_CClass, MG_HCTL, MG_X, MG_Y
if (MG_CClass="SysListView32" || MG_CClass="TListView")
{
pt := DllCall("GlobalAlloc", "UInt",0x40, "UInt",8, "Ptr")
NumPut(MG_X, pt+0, 0, "Int")
NumPut(MG_Y, pt+0, 4, "Int")
DllCall("ScreenToClient", "Ptr",MG_HCTL, "Ptr",pt)
hp := DllCall("OpenProcess", "UInt",0x001F0FFF, "UInt",0, "UInt",MG_PID, "Ptr")
size := 8 + A_PtrSize*3
pi := DllCall("VirtualAllocEx", "Ptr",hp, "Ptr",0, "UInt",size, "UInt",0x1000, "UInt",0x4, "Ptr")
DllCall("WriteProcessMemory", "Ptr",hp, "Ptr",pi, "Ptr",pt, "Int",8, "Ptr",0)
SendMessage, 0x1012, 0, %pi%,, ahk_id %MG_HCTL%
DllCall("ReadProcessMemory", "Ptr",hp, "Ptr",pi+8, "PtrP",flag, "UInt",A_PtrSize, "Ptr",0)
DllCall("VirtualFreeEx", "Ptr",hp, "Ptr",pi, "UInt",0, "UInt",0x8000)
DllCall("CloseHandle", Ptr,hp)
DllCall("GlobalFree", "Ptr",pt)
flag := flag & 15
return (flag<4) ? ((flag<2) ? 0 : "ItemIcon") : ((flag<8) ? "ItemLabel" : "ItemState")
}
return 0
}
 
;-------------------------------------------------------------------------------
; Hittest the target TreeView
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_TvHitTest()
{
global MG_PID, MG_CClass, MG_HCTL, MG_X, MG_Y
if (MG_CClass="SysTreeView32" || MG_CClass="TTreeView")
{
pt := DllCall("GlobalAlloc", "UInt",0x40, "UInt",8, "Ptr")
NumPut(MG_X, pt+0, 0, "Int")
NumPut(MG_Y, pt+0, 4, "Int")
DllCall("ScreenToClient", "Ptr",MG_HCTL, "Ptr",pt)
hp := DllCall("OpenProcess", "UInt",0x001F0FFF, "UInt",0, "UInt",MG_PID, "Ptr")
size := 8 + A_PtrSize*2
pi := DllCall("VirtualAllocEx", "Ptr",hp, "Ptr",0, "UInt",size, "UInt",0x1000, "UInt",0x4, "Ptr")
DllCall("WriteProcessMemory", "Ptr",hp, "Ptr",pi, "Ptr",pt, "Int",8, "Ptr",0)
SendMessage, 0x1111, 0, %pi%,, ahk_id %MG_HCTL%
DllCall("ReadProcessMemory", "Ptr",hp, "Ptr",pi+8, "PtrP",flag, "UInt",A_PtrSize, "Ptr",0)
DllCall("VirtualFreeEx", "Ptr",hp, "Ptr",pi, "UInt",0, "UInt",0x8000)
DllCall("CloseHandle", Ptr,hp)
DllCall("GlobalFree", "Ptr",pt)
flag := flag & 127
return (flag<16) ? ((flag<4) ? ((flag<2) ? 0 : "ItemIcon") : ((flag<8) ? "ItemLabel" : "Indent")) : ((flag<32) ? "Button" : ((flag<64) ? "Right" : "ItemState"))
}
return 0
}
 
;-------------------------------------------------------------------------------
; Hittest the DirectUIHWND
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_DuiHitTest()
{
global MG_CClass, MG_X, MG_Y
if (MG_CClass = "DirectUIHWND") {
uia := ComObjCreate("{ff48dba4-60ef-4201-aa87-54103eef594e}","{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")
if (uia) {
uia := new MGC_UIAInterface(uia)
uia.base.base.__UIA := uia
ele := uia.FromPoint(MG_X, MG_Y)
return (ele.id==50006 || ele.id==50007) ? "ItemIcon" : (ele.id==50004) ? "ItemLabel" : ""
}
}
return ""
}
class MGC_UIABase {
__New(p="", flag=1) {
ObjInsert(this,"__Value",p), ObjInsert(this,"__Flag",flag)
}
__Get(member) {
if member not in base,__UIA
{
if (DllCall(this.__Vt(21), "Ptr",this.__Value, "PtrP",out) == 0) {
return out
}
}
}
__Delete() {
this.__Flag ? ObjRelease(this.__Value) :
}
__Vt(n) {
return NumGet(NumGet(this.__Value+0, "Ptr")+n*A_PtrSize, "Ptr")
}
}
class MGC_UIAInterface extends MGC_UIABase {
FromPoint(x, y) {
ele := 0
hr := DllCall(this.__Vt(7), "Ptr",this.__Value, "Int64",y<<32|x, "PtrP",out)
if (hr == 0) {
ele := new MGC_UIAElement(out)
}
return ele
}
}
class MGC_UIAElement extends MGC_UIABase {
static __IID := "{d22108aa-8ac5-49a5-837b-37bbb3d7591e}"
}
 
;-------------------------------------------------------------------------------
; Check whether the cursor is on the item of the ListView and TreeView
; fLvLabel : 0 = Detect only icon of the ListView
; : 1 = Include text label of the ListView
; fTvLabel : 0 = Detect only icon of the TreeView
; : 1 = Include text label of the TreeView
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_TreeListHitTest(fLvLabel=1, fTvLabel=1)
{
lvht := MG_LvHitTest()
if (!lvht) {
lvht := MG_DuiHitTest()
}
if (lvht) {
return (fLvLabel ? true : lvht!="ItemLabel")
}
else if (tvht := MG_TvHitTest()) {
if (!fTvLabel && (tvht="ItemLabel")) {
return false
} else {
return InStr(tvht, "Item")
}
}
return false
}
 
;-------------------------------------------------------------------------------
; Get the EXE file path of the target
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_ExePath(pid=0)
{
global MG_PID
if (!pid) {
pid:=MG_PID
}
len := 260
VarSetCapacity(s, (len+1)*2, 0)
hProc := DllCall("OpenProcess", "UInt",0x410, "UInt",0, "UInt",pid, "Ptr")
if (DllCall("psapi.dll\EnumProcessModules", "Ptr",hProc, "Ptr*",hMod, "Int",4, "Ptr*",nd, "Ptr")<>0) {
DllCall("psapi.dll\GetModuleFileNameEx", "Ptr",hProc, "Ptr",hMod, "Str",s, "Int",len, "Int")
}
DllCall("CloseHandle", Ptr,hProc)
return s
}
 
;-------------------------------------------------------------------------------
; Get the command line of the target
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_CommandLine(pid=0)
{
global MG_PID
if (!pid) {
pid:=MG_PID
}
hProc := DllCall("OpenProcess", "UInt",0x001F0FFF, "UInt",0, "UInt",pid, "Ptr")
 
size := A_PtrSize*6
VarSetCapacity(pbi, size, 0)
DllCall("ntdll\NtQueryInformationProcess", "Ptr",hProc, "Ptr",0, "Ptr",&pbi, "UInt",size, "Ptr",0)
addr := NumGet(pbi, A_PtrSize, "Ptr")
 
size := A_PtrSize*57 + 244
VarSetCapacity(peb, size, 0)
DllCall("ReadProcessMemory", "Ptr",hProc, "Ptr",addr, "Ptr",&peb, "UInt",size, "Ptr",0)
addr := NumGet(peb, A_PtrSize*4, "Ptr")
 
size := A_PtrSize*13 + 24
VarSetCapacity(param, size, 0)
DllCall("ReadProcessMemory", "Ptr",hProc, "Ptr",addr, "Ptr",&param, "UInt",size, "Ptr",0)
length := NumGet(param, A_PtrSize*12+16, "UShort")
addr   := NumGet(param, A_PtrSize*13+16, "Ptr")
 
VarSetCapacity(cmdline, length+2, 0)
DllCall("ReadProcessMemory", "Ptr",hProc, "Ptr",addr, "Ptr",&cmdline, "UInt",length, "Ptr",0)
return cmdline
}
 
;-------------------------------------------------------------------------------
; Get an unique number of the target control
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_CIndex()
{
global MG_HCTL,MG_HWND,MG_CClass
WinGet,hl,ControlListHWND,ahk_id %MG_HWND%
Loop,Parse,hl,`n
{
if (A_LoopField=MG_HCTL) {
idx:=A_Index
break
}
}
WinGet,cl,ControlList,ahk_id %MG_HWND%
Loop,Parse,cl,`n
{
if (A_Index=idx) {
return RegExReplace(A_LoopField,"^" . MG_CClass,"")*1
}
}
}
 
;-------------------------------------------------------------------------------
; Get the list of the target informations
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_DumpWinInfo()
{
global MG_HWND, MG_HCTL, MG_Exe, MG_WClass, MG_Title, MG_CClass
 
WinGetPos,wx,wy,ww,wh,ahk_id %MG_HWND%
ControlGetPos,cx,cy,cw,ch,,ahk_id %MG_HCTL%
 
return "MG_Exe " . MG_Exe
. "`nMG_ExePath() " . MG_ExePath()
. "`nMG_CommandLine() " . MG_CommandLine()
. "`nMG_HitTest() " . MG_HitTest()
. "`nMG_LvHitTest() " . MG_LvHitTest()
. "`nMG_TvHitTest() " . MG_TvHitTest()
. "`nMG_DuiHitTest() " . MG_DuiHitTest()
. "`nMG_WClass " . MG_WClass
. "`nMG_Title " . MG_Title
. "`nMG_WinX() " . wx
. "`nMG_WinY() " . wy
. "`nMG_WinW() " . ww
. "`nMG_WinH() " . wh
. "`nMG_CClass " . MG_CClass
. "`nMG_CIndex() " . MG_CIndex()
. "`nMG_ControlX() " . cx
. "`nMG_ControlY() " . cy
. "`nMG_ControlW() " . cw
. "`nMG_ControlH() " . ch
}
 
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Retrieving information related to the mouse cursor
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Get Handle of Current Cursor
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_GetCursor()
{
VarSetCapacity(infCur, 16+A_PtrSize, 0)
NumPut(16+A_PtrSize, infCur, 0, "UInt")
DllCall("GetCursorInfo", "Ptr",&infCur)
hCursor := NumGet(infCur, 8, "Ptr")
return hCursor
}
 
;-------------------------------------------------------------------------------
; Check whether the cursor is specified one
; idCursor : Cursor ID to check
; fMode : 0 = Check cursor when Gesture is started
; : 1 = Check cursor when Gesture is recognized
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CheckCursor(idCursor=0, fMode=0)
{
global MG_Cursor
hCursor := DllCall("LoadCursor", "Ptr",0, "UInt",idCursor, "Ptr")
if (fMode==0) {
return (hCursor == MG_Cursor)
} else {
return (hCursor == MG_GetCursor())
}
}
 
;-------------------------------------------------------------------------------
; Check whether the cursor is defined by Windows
; fMatch : 1 = Check whether the cursor is defined by Windows
; : 0 = Check whether the cursor is NOT defined by Windows
; fMode : 0 = Check cursor when Gesture is started
; : 1 = Check cursor when Gesture is recognized
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CheckAllCursor(fMatch=0, fMode=0)
{
static tblCursorID := "32512,32513,32649,32514,32515,32648,32650,32651,32646,32645,32644,32642,32643,32516"
 
Loop, Parse, tblCursorID, `,
{
if (MG_CheckCursor(A_LoopField, fMode)) {
return fMatch ? 1 : 0
}
}
return (fMatch ? 0 : 1)
}
 
;-------------------------------------------------------------------------------
; Check whether the cursor is in specified rectangular region
; x, y : X-Y coordinates of upper left corner
; width : Width of rectangular region (0=Use Window Width)
; height : Height of rectangular region (0=Use Window Height)
; target : 0 = X-Y position is relative coordinates of Target Window
;   1 = X-Y position is relative coordinates of Target Control
;   2 = X-Y position is absolute coordinates of Screen
; origin : Origin corner of target window (0=Upper-Left  1=Upper-Right
;   2=Lower-Left  3=Lower-Right)
; fMode : 0 = Check cursor coordinates when Gesture is started
; : 1 = Check cursor coordinates when Gesture is recognized
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CursorInRect(x, y, width, height, target=0, origin=0, fMode=0)
{
global MG_X, MG_Y, MG_HWND, MG_HCTL
if (fMode==0) {
mx:=MG_X, my:=MG_Y
}
else {
CoordMode, Mouse, Screen
MouseGetPos, mx, my
}
;...........................................................................
; Get target rectangle
if (target==0) {
WinGetPos, winX, winY, winW, winH, ahk_id %MG_HWND%
}
else if (target==1) {
WinGetPos, winX, winY, winW, winH, ahk_id %MG_HCTL%
}
else {
SysGet, winX, 76
SysGet, winY, 77
SysGet, winW, 78
SysGet, winH, 79
}
;...........................................................................
; Convert parameters
if (x>0 && x<1) {
x := winW * x
}
if (y>0 && y<1) {
y := winH * y
}
if (width <= 0) {
width := winW + width
}
else if (width<1) {
width := winW * width
}
if (height <= 0) {
height := winH + height
}
else if (height<1) {
height := winH * height
}
;...........................................................................
; Convert coordinates
if (origin==1) {
x1 := winX + winW - 1 + x
y1 := winY + y
}
else if (origin==2) {
x1 := winX + x
y1 := winY + winH - 1 + y
}
else if (origin==3) {
x1 := winX + winW - 1 + x
y1 := winY + winH - 1 + y
}
else {
x1 := winX + x
y1 := winY + y
}
x2  :=  x1 + width  - 1
y2  :=  y1 + height - 1
;...........................................................................
; Check coordinates
if (x1<=mx && mx<=x2
&& y1<=my && my<=y2)
{
return 1
}
return 0
}
 
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Target control functions
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Emulate Mouse Button
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Click(btn, mode="", cnt=1)
{
local back
 
if (mode!="" || cnt<1) {
cnt := 1
}
if (IsLabel("MG_" . btn . "_Press"))
{
Gosub, MG_%btn%_Press
}
else if (IsLabel("MG_" . btn . "_Down"))
{
back := MG_DisableDef%btn%
MG_DisableDef%btn% := 0
Loop, %cnt%
{
if (mode="" || mode="D") {
GoSub, MG_%btn%_Down
}
if (mode="" || mode="U") {
GoSub, MG_%btn%_Up
}
}
MG_DisableDef%btn% := back
}
else
{
if (btn = "LB") {
szButton := "LEFT"
} else if (btn = "RB") {
szButton := "RIGHT"
} else if (btn = "MB") {
szButton := "MIDDLE"
} else if (btn = "X1B") {
szButton := "X1"
} else if (btn = "X2B") {
szButton := "X2"
}
if (mode="") {
MouseClick, %szButton%,,, %cnt%
} else {
MouseClick, %szButton%,,,,, %mode%
}
}
}
 
;-------------------------------------------------------------------------------
; Move Mouse Cursor
; x, y : X-Y coordinates of the cursor
; origin : 0 = Origin point is gesture start position
;   1 = Origin point is action start position
;   2 = Origin point is current cursor position
; abs : 0 = x and y are relative coordinates from the origin point
; : 1 = x and y are absolute coordinates
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_Move(x=0, y=0, origin=0, abs=0)
{
global
CoordMode,Mouse,Screen
SetMouseDelay,-1
local relative:=""
if (abs==0)
{
if (origin==0) {
x+=MG_X, y+=MG_Y
} else if (origin==1) {
x+=MG_NowX, y+=MG_NowY
} else {
relative:="R"
}
}
BlockInput, On
MouseMove, %x%, %y%, 0, %relative%
BlockInput, Off
}
 
;-------------------------------------------------------------------------------
; Scroll
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_Scroll(x=0,y=0,hctl=0)
{
global
if (!hctl) {
hctl:=MG_HCTL
}
Loop,% Abs(x)
PostMessage,0x114,% x>=0,0,,ahk_id %hctl%
Loop,% Abs(y)
PostMessage,0x115,% y>=0,0,,ahk_id %hctl%
}
 
;-------------------------------------------------------------------------------
; Instant Scroll
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_InstantScroll(stay=1,ppc_x=8,ppc_y=12,hctl=0)
{
global
local mx,my,cx,cy
if (!hctl) {
hctl:=MG_HCTL
}
CoordMode,Mouse,Screen
MouseGetPos,mx,my
Loop,% Abs(cx:=((mx-MG_X)//ppc_x))
PostMessage,0x114,% cx>=0,0,,ahk_id %hctl%
Loop,% Abs(cy:=((my-MG_Y)//ppc_y))
PostMessage,0x115,% cy>=0,0,,ahk_id %hctl%
if (stay) {
mx:=mx-cx*ppc_x
my:=my-cy*ppc_y
MouseMove,%mx%,%my%,0
}
}
 
;-------------------------------------------------------------------------------
; Drag Scroll
; Implemented by lukewarm
;-------------------------------------------------------------------------------
MG_DragScroll(ppc_x=8,ppc_y=12,hctl=0)
{
global
static lx:=0,ly:=0,lmx:=0,lmy:=0,lctl:=0
if (!hctl) {
hctl:=MG_HCTL
}
if (lmx!=MG_X || lmy!=MG_Y || lctl!=hctl) {
lmx:=lx:=MG_X
lmy:=ly:=MG_Y
lctl:=hctl
}
CoordMode,Mouse,Screen
MouseGetPos,mx,my
Loop,% Abs(cx:=(mx-lx)//ppc_x)
PostMessage,0x114,% cx<0,0,,ahk_id %hctl%
Loop,% Abs(cy:=(my-ly)//ppc_y)
PostMessage,0x115,% cy<0,0,,ahk_id %hctl%
lx:=lx+cx*ppc_x
ly:=ly+cy*ppc_y
}
 
;-------------------------------------------------------------------------------
; Scroll Completely
; dir   : "V":Vertical Scroll  "H":Horizontal Scroll
; cnt   : Scroll Lines or Pages (Negative Value : Scroll Up or Left)
; fPage : 1=Page Scroll  0=Line Scroll
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_Scroll2(dir, cnt, fPage=0)
{
global MG_HCTL, MG_X, MG_Y, MG_CtlL, MG_CtlT, MG_CtlW, MG_CtlH, MG_hSB
static pEnumChildProc := 0
if (!pEnumChildProc) {
pEnumChildProc := RegisterCallback("MG_EnumChildProc", "Fast")
}
WinGetPos, MG_CtlL, MG_CtlT, MG_CtlW, MG_CtlH, ahk_id %MG_HCTL%
hWnd := MG_HCTL
lParam := 0
MG_hSB := 0
Loop, 2
{
DllCall("EnumChildWindows", "Ptr",hWnd, "Ptr",pEnumChildProc, "Ptr",(dir="V"))
if (MG_hSB) {
lParam := MG_hSB
hWnd := DllCall("GetParent", "Ptr",MG_hSB)
break
}
if (A_Index==1) {
hWnd := DllCall("GetParent", "Ptr",MG_HCTL)
}
}
if (!lParam) {
hWnd := MG_HCTL
}
uMsg := (dir="V") ? 0x115 : 0x114
wParam := (cnt>=0) ? 1 : 0
if (fPage) {
wParam += 2
}
Loop, % Abs(cnt) {
PostMessage, %uMsg%, %wParam%, %lParam%,, ahk_id %hWnd%
Sleep, 1
}
}
 
;-------------------------------------------------------------------------------
; Enumerate Child Windows Callback Function
; hWnd   : Handle to Child Window
; lParam : 1=Vertical Scroll  0=Horizontal Scroll
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_EnumChildProc(hWnd, lParam)
{
global MG_HCTL, MG_X, MG_Y, MG_CtlL, MG_CtlT, MG_CtlW, MG_CtlH, MG_hSB
WinGetClass, szClass, ahk_id %hWnd%
if (!InStr(szClass, "ScrollBar")) {
return true
}
WinGet, dwStyle, Style, ahk_id %hWnd%
if (!(dwStyle & 0x10000000)) {
return true
}
static prevL, prevT
WinGetPos, sbL, sbT, sbW, sbH, ahk_id %hWnd%
if (lParam)
{
if (sbW > sbH) {
return true
}
if ((sbL+sbW)<MG_CtlL || sbL>(MG_CtlL+MG_CtlW) || (sbT+sbH)<=MG_CtlT || sbT>=(MG_CtlT+MG_CtlH))
{
return true
}
if ((MG_Y >= sbT) && (MG_Y < sbT+sbH))
{
MG_hSB := hWnd
return false
}
if (MG_hSB && (abs(MG_Y-sbT) > abs(MG_Y-prevT)))
{
return true
}
}
else
{
if (sbW < sbH) {
return true
}
if ((sbT+sbH)<MG_CtlT || sbT>(MG_CtlT+MG_CtlH) || (sbL+sbW)<=MG_CtlL || sbL>=(MG_CtlL+MG_CtlW))
{
return true
}
if ((MG_X >= sbL) && (MG_X < sbL+sbW))
{
MG_hSB := hWnd
return false
}
if (MG_hSB && (abs(MG_X-sbL) > abs(MG_X-prevL)))
{
return true
}
}
MG_hSB:=hWnd, prevL:=sbL, prevT:=sbT
return true
}
 
;-------------------------------------------------------------------------------
; Drag Scroll Completely
; invert : 0=Scroll against the cursor  1=Follow the cursor
; auto   : 0=Scroll one by one  1=Auto-scrolling
; resV   : Vertical Resolution
; resH   : Horizontal Resolution
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_DragScroll2(invert=1, auto=0, resV=15, resH=30)
{
global MG_HCTL, MG_X, MG_Y, MG_hSB
static lx:=0, ly:=0, lmx:=0, lmy:=0, lctl:=0
if (lmx!=MG_X || lmy!=MG_Y || lctl!=MG_HCTL)
{
lmx:=lx:=MG_X
lmy:=ly:=MG_Y
lctl:=MG_HCTL
}
CoordMode,Mouse,Screen
MouseGetPos,mx,my
if (auto)
{
dX := (mx-MG_X) // resH
dY := (my-MG_Y) // resV
}
else
{
dX := (mx-lx) // resH
dY := (my-ly) // resV
lx += dX*resH
ly += dY*resV
}
dirV := (dY<0 ? -1 : 1) * (invert ? -1 : 1)
dirH := (dX<0 ? -1 : 1) * (invert ? -1 : 1)
dY := abs(dY)
dX := abs(dX)
while (dX>0 || dY>0)
{
if (dY>0) {
MG_Scroll2("V", dirV)
dY--
}
if (dX>0) {
MG_Scroll2("H", dirH)
dX--
}
}
}
 
;-------------------------------------------------------------------------------
; Send Wheel Rotation Message
; dir : "U":Rotation Up  "D":Rotation Down
; counts : Rotation Distance
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SendWheel(dir, counts=1)
{
local szClass
WinGetClass, szClass
if (szClass="ApplicationFrameWindow"
|| szClass="Windows.UI.Core.CoreWindow"
|| szClass="Xaml_WindowedPopupClass")
{
Send, % "{" (dir="U" ? "WheelUp" : "WheelDown") (counts>1 ? " " counts : "") "}"
return
}
if (szClass="tooltips_class32") {
SendMessage, 0x041C
CoordMode, Mouse, Screen
MouseGetPos, MG_X, MG_Y, MG_HWND, MG_HCTL, 3
}
hWnd := MG_HCTL ? MG_HCTL : MG_HWND
wParam := (dir="U" ? 0x00780000*counts : 0xFF880000*counts)
| GetKeyState("LButton")
| GetKeyState("RButton")  << 1
| GetKeyState("Shift")   << 2
| GetKeyState("Ctrl")   << 3
| GetKeyState("MButton")  << 4
| GetKeyState("XButton1") << 5
| GetKeyState("XButton2") << 6
lParam := MG_Y<<16 | MG_X
PostMessage, 0x020A, %wParam%, %lParam%,, ahk_id %hWnd%
}
 
;-------------------------------------------------------------------------------
; Move and Resize the Window
; x : Left coordinates of the window
; y : Upper coordinates of the window
; w : Width of the window
; h : Height of the window
; fRel : Position and Size are (0=Absolute or 1=Relative) Value
; hWnd : Handle of the target window
; ExAreas : Edge areas to exclude from the screen for window arrangement
; bAdjust : Adjusts window size with extended border widths of Aero window
;
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_WinMove(x:="", y:="", w:="", h:="", fRel:=0, hWnd:=0, ExAreas:=0, bAdjust:=0)
{
global MG_X, MG_Y, MG_HWND
 
if (x="" && y="" && w="" && h="") {
return
}
if (!hWnd) {
hWnd := MG_HWND
}
;...........................................................................
; Relative
if (fRel)
{
WinGetPos, winX, winY, winW, winH, ahk_id %hWnd%
; Left Position
if (RegExMatch(x, "([0-9]+)/([0-9]+)", $)) {
winX := winX * $1 // $2
} else if (x<=0 || 1<=x) {
winX += x
} else {
winX *= x
}
; Top Position
if (RegExMatch(y, "([0-9]+)/([0-9]+)", $)) {
winY := winY * $1 // $2
} else if (y<=0 || 1<=y) {
winY += y
} else {
winY *= y
}
; Width
if (RegExMatch(w, "([0-9]+)/([0-9]+)", $)) {
winW := winW * $1 // $2
} else if (w<=0 || 1<=w) {
winW += w
} else {
winW *= w
}
; Height
if (RegExMatch(h, "([0-9]+)/([0-9]+)", $)) {
winH := winH * $1 // $2
} else if (h<=0 || 1<=h) {
winH += h
} else {
winH *= h
}
}
;...........................................................................
; Absolute
else
{
MG_GetMonitorRect(MG_X, MG_Y, dtL, dtT, dtR, dtB, true)
dtL := ExAreas[1] ? dtL+ExAreas[1] : dtL
dtT := ExAreas[2] ? dtT+ExAreas[2] : dtT
dtR := ExAreas[3] ? dtR-ExAreas[3] : dtR
dtB := ExAreas[4] ? dtB-ExAreas[4] : dtB
dtW := dtR - dtL
dtH := dtB - dtT
; Left Position
if (RegExMatch(x, "([0-9]+)/([0-9]+)", $)) {
winX := dtW * $1 // $2
} else if (x<=0 || 1<=x) {
winX := x
} else {
winX := dtW * x
}
winX += dtL
; Top Position
if (RegExMatch(y, "([0-9]+)/([0-9]+)", $)) {
winY := dtH * $1 // $2
} else if (y<=0 || 1<=y) {
winY := y
} else {
winY := dtH * y
}
winY += dtT
; Width
if (RegExMatch(w, "([0-9]+)/([0-9]+)", $)) {
winW := dtW * $1 // $2
} else if (w<0 || 1<=w) {
winW := w
} else {
winW := dtW * (w!=0 ? w : 1)
}
; Height
if (RegExMatch(h, "([0-9]+)/([0-9]+)", $)) {
winH := dtH * $1 // $2
} else if (h<0 || 1<=h) {
winH := h
} else {
winH := dtH * (h!=0 ? h : 1)
}
}
bdL:=0, bdT:=0, bdR:=0, bdB:=0
if (bAdjust) {
MG_GetExtendedWinBorders(hWnd, bdL, bdT, bdR, bdB)
}
winX := (x!="") ? winX-bdL    : ""
winY := (y!="") ? winY-bdT    : ""
winW := (w!="") ? winW+bdL+bdR : ""
winH := (h!="") ? winH+bdT+bdB : ""
WinMove, ahk_id %hWnd%,, winX, winY, winW, winH
}
 
;-------------------------------------------------------------------------------
; Move the window to a specific location
; pos : Location code for window destination
; mon : Monitor number (1 = Primary monitor)
; bAdjust : Adjusts window size with extended border widths of Aero window
; ofsX : Offset value for fine adjustment of horizontal position
; ofsY : Offset value for fine adjustment of vertical position
; hWnd : Handle of the target window
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_WinMoveSpecific(pos, mon:=1, bAdjust:=0, ofsX:=0, ofsY:=0, hWnd:=0)
{
global MG_HWND
static prvX, prvY, hLastWnd:=0
 
SysGet, wa, MonitorWorkArea, % mon!=1 ? mon : ""
if (waLeft == "") {
SysGet, wa, MonitorWorkArea
if (waLeft == "") {
return
}
}
if (!hWnd) {
hWnd := MG_HWND
}
WinGetPos, orgX, orgY, w, h, ahk_id %hWnd%
orgDpi := MG_GetDpiFromWindow(hWnd)
bdL:=0, bdT:=0, bdR:=0, bdB:=0
Loop, 2  {
if (bAdjust) {
MG_GetExtendedWinBorders(hWnd, bdL, bdT, bdR, bdB)
}
if (pos = "C") { ; Center
dstX := (waLeft - bdL + ofsX) + (waRight - waLeft - w)/2
dstY := (waTop - bdT + ofsY) + (waBottom - waTop - h)/2
}
else if (pos = "L") { ; Left
dstX := waLeft - bdL + ofsX
dstY := orgY + ofsY
}
else if (pos = "T") { ; Top
dstX := orgX + ofsX
dstY := waTop - bdT + ofsY
}
else if (pos = "R") { ; Right
dstX := waRight - w + bdR + ofsX
dstY := orgY + ofsY
}
else if (pos = "B") { ; Bottom
dstX := orgX + ofsX
dstY := waBottom - h + bdB + ofsY
}
else if (pos = "LT") { ; Upper left
dstX := waLeft - bdL + ofsX
dstY := waTop - bdT + ofsY
}
else if (pos = "RT") { ; Upper right
dstX := waRight - w + bdR + ofsX
dstY := waTop - bdT + ofsY
}
else if (pos = "LB") { ; Lower left
dstX := waLeft - bdL + ofsX
dstY := waBottom - h + bdB + ofsY
}
else if (pos = "RB") { ; Lower right
dstX := waRight - MG_WinW() + bdR + ofsX
dstY := waBottom - h + bdB + ofsY
}
else if (pos = "O") { ; Original position
if (!WinExist("ahk_id " hLastWnd)) {
return
}
dstX := prvX
dstY := prvY
}
else {
return
}
WinMove, ahk_id %hWnd%,, %dstX%, %dstY%
if (A_Index <= 1) {
dstDpi := MG_GetDpiFromWindow(hWnd)
if (orgDpi == dstDpi) {
break
}
w := MG_AdjustToDPI(w, dstDpi, orgDpi)
h := MG_AdjustToDPI(h, dstDpi, orgDpi)
WinMove, ahk_id %hWnd%,,,, %w%, %h%
}
}
prvX:=orgX, prvY:=orgY, hLastWnd:=hWnd
}
 
;-------------------------------------------------------------------------------
; Get extended border widths of the Aero window
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_GetExtendedWinBorders(hWnd, ByRef bdL, ByRef bdT, ByRef bdR, ByRef bdB)
{
local bAero, rc, aL, aT, aR, aB, nL, nT, nW, nH
 
bdL:=0, bdT:=0, bdR:=0, bdB:=0
bAero := 0
if (DllCall("dwmapi.dll\DwmIsCompositionEnabled", UIntP,bAero, UInt)>=0 && bAero) {
VarSetCapacity(rc, 16, 0)
if (DllCall("dwmapi.dll\DwmGetWindowAttribute", Ptr,hWnd, UInt,9, Ptr,&rc, UInt,16, UInt)>=0) {
aL := NumGet(rc, 0, "Int")
aT := NumGet(rc, 4, "Int")
aR := NumGet(rc, 8, "Int")
aB := NumGet(rc, 12, "Int")
WinGetPos, nL, nT, nW, nH, ahk_id %hWnd%
bdL := aL - nL
bdT := aT - nT
bdR := nL + nW - aR
bdB := nT + nH - aB
}
}
}
 
;-------------------------------------------------------------------------------
; Set window event hook
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SetWinEventHook()
{
local funcHook, hWnd
 
MG_idxActWnd := 0
MG_bActMinWnd := false
MG_aryActWnd :=
MG_FillActiveWindowBuffer()
funcHook := RegisterCallback("MG_EventHookProc", "Fast")
MG_hEventHook := DllCall("SetWinEventHook", UInt,0x0003, UInt,0x0003
, Ptr,0, Ptr,funcHook, UInt,0, UInt,0, UInt,3, Ptr)
WinGet, hWnd, ID, A
MG_EventHookProc(MG_hEventHook, 0x0003, hWnd, 0, 0, 0, 0)
}
 
;-------------------------------------------------------------------------------
; Fill active windows buffer
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_FillActiveWindowBuffer()
{
global MG_aryActWnd
 
Loop, 2 {
; Phase 1 -> Phase 2
phase := A_Index
if (phase == 2) {
DetectHiddenWindows, On
}
WinGet, wnd, List,,,!!!_dummy_dummy_dummy_!!!
Loop, %wnd%
{
hWnd := wnd%A_Index%
if (phase == 1) {
WinGetPos,,,w, h, ahk_id %hWnd%
bTarget := (MG_IsActivationTarget(hWnd) && w!=0 && h!=0)
} else {
bTarget := MG_IsDelphiMinWnd(hWnd)
}
if (bTarget) {
bExist := false
Loop, % MG_aryActWnd.MaxIndex(){
if (MG_aryActWnd[A_Index] == hWnd) {
bExist := true
break
}
}
if (!bExist) {
MG_aryActWnd.Push(hWnd)
}
}
}
}
DetectHiddenWindows, Off
}
 
;-------------------------------------------------------------------------------
; Check whether specified window is minimized Delphi application window
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_IsDelphiMinWnd(hWnd)
{
WinGet, dwStyle, Style, ahk_id %hWnd%
if (!(dwStyle & 0x10000000)) {
WinGet, pid, Pid, ahk_id %hWnd%
hTApp := WinExist("ahk_class TApplication ahk_pid " pid)
if (hTApp && (hTApp!=hWnd)) {
WinGet, dwStyle, Style
if (dwStyle & 0x20000000) {
return hTApp
}
}
}
return 0
}
 
;-------------------------------------------------------------------------------
; Event hook procedure
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_EventHookProc(hWinEventHook, iEvent, hWnd, idObject, idChild, dwEventThread, dwmsEventTime)
{
local idx
static hPrevActive:=0
 
if (iEvent==0x0003 && idObject==0 && hPrevActive!=hWnd) {
if (MG_IsActivationTarget(hPrevActive)) {
idx := MG_aryActWnd.MaxIndex()
DetectHiddenWindows, On
Loop, % MG_aryActWnd.MaxIndex() {
if (!WinExist("ahk_id " MG_aryActWnd[idx])
|| (MG_aryActWnd[idx] == hPrevActive)) {
MG_aryActWnd.RemoveAt(idx)
}
idx--
}
DetectHiddenWindows, Off
MG_aryActWnd.Push(hPrevActive)
}
hPrevActive := hWnd
}
}
 
;-------------------------------------------------------------------------------
; Activate previous active window
; tmLimit : Time limit of subsequent calling (ms)
; bMin    : true=Restore minimized window  false=Ignore minimized window
;
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_ActivatePrevWin(tmLimit=0, bMin=true)
{
global
MG_bActMinWnd := bMin
if (!tmLimit) {
MG_ClearActWndIdx()
}
else {
tmLimit := tmLimit>0 ? -tmLimit : tmLimit
SetTimer, MG_ClearActWndIdx, %tmLimit%
}
SetTimer, MG_PrevWinActivation, -1
}
 
MG_PrevWinActivation()
{
local hWnd, hPrev, dwStyle, hTApp
static hStart:=0
 
WinGet, hWnd, ID, A
if (MG_idxActWnd <= 0) {
hStart := hWnd
MG_aryActWndCopy := MG_aryActWnd.Clone()
MG_idxActWnd := MG_aryActWndCopy.MaxIndex()+1
}
DetectHiddenWindows, On
Loop, % MG_aryActWndCopy.MaxIndex() {
MG_idxActWnd := (MG_idxActWnd > 1) ? MG_idxActWnd-1 : MG_aryActWndCopy.MaxIndex()
hPrev := MG_aryActWndCopy[MG_idxActWnd]
if (hStart && (hStart == hPrev) && (MG_aryActWndCopy.MaxIndex() > 2)) {
MG_aryActWndCopy.RemoveAt(MG_idxActWnd)
MG_aryActWndCopy.InsertAt(1, hStart)
hStart := 0
MG_idxActWnd++
continue
}
if *1 {
; Exclude minimized windows if specified
WinGet, dwStyle, Style, % "ahk_id " hPrev
if (!MG_bActMinWnd && (dwStyle & 0x20000000)) {
continue
}
; Restore minimized Delphi application windows
hTApp := MG_IsDelphiMinWnd(hPrev)
if (hTApp) {
WinRestore, % "ahk_id " hTApp
}
; Exclude in other conditions
else if (!MG_IsActivationTarget(hPrev)) {
continue
}
; Activate
WinActivate, % "ahk_id " hPrev
break
}
}
DetectHiddenWindows, Off
}
 
MG_ClearActWndIdx()
{
global
MG_aryActWndCopy.RemoveAt(1, MG_aryActWndCopy.MaxIndex())
MG_aryActWndCopy := ""
MG_idxActWnd := 0
}
 
;-------------------------------------------------------------------------------
; Simulate Drop Files
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_DropFiles(szFiles="", szWinTitle="")
{
global MG_HWND
if (szFiles = "") {
szFiles := Clipboard
}
if (szWinTitle = "") {
szWinTitle := "ahk_id " . MG_HWND
}
szFiles := RegExReplace(RegExReplace(szFiles,"\n$",""),"\r","")
size := 4*3 + A_PtrSize*2
hDrop := DllCall("GlobalAlloc", "UInt",0x42, "UInt",size+(StrLen(szFiles)+2)*2, "Ptr")
pHDROP := DllCall("GlobalLock", "Ptr",hDrop, "Ptr")
NumPut(size, pHDROP+0) ;offset
NumPut(0   , pHDROP+4) ;pt.x
NumPut(0   , pHDROP+8) ;pt.y
NumPut(0   , pHDROP+8+A_PtrSize,   0, "Ptr") ;fNC
NumPut(1   , pHDROP+8+A_PtrSize*2, 0, "Ptr") ;fWide
pszPath := pHDROP + size
Loop,Parse,szFiles,`n,`r
{
DllCall("RtlMoveMemory", "Ptr",pszPath, "Str",A_LoopField, "UInt",StrLen(A_LoopField)*2)
pszPath += (StrLen(A_LoopField)+1)*2
}
DllCall("GlobalUnlock", "Ptr",hDrop)
PostMessage, 0x233, %hDrop%, 0,,%szWinTitle%
}
 
;-------------------------------------------------------------------------------
; Set the files to clipboard to make copying or moving
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_FilesToClipboard(szFiles="", isMove=0)
{
if (DllCall("OpenClipboard", "Ptr",0))
{
szFiles := RegExReplace(RegExReplace(szFiles,"\n$",""),"\r","")
size := 4*3 + A_PtrSize*2
hData := DllCall("GlobalAlloc", "UInt",0x2042, "UInt",size+(StrLen(szFiles)+2)*2, "Ptr")
pHDROP := DllCall("GlobalLock", "Ptr",hData, "Ptr")
NumPut(size, pHDROP+0) ;offset
NumPut(0   , pHDROP+4) ;pt.x
NumPut(0   , pHDROP+8) ;pt.y
NumPut(0   , pHDROP+8+A_PtrSize,   0, "Ptr") ;fNC
NumPut(1   , pHDROP+8+A_PtrSize*2, 0, "Ptr") ;fWide
pszPath := pHDROP + size
Loop,Parse,szFiles,`n,`r
{
DllCall("RtlMoveMemory", "Ptr",pszPath, "Str",A_LoopField, "UInt",StrLen(A_LoopField)*2)
pszPath += (StrLen(A_LoopField)+1)*2
}
DllCall("EmptyClipboard")
DllCall("SetClipboardData", "Ptr",15, "Ptr",hData)
DllCall("GlobalUnlock", "Ptr",hData)
 
hData := DllCall("GlobalAlloc", "UInt",0x2042, "UInt",A_PtrSize, "Ptr")
p := DllCall("GlobalLock", "Ptr",hData, "Ptr")
NumPut(isMove ? 2 : 1 , p+0, 0, "Ptr")
DllCall("SetClipboardData", "Ptr",DllCall("RegisterClipboardFormat", "Str","Preferred DropEffect"), "Ptr",hData)
DllCall("GlobalUnlock", "Ptr",hData)
DllCall("CloseClipboard")
}
}
 
;-------------------------------------------------------------------------------
; Activate target window and set focus on target control
; bCtrl : true = Set focus on target control
; delay : Delay time for asynchronous activation in milliseconds
;
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_WinActivate(bCtrl:=false, delay:=0)
{
global
MG_bWndActivated := false
MG_bCtrlActivate := bCtrl
if (delay > 0) {
SetTimer, MG_Activation, -%delay%
} else {
MG_Activation()
}
}
 
MG_Activation()
{
local FocusClassNN, hFocusCtrl
 
if (!WinExist("ahk_id " MG_HWND)) {
return
}
Critical
if (!MG_bWndActivated) {
MG_bWndActivated := true
if (!WinActive("ahk_id " MG_HWND)) {
WinActivate, ahk_id %MG_HWND%
}
}
if (MG_bCtrlActivate && MG_bWndActivated) {
ControlGetFocus, FocusClassNN, ahk_id %MG_HWND%
ControlGet, hFocusCtrl, Hwnd,, %FocusClassNN%, ahk_id %MG_HWND%
if (hFocusCtrl != MG_HCTL) {
ControlFocus,, ahk_id %MG_HCTL%
}
}
Critical, Off
}
 
;-------------------------------------------------------------------------------
; Minimize / Close all windows of the same class
; ope   : "Minimize" or "Close"
; szInTitle : Specify a string to filter by window title
; szExTitle : Specify a string to exclude by window title
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_OperateSameClass(ope, szInTitle:="", szExTitle:="", szClass:="")
{
local uMsg, wParam, hWnd, szTitle
 
if (ope = "Minimize") {
uMsg:=0x0112, wParam:=0xF020
} else if (ope = "Close") {
uMsg:=0x0010, wParam:=0
} else {
return
}
if (!szClass) {
szClass := MG_WClass
}
WinGet, WndList, list, ahk_class %szClass%
Loop, %WndList%
{
    hWnd := WndList%A_Index% 
if (szInTitle || szExTitle) {
WinGetTitle, szTitle, ahk_id %hWnd%
if *2
|| (szExTitle &&  InStr(szTitle, szExTitle))) {
continue
}
}
    PostMessage, uMsg, wParam, 0,, ahk_id %hWnd%
}
}
 
;-------------------------------------------------------------------------------
; Tile all windows of the same class
; dir : "H" = Tile horizontally  "V" = Tile vertically
; :  otherwise tile as panes
; exL : Excluding area of screen left side 
; exT : Excluding area of screen upper side
; exR : Excluding area of screen right side
; exB : Excluding area of screen lower side
; bAdjust : Adjusts window size with extended border widths of Aero window
;
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_TileSameClass(dir:="", exL:=0, exT:=0, exR:=0, exB:=0, bAdjust=1, szClass:="")
{
local x, y, w, h, nX, nY, hWnd, dwStyle, aryEx
 
if (!szClass) {
szClass := MG_WClass
}
WinGet, WndList, list, ahk_class %MG_WClass%
x:=y:=w:=h:=0, nX:=nY:=1
if (WndList > 1) {
if (dir=="H") {
nY := WndList
} else if (dir=="V") {
nX := WndList
} else {
nX := Ceil(Sqrt(WndList))
nY := Ceil(WndList / nX)
}
w := nX>1 ? "1/" nX : 0
h := nY>1 ? "1/" nY : 0
}
Loop, %WndList%
{
    hWnd := WndList%A_Index%
WinGet, dwStyle, Style, ahk_id %hWnd%
if (dwStyle & 0x20000000) {
    WinRestore, ahk_id %hWnd%
}
    x := nX>1 ? Mod(A_Index-1, nX) "/" nX : 0
    y := nY>1 ? (A_Index-1)//nX "/" nY : 0
    aryEx := [exL, exT, exR, exB]
MG_WinMove(x, y, w, h,, hWnd, aryEx, bAdjust)
}
}
 
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Gesture Hints
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Initialize Gesture Hints
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_InitNavi()
{
global
if (MG_UseExNavi==4) {
MG_LoadIniFile()
}
if (MG_UseNavi) {
MG_NaviEnabled := 1
Menu, %MG_MenuName%, Check, %MG_LngMenu003%
if (MG_UseExNavi) {
MG_CreateExNavi()
}
}
}
 
;-------------------------------------------------------------------------------
; Toggle Gesture Hints
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_NaviToggleEnable()
{
global
MG_NaviEnabled := !MG_NaviEnabled
Menu, %MG_MenuName%, % MG_NaviEnabled ? "Check" : "Uncheck", %MG_LngMenu003%
if (MG_NaviEnabled)
{
if (MG_UseExNavi) {
MG_CreateExNavi()
}
TrayTip, MouseGestureL, %MG_LngTooltip003%
}
else
{
if (MG_UseExNavi) {
MG_DestroyExNavi()
}
TrayTip, MouseGestureL, %MG_LngTooltip004%
}
SetTimer, MG_HideTrayTip, -1000
}
 
;-------------------------------------------------------------------------------
; Start Gesture Hints
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_StartNavi()
{
global
if (MG_NaviEnabled) {
SetTimer, MG_NaviPersistTimer, Off
MG_NaviPrst := 0
MG_SetExNaviBgColor()
MG_GetTargetMonitorRect()
MG_NaviUpdate()
SetTimer, MG_NaviUpdate, %MG_NaviInterval%
}
}
 
;-------------------------------------------------------------------------------
; Stop Gesture Hints
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_StopNavi(fForce=1)
{
global
if (MG_NaviEnabled) {
if (fForce) {
SetTimer, MG_NaviPersistTimer, Off
MG_NaviPrst := 0
}
else if (MG_NaviPrst) {
return
}
SetTimer, MG_NaviUpdate, Off
if (MG_UseExNavi) {
Gui, MGW_ExNavi:Show, Hide
} else {
Tooltip
MG_Tooltip=
}
}
}
 
;-------------------------------------------------------------------------------
; Update Gesture Hints
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_NaviUpdate()
{
global
if (MG_UseExNavi==1 || MG_UseExNavi==2) {
MG_UpdateExNavi()
}
else if (MG_UseExNavi==3 || MG_UseExNavi==4) {
MG_UpdateAdNavi()
}
else {
MG_UpdateNavi()
}
}
 
;-------------------------------------------------------------------------------
; Update Hint Tips
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateNavi()
{
global
if (MG_Tooltip) {
ToolTip,% RegExReplace(MG_Tooltip,"(?<=^|\n)\t+")
}
else if (MG_Tooltip_%MG_Gesture%) {
ToolTip,% MG_Tooltip_%MG_Gesture%
}
else if (MG_NaviPrst) {
Tooltip, %MG_NaviPrstStr%
}
else {
Tooltip, %MG_Gesture%
}
}
 
;-------------------------------------------------------------------------------
; Hints Persistence Timer
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_NaviPersistTimer()
{
SetTimer, MG_NaviPersistTimer, Off
MG_StopNavi(1)
}
 
;-------------------------------------------------------------------------------
; Create Gesture Hints Window
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_CreateExNavi()
{
global
Gui, MGW_ExNavi:New
Gui, MGW_ExNavi:+HwndMG_ExNaviHwnd -Caption +ToolWindow +AlwaysOnTop +LastFound -DPIScale
if (MG_UseExNavi==1 || MG_UseExNavi==2)
{
if (MG_ExNaviTransBG) {
MG_ExNaviBG := MG_MakeTransColor(MG_ExNaviFG)
}
else if *3 {
WinSet, Transparent, %MG_ExNaviTranspcy%
}
MG_ExNaviFG2 := MG_ConvertHex(MG_ExNaviFG)
MG_ExNaviBG2 := MG_ConvertHex(MG_ExNaviBG)
}
else if (MG_UseExNavi==3 || MG_UseExNavi==4)
{
MG_AdNaviFG2 := MG_ConvertHex(MG_AdNaviFG)
MG_AdNaviNI2 := MG_ConvertHex(MG_AdNaviNI)
MG_AdNaviBG2 := MG_ConvertHex(MG_AdNaviBG)
MG_AdNaviTransClr := MG_MakeTransColor(MG_AdNaviBG)
MG_AdNaviTransClr2 := MG_ConvertHex(MG_AdNaviTransClr)
Gui, MGW_ExNavi:Color, %MG_AdNaviBG%
local colorBG := MG_AdNaviTransClr
if (0<MG_AdNaviTranspcy && MG_AdNaviTranspcy<255) {
colorBG .= " " . MG_AdNaviTranspcy
}
WinSet, TransColor, %colorBG%
}
}
 
;-------------------------------------------------------------------------------
; Make Transparent Color
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_MakeTransColor(color)
{
RegExMatch(color, "([a-zA-Z0-9][a-zA-Z0-9])([a-zA-Z0-9][a-zA-Z0-9])([a-zA-Z0-9][a-zA-Z0-9])", $)
RR := "0x" . $1, RR += (RR>0) ? -1 : 1
GG := "0x" . $2, GG += (GG>0) ? -1 : 1
BB := "0x" . $3, BB += (BB>0) ? -1 : 1
SetFormat, IntegerFast, H
colTrans := (RR<<16) + (GG<<8) + BB
colTrans := RegExReplace(colTrans, "^0x")
SetFormat, IntegerFast, D
len := StrLen(colTrans)
Loop, % (6 - len)
{
colTrans := "0" . colTrans
}
return colTrans
}
 
;-------------------------------------------------------------------------------
; Convert String Hexadecimal
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_ConvertHex(hex)
{
return RegExReplace(hex
,"([a-zA-Z0-9][a-zA-Z0-9])([a-zA-Z0-9][a-zA-Z0-9])([a-zA-Z0-9][a-zA-Z0-9])"
,"0x$3$2$1")
}
 
;-------------------------------------------------------------------------------
; Destroy Gesture Hints Window
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_DestroyExNavi()
{
Gui, MGW_ExNavi:Destroy
}
 
;-------------------------------------------------------------------------------
; Set Arrow Hints Background Color and Transparency
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SetExNaviBgColor()
{
global
if (MG_UseExNavi!=1 && MG_UseExNavi!=2)
{
return
}
RegExMatch(MG_Gesture, "(\w+)_", $)
MG_ExNaviIdvFG := (MG_ExNaviFG_%$1% != "") ? MG_ConvertHex(MG_ExNaviFG_%$1%) : ""
MG_ExNaviIdvBG := ""
local colorBG := MG_ExNaviBG
if (MG_ExNaviTransBG)
{
if (MG_ExNaviFG_%$1% != "")
{
colorBG := MG_MakeTransColor(MG_ExNaviFG_%$1%)
MG_ExNaviIdvBG := MG_ConvertHex(colorBG)
}
local trans := ""
if (0<MG_ExNaviTranspcy && MG_ExNaviTranspcy<255) {
trans := " " . MG_ExNaviTranspcy
}
Gui, MGW_ExNavi:+LastFound
WinSet, TransColor, %colorBG%%trans%
}
Gui, MGW_ExNavi:Color, %colorBG%
}
 
;-------------------------------------------------------------------------------
; Get Work Area of Target Monitor
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_GetTargetMonitorRect()
{
global
if *4
{
MG_GetMonitorRect(MG_X, MG_Y, MG_MonitorL, MG_MonitorT, MG_MonitorR, MG_MonitorB, true)
}
}
 
;-------------------------------------------------------------------------------
; Update Arrow Hints
; Implemented by lukewarm
; Modified by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateExNavi()
{
global
static prevX:=0, prevY:=0
;...........................................................................
; Critical Section
static fCritical := 0
if (fCritical) {
return
}
fCritical := 1
;...........................................................................
; Make Arrows String and Check Gesture Conditions
local szGesture := MG_NaviPrst ? MG_NaviPrstStr : MG_Gesture
local szArrows := MG_MakeArrowsStr(szGesture)
if (!szArrows)
{
fCritical := 0
return
}
;...........................................................................
; Decide Drawing Position
local winX, winY, newDPI, bDpiChanged:=false
if (MG_ExNaviMargin < 0)
{
winX:=MG_X, winY:=MG_Y
}
else
{
CoordMode, Mouse, Screen
MouseGetPos, winX, winY
winX += MG_AdjustToDPI(MG_ExNaviMargin)
winY += MG_AdjustToDPI(MG_ExNaviMargin)
if (prevX!=winX || prevY!=winY) {
newDPI := MG_GetDpiFromPoint(winX, winY)
if (newDPI != MG_ScreenDPI) {
MG_ScreenDPI := newDPI
bDpiChanged := true
}
}
}
;...........................................................................
; Draw Arrows
if *5
local size
VarSetCapacity(size, 8, 0)
DllCall("GetTextExtentPoint32", "Ptr",hDC, "Str",szArrows, "Int",StrLen(szArrows), "Ptr",&size)
local winW := NumGet(size, 0, "UInt") + MG_AdjustToDPI(MG_ExNaviPadding)*2
local winH := NumGet(size, 4, "UInt") + MG_AdjustToDPI(MG_ExNaviPadding)*2
if (winW && winH)
{
Gui, MGW_ExNavi:Show, x%winX% y%winY% w%winW% h%winH% NA
MG_EraseArrows(hDC, clrBG)
DllCall("TextOut", "Ptr",hDC, "Int",MG_AdjustToDPI(MG_ExNaviPadding)
, "Int",MG_AdjustToDPI(MG_ExNaviPadding), "Str",szArrows, "Int",StrLen(szArrows))
}
}
 
;-------------------------------------------------------------------------------
; Update Hint Arrows Type 2
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateArrowHints2(hDC, szGesture, szArrows, winX, winY, clrBG)
{
global
local size
VarSetCapacity(size, 8, 0)
local OneArrow = SubStr(szArrows, 1, 1)
DllCall("GetTextExtentPoint32", "Ptr",hDC, "Str",OneArrow, "Int",1, "Ptr",&size)
local w := NumGet(size, 0, "UInt")
local h := NumGet(size, 4, "UInt")
local FullW := (w > h) ? w : h
FullW += MG_AdjustToDPI(MG_ExNaviSpacing)
local HalfW := FullW
HalfW /= 2
 
local maxX:=0, maxY:=0, minX:=0, minY:=0
Loop, Parse, szArrows
{
local preIdx := A_Index - 1
if (MG_ArrowPos%A_Index% ==  1) {
ArrowX%A_Index% := ArrowX%preIdx% - FullW
ArrowY%A_Index% := ArrowY%preIdx% + FullW
}
else if (MG_ArrowPos%A_Index% ==  2) {
ArrowX%A_Index% := ArrowX%preIdx%
ArrowY%A_Index% := ArrowY%preIdx% + FullW
}
else if (MG_ArrowPos%A_Index% ==  3) {
ArrowX%A_Index% := ArrowX%preIdx% + FullW
ArrowY%A_Index% := ArrowY%preIdx% + FullW
}
else if (MG_ArrowPos%A_Index% ==  4) {
ArrowX%A_Index% := ArrowX%preIdx% - FullW
ArrowY%A_Index% := ArrowY%preIdx%
}
else if (MG_ArrowPos%A_Index% ==  6) {
ArrowX%A_Index% := ArrowX%preIdx% + FullW
ArrowY%A_Index% := ArrowY%preIdx%
}
else if (MG_ArrowPos%A_Index% ==  7) {
ArrowX%A_Index% := ArrowX%preIdx% - FullW
ArrowY%A_Index% := ArrowY%preIdx% - FullW
}
else if (MG_ArrowPos%A_Index% ==  8) {
ArrowX%A_Index% := ArrowX%preIdx%
ArrowY%A_Index% := ArrowY%preIdx% - FullW
}
else if (MG_ArrowPos%A_Index% ==  9) {
ArrowX%A_Index% := ArrowX%preIdx% + FullW
ArrowY%A_Index% := ArrowY%preIdx% - FullW
}
else if (MG_ArrowPos%A_Index% == 10) {
ArrowX%A_Index% := ArrowX%preIdx% - HalfW
ArrowY%A_Index% := ArrowY%preIdx% - FullW
}
else if (MG_ArrowPos%A_Index% == 11) {
ArrowX%A_Index% := ArrowX%preIdx% - FullW
ArrowY%A_Index% := ArrowY%preIdx% - HalfW
}
else if (MG_ArrowPos%A_Index% == 12) {
ArrowX%A_Index% := ArrowX%preIdx% + FullW
ArrowY%A_Index% := ArrowY%preIdx% - HalfW
}
else if (MG_ArrowPos%A_Index% == 13) {
ArrowX%A_Index% := ArrowX%preIdx% + HalfW
ArrowY%A_Index% := ArrowY%preIdx% - FullW
}
else if (MG_ArrowPos%A_Index% == 14) {
ArrowX%A_Index% := ArrowX%preIdx% + HalfW
ArrowY%A_Index% := ArrowY%preIdx% + FullW
}
else if (MG_ArrowPos%A_Index% == 15) {
ArrowX%A_Index% := ArrowX%preIdx% + FullW
ArrowY%A_Index% := ArrowY%preIdx% + HalfW
}
else if (MG_ArrowPos%A_Index% == 16) {
ArrowX%A_Index% := ArrowX%preIdx% - FullW
ArrowY%A_Index% := ArrowY%preIdx% + HalfW
}
else if (MG_ArrowPos%A_Index% == 17) {
ArrowX%A_Index% := ArrowX%preIdx% - HalfW
ArrowY%A_Index% := ArrowY%preIdx% + FullW
}
else {
ArrowX%A_Index% := 0
ArrowY%A_Index% := 0
}
if (maxX < ArrowX%A_Index%) {
maxX := ArrowX%A_Index%
}
if (maxY < ArrowY%A_Index%) {
maxY := ArrowY%A_Index%
}
if (minX > ArrowX%A_Index%) {
minX := ArrowX%A_Index%
}
if (minY > ArrowY%A_Index%) {
minY := ArrowY%A_Index%
}
}
local winW := maxX - minX + FullW - MG_AdjustToDPI(MG_ExNaviSpacing)
local winH := maxY - minY + FullW - MG_AdjustToDPI(MG_ExNaviSpacing)
if (winW && winH)
{
Gui, MGW_ExNavi:Show, x%winX% y%winY% w%winW% h%winH% NA
MG_EraseArrows(hDC, clrBG)
Loop, Parse, szArrows
{
local posX := ArrowX1 + ArrowX%A_Index% - minX
local posY := ArrowY1 + ArrowY%A_Index% - minY
DllCall("TextOut", "Ptr",hDC, "Int",posX, "Int",posY, "Str",A_LoopField, "Int",1)
}
}
}
 
;-------------------------------------------------------------------------------
; Erase hint arrows with filling by background color
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_EraseArrows(hDC, clrBG)
{
local w, h, rc, hBrush
WinGetPos,,, w, h, ahk_id %MG_ExNaviHwnd%
VarSetCapacity(rc, 16, 0)
NumPut(w, rc,  8, "UInt")
NumPut(h, rc, 12, "UInt")
hBrush := DllCall("CreateSolidBrush", "UInt",clrBG, "Ptr")
DllCall("FillRect", "Ptr",hDC, "Ptr",&rc, "Ptr",hBrush)
DllCall("DeleteObject", "Ptr",hBrush)
}
 
;-------------------------------------------------------------------------------
; Make Arrows String
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_MakeArrowsStr(szGesture)
{
global
static DirD:=0xEA, DirL:=0xE7, DirR:=0xE8, DirU:=0xE9
static Dir1:=0xED, Dir2:=0xEA, Dir3:=0xEE, Dir4:=0xE7, Dir6:=0xE8, Dir7:=0xEB, Dir8:=0xE9, Dir9:=0xEC
static Next11:=1, Next12:=17, Next13:=2, Next14:=16, Next16:=2, Next17:=4, Next18:=4, Next19:=9
static Next21:=17, Next22:=2, Next23:=14, Next24:=1, Next26:=3, Next27:=4, Next28:=8, Next29:=6
static Next31:=2, Next32:=14, Next33:=3, Next34:=2, Next36:=15, Next37:=7, Next38:=6, Next39:=6
static Next41:=16, Next42:=1, Next43:=2, Next44:=4, Next46:=6, Next47:=11, Next48:=7, Next49:=8
static Next61:=2, Next62:=3, Next63:=15, Next64:=4, Next66:=6, Next67:=8, Next68:=9, Next69:=12
static Next71:=4, Next72:=4, Next73:=3, Next74:=11, Next76:=8, Next77:=7, Next78:=10, Next79:=8
static Next81:=4, Next82:=2, Next83:=6, Next84:=7, Next86:=9, Next87:=10, Next88:=8, Next89:=13
static Next91:=1, Next92:=6, Next93:=6, Next94:=8, Next96:=12, Next97:=8, Next98:=13, Next99:=9
 
Loop, % MG_BtnNames.MaxIndex() {
if (MG_BtnNames[A_Index]) {
szGesture := RegExReplace(szGesture, MG_BtnNames[A_Index] . "_")
}
}
szGesture := RegExReplace(szGesture, "_")
RegExMatch(szGesture, "[DLRU12346789]*", $)
if (!StrLen($))
{
return
}
local szArrows:="", num:=0, dirPrev:=0
Loop, Parse, $
{
szArrows .= Chr(Dir%A_LoopField%)
if (MG_UseExNavi==2)
{
local dirThis:=A_LoopField
if (dirThis = "L") {
dirThis:="4"
}
else if (dirThis = "R") {
dirThis:="6"
}
else if (dirThis = "U") {
dirThis:="8"
}
else if (dirThis = "D") {
dirThis:="2"
}
num++
MG_ArrowPos%num% := Next%dirPrev%%dirThis%
dirPrev := dirThis
}
}
return szArrows
}
 
;-------------------------------------------------------------------------------
; Update Advanced Gesture Hints
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateAdNavi()
{
global
static prevX:=0, prevY:=0
;...........................................................................
; Critical Section
static fCritical := 0
if (fCritical) {
return
}
fCritical := 1
;...........................................................................
; Check Gesture Conditions
local szGesture := MG_NaviPrst ? MG_NaviPrstStr : MG_Gesture
if (!szGesture) {
fCritical := 0
return
}
if (!MG_AdNaviOnClick && (szGesture = MG_1stTrigger)) {
Gui, MGW_ExNavi:Hide
fCritical := 0
return
}
;...........................................................................
; Decide Drawing Position
local winX, winY, newDPI, bDpiChanged:=false
if (MG_AdNaviPosition == 0) {
if (MG_AdNaviMargin < 0) {
winX:=MG_X, winY:=MG_Y
}
else {
CoordMode,Mouse,Screen
MouseGetPos, winX, winY
winX += MG_AdjustToDPI(MG_AdNaviMargin)
winY += MG_AdjustToDPI(MG_AdNaviMargin)
if (prevX!=winX || prevY!=winY) {
newDPI := MG_GetDpiFromPoint(winX, winY)
if (newDPI != MG_ScreenDPI) {
MG_ScreenDPI := newDPI
bDpiChanged := true
}
}
}
}
;...........................................................................
; Draw Gesture Pattern
if *6 {
local dwStyle
WinGet, dwStyle, Style, ahk_id %MG_ExNaviHwnd%
if (dwStyle & 0x10000000) {
Gui, MGW_ExNavi:Show, x%winX% y%winY% NA
}
}
prevX:=winX, prevY:=winY
MG_PrevGesture := szGesture
fCritical := 0
}
 
;-------------------------------------------------------------------------------
; Update Advanced Gesture Hints Type 1
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateAdNavi1(hDC, winX, winY, szGesture)
{
global
local gesW, gesH
MG_DrawGesture(hDC, 0, 0, szGesture, gesW, gesH, 1)
MG_ActionStr := ""
if (IsLabel("MG_GetAction_" . szGesture . "_")) {
GoSub, MG_GetAction_%szGesture%_
}
local actW:=0, actH:=0
if (MG_ActionStr)
{
MG_ActionStr := " : " . MG_ActionStr
MG_DrawAction(hDC, 0, 0, MG_ActionStr, 1, actW, actH)
}
local winW := gesW + actW + MG_AdjustToDPI(MG_AdNaviPaddingL) + MG_AdjustToDPI(MG_AdNaviPaddingR)
local winH := (gesH>actH ? gesH : actH) + MG_AdjustToDPI(MG_AdNaviPaddingT) + MG_AdjustToDPI(MG_AdNaviPaddingB)
if (! winW || !winH) {
return
}
MG_SetAdNaviPos(winX, winY, winW, winH)
Gui, MGW_ExNavi:Show, x%winX% y%winY% w%winW% h%winH% NA
MG_RoundWindow(hDC, winW, winH, MG_AdjustToDPI(MG_AdNaviRound), MG_AdNaviBG2, MG_AdNaviTransClr2)
DllCall("SetTextColor", "Ptr",hDC, "UInt",MG_AdNaviFG2)
MG_DrawGesture(hDC, MG_AdjustToDPI(MG_AdNaviPaddingL), MG_AdjustToDPI(MG_AdNaviPaddingT), szGesture, gesW, gesH)
if (actW) {
MG_DrawAction(hDC, MG_AdjustToDPI(MG_AdNaviPaddingL)+gesW, MG_AdjustToDPI(MG_AdNaviPaddingT), MG_ActionStr)
}
}
 
;-------------------------------------------------------------------------------
; Update Advanced Gesture Hints Type 2 (Gesture Navigation)
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateAdNavi2(hDC, winX, winY, szGesture)
{
global
local gesW:=0, gesH:=0, actW:=0, nGes:=0, szGes:="", len:=StrLen(szGesture)
;...........................................................................
; Compare current gesture to registered gestures
Loop, %Gesture_Count%
{
local idxGes:=A_Index
Loop, Parse, Gesture_%A_Index%_Patterns, `n
{
if (InStr(A_LoopField, szGesture)==1) {
;...............................................................
; Eliminate the cases matched to part of button names
local dir1:=A_LoopField, dir2:=szGesture
Loop, % MG_BtnNames.MaxIndex() {
if (MG_BtnNames[A_Index]) {
dir1 := RegExReplace(dir1, MG_BtnNames[A_Index] . "_")
dir2 := RegExReplace(dir2, MG_BtnNames[A_Index] . "_")
}
}
if (InStr(dir1, dir2)!=1) {
Continue
}
;...............................................................
; Get Bound Action String
MG_ActionStr := ""
if (IsLabel("MG_GetAction_" . A_LoopField)) {
GoSub, MG_GetAction_%A_LoopField%
}
if (!MG_ActionStr) {
Continue
}
;...............................................................
; Update size of area to draw
local tmpW, tmpH1, tmpH2
MG_DrawGesture(hDC, 0, 0, A_LoopField, tmpW, tmpH1, 1)
if (gesW < tmpW) {
gesW := tmpW
}
MG_ActionStr := " : " . MG_ActionStr
MG_DrawAction(hDC, 0, 0, MG_ActionStr, 1, tmpW, tmpH2)
if (actW < tmpW) {
actW := tmpW
}
nGes++
nRowH%nGes% := (tmpH1>=tmpH2) ? tmpH1 : tmpH2
gesH += nRowH%nGes%
szAct%nGes% := MG_ActionStr
szGes .= szGes ? "`," : ""
szGes .= A_LoopField
}
}
}
;...........................................................................
; Draw Gesture Patterns and Bound Actions
if (nGes)
{
local winW := gesW + actW + MG_AdjustToDPI(MG_AdNaviPaddingL) + MG_AdjustToDPI(MG_AdNaviPaddingR)
local winH := gesH + MG_AdjustToDPI(MG_AdNaviPaddingT) + MG_AdjustToDPI(MG_AdNaviPaddingB)
if (! winW || !winH) {
return
}
MG_SetAdNaviPos(winX, winY, winW, winH)
Gui, MGW_ExNavi:Show, x%winX% y%winY% w%winW% h%winH% NA
MG_RoundWindow(hDC, winW, winH, MG_AdjustToDPI(MG_AdNaviRound), MG_AdNaviBG2, MG_AdNaviTransClr2)
local ptY := MG_AdjustToDPI(MG_AdNaviPaddingT)
DllCall("SetTextColor", "Ptr",hDC, "UInt",MG_AdNaviFG2)
Loop, Parse, szGes, `,
{
MG_DrawGesture(hDC, MG_AdjustToDPI(MG_AdNaviPaddingL), ptY, A_LoopField, gesW+actW, nRowH%A_Index%, 0, len)
DllCall("SetTextColor", "Ptr",hDC, "UInt",MG_AdNaviFG2)
MG_DrawAction(hDC, MG_AdjustToDPI(MG_AdNaviPaddingL)+gesW, ptY, szAct%A_Index%)
ptY += nRowH%A_Index%
}
}
else
{
Gui, MGW_ExNavi:Hide
}
}
 
;-------------------------------------------------------------------------------
; Set Display Position of Advanced Gesture Hints
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_SetAdNaviPos(ByRef winX, ByRef winY, winW, winH)
{
global
if (MG_AdNaviPosition == 0) {
return
}
else if (MG_AdNaviPosition == 1) {
winX := MG_MonitorL + MG_AdjustToDPI(MG_AdNaviSpaceX)
winY := MG_MonitorT + MG_AdjustToDPI(MG_AdNaviSpaceY)
}
else if (MG_AdNaviPosition == 2) {
winX := MG_MonitorR - MG_AdjustToDPI(MG_AdNaviSpaceX) - winW
winY := MG_MonitorT + MG_AdjustToDPI(MG_AdNaviSpaceY)
}
else if (MG_AdNaviPosition == 3) {
winX := MG_MonitorL + MG_AdjustToDPI(MG_AdNaviSpaceX)
winY := MG_MonitorB - MG_AdjustToDPI(MG_AdNaviSpaceY) - winH
}
else if (MG_AdNaviPosition == 4) {
winX := MG_MonitorR - MG_AdjustToDPI(MG_AdNaviSpaceX) - winW
winY := MG_MonitorB - MG_AdjustToDPI(MG_AdNaviSpaceY) - winH
}
}
 
;-------------------------------------------------------------------------------
; Round Window Corners
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_RoundWindow(hDC, winW, winH, nRadius, clrBG, clrTrans)
{
if (nRadius <= 0)
{
return
}
winW++, winH++
hBrsB := DllCall("CreateSolidBrush", "UInt",clrBG, "Ptr")
hBrsT := DllCall("CreateSolidBrush", "UInt",clrTrans, "Ptr")
hRgn1 := DllCall("CreateRectRgn", "Int",0, "Int",0, "Int",winW, "Int",winH, "Ptr")
hRgn2 := DllCall("CreateRoundRectRgn", "Int",0, "Int",0, "Int",winW, "Int",winH, "Int",nRadius*2, "Int",nRadius*2, "Ptr")
DllCall("CombineRgn", "Ptr",hRgn1, "Ptr",hRgn1, "Ptr",hRgn2, "Int",4)
DllCall("FillRgn", "Ptr",hDC, "Ptr",hRgn1, "Ptr",hBrsT)
DllCall("FillRgn", "Ptr",hDC, "Ptr",hRgn2, "Ptr",hBrsB)
DllCall("DeleteObject", "Ptr",hBrsB)
DllCall("DeleteObject", "Ptr",hBrsT)
DllCall("DeleteObject", "Ptr",hRgn1)
DllCall("DeleteObject", "Ptr",hRgn2)
}
 
;-------------------------------------------------------------------------------
; Draw Action String
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_DrawAction(hDC, ptX, ptY, szAction, fMeasure=0, ByRef strW=0, ByRef strH=0)
{
global MG_hFntAct, MG_AdNaviNI2
 
hFntOld := DllCall("SelectObject", "Ptr",hDC, "Ptr",MG_hFntAct, "Ptr")
if (fMeasure)
{
VarSetCapacity(size, 8, 0)
DllCall("GetTextExtentPoint32", "Ptr",hDC, "Str",szAction, "Int",StrLen(szAction), "Ptr",&size)
strW := NumGet(size, 0, "UInt")
strH := NumGet(size, 4, "UInt")
}
else
{
DllCall("TextOut", "Ptr",hDC, "Int",ptX, "Int",ptY, "Str",szAction, "Int",StrLen(szAction))
}
DllCall("SelectObject", "Ptr",hDC, "Ptr",hFntOld)
}
 
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Gesture Trails
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Initialize Gesture Trails
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_InitTrail()
{
local style, x, y, width, height, trans
 
if (!MG_ShowTrail) {
return
}
MG_TrailDrawn := 0
MG_TrailColor2 := MG_ConvertHex(MG_TrailColor)
MG_TrailTransClr := (MG_TrailColor!="FF00FF") ? "FF00FF" : "FE00FE"
MG_TrailTransClr2 := MG_ConvertHex(MG_TrailTransClr)
if (MG_DrawTrailWnd)
{
SysGet, x, 76
SysGet, y, 77
SysGet, width,  78
SysGet, height, 79
x++, y++, width--, height--
Gui, MGW_Trail:New
Gui, MGW_Trail:+HwndMG_TrailHwnd -Caption +ToolWindow +E0x08000020 +LastFound
Gui, MGW_Trail:Color, %MG_TrailTransClr%
trans := ""
if (0<MG_TrailTranspcy && MG_TrailTranspcy<255) {
trans := " " . MG_TrailTranspcy
}
WinSet, TransColor, %MG_TrailTransClr%%trans%
Gui, MGW_Trail:Show, x%x% y%y% w%width% h%height% NA
}
}
 
;-------------------------------------------------------------------------------
; Start Gesture Trails
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_StartTrail()
{
global
if (MG_ShowTrail) {
SetTimer, MG_DrawTrail, -1
SetTimer, MG_DrawTrail, %MG_TrailInterval%
}
}
 
;-------------------------------------------------------------------------------
; Stop Gesture Trails
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_StopTrail()
{
global
if (MG_ShowTrail) {
SetTimer, MG_DrawTrail, Off
if (MG_TrailDrawing) {
SetTimer, MG_StopTrail, -100
} else {
MG_ClearTrail()
}
}
}
 
;-------------------------------------------------------------------------------
; Draw Gesture Trails
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_DrawTrail()
{
global
;...........................................................................
; Critical Section
if (!MG_ShowTrail || MG_TrailDrawing) {
return
}
MG_TrailDrawing := 1
;...........................................................................
; Check Cursor Movement
local curX, curY
CoordMode, Mouse, Screen
MouseGetPos, curX, curY
if (!MG_TrailDrawn) {
if ((MG_X-curX)**2+(MG_Y-curY)**2 < MG_TrailStartMove**2) {
MG_TrailDrawing := 0
return
} else {
MG_TrailDrawn := 1
Gui, MGW_Trail:+AlwaysOnTop
}
}
local x1:=MG_TX, y1:=MG_TY, x2:=curX, y2:=curY
if (MG_DrawTrailWnd)
{
Gui, MGW_Trail:+LastFound
WinGetPos, left, top
x1-=left, x2-=left, y1-=top, y2-=top
}
local hWnd := MG_DrawTrailWnd ? MG_TrailHwnd : 0
local hDC := DllCall("GetWindowDC", "Ptr",hWnd, "Ptr")
local hPen := DllCall("CreatePen", "Ptr",0, "Ptr",MG_AdjustToDPI(MG_TrailWidth), "Int",MG_TrailColor2)
local hPenOld := DllCall("SelectObject", "Ptr",hDC, "Ptr",hPen, "Ptr")
DllCall("MoveToEx", "Ptr",hDC, "Ptr",x1, "Ptr",y1, "Ptr",0)
DllCall("LineTo", "Ptr",hDC, "Ptr",x2, "Ptr",y2)
DllCall("SelectObject", "Ptr",hDC, "Ptr",hPenOld)
DllCall("DeleteObject", "Ptr",hPen)
DllCall("ReleaseDC", "Ptr",hWnd, "Ptr",hDC)
MG_TX:=curX, MG_TY:=curY
;...........................................................................
; Update bounding rectangle of Gesture Trail
if (MG_TL > curX) {
MG_TL := curX
}
if (MG_TR < curX) {
MG_TR := curX
}
if (MG_TT > curY) {
MG_TT := curY
}
if (MG_TB < curY) {
MG_TB := curY
}
MG_TrailDrawing := 0
}
 
;-------------------------------------------------------------------------------
; Clear Gesture Trails
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_ClearTrail()
{
local l, t, r, b, rc, owL, owT
 
if (!MG_ShowTrail || !MG_TrailDrawn)
{
return
}
MG_TrailDrawn := 0
;...........................................................................
; Set Bounding Rectangle of Gesture Trail
l := MG_TL-MG_AdjustToDPI(MG_TrailWidth)-1
t := MG_TT-MG_AdjustToDPI(MG_TrailWidth)-1
r := MG_TR+MG_AdjustToDPI(MG_TrailWidth)+1
b := MG_TB+MG_AdjustToDPI(MG_TrailWidth)+1
if (MG_DrawTrailWnd) {
WinGetPos, owL, owT,,, ahk_id %MG_TrailHwnd%
l-=owL, t-=owT, r-=owL, b-=owT
}
VarSetCapacity(rc, 16, 0)
NumPut(l, rc,  0, "UInt")
NumPut(t, rc,  4, "UInt")
NumPut(r, rc,  8, "UInt")
NumPut(b, rc, 12, "UInt")
if (MG_DrawTrailWnd) {
;.......................................................................
; Clear Overwrap Window
local hDC := DllCall("GetWindowDC", "Ptr",MG_TrailHwnd, "Ptr")
local hBrush := DllCall("CreateSolidBrush", "UInt",MG_TrailTransClr2, "Ptr")
DllCall("FillRect", "Ptr",hDC, "Ptr",&rc, "Ptr",hBrush)
DllCall("DeleteObject", "Ptr",hBrush)
DllCall("ReleaseDC", "Ptr",MG_TrailHwnd, "Ptr",hDC)
Gui, MGW_Trail:-AlwaysOnTop
WinSet, Bottom,, ahk_id %MG_TrailHwnd%
} else {
;.......................................................................
; Redraw Screen
DllCall("RedrawWindow", "Ptr",0, "Ptr",&rc, "Ptr",0, "Ptr",0x0587)
}
}
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Log Display
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Initialize Log Display
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_InitLog()
{
global
if (!MG_ShowLogs) {
return
}
MG_Log := []
MG_LogPtr := MG_LogMax
Gui, MGW_LogBG:New, -Caption +LastFound +ToolWindow +E0x08000020
WinSet, Transparent, %MG_LogTranspcy%
Gui, MGW_LogBG:Color, %MG_LogBG%
 
local color, x, y, w, h, wa, waRight, waBottom
colorBG := MG_MakeTransColor(MG_LogFG)
Gui, MGW_Log:New, +OwnerMGW_LogBG -Caption +ToolWindow +LastFound +E0x08000020 +Delimiter`n
WinSet, TransColor, %colorBG%
Gui, MGW_Log:Font, s%MG_LogFontSize%, %MG_LogFont%
Gui, MGW_Log:Color, %colorBG%, %colorBG%
Gui, MGW_Log:Margin, 10, 0
Gui, MGW_Log:Add, Edit, y10 w%MG_LogSizeW% r%MG_LogMax% vMG_LogList -VScroll -E0x00000200 c%MG_LogFG%
Gui, MGW_Log:Show, AutoSize Hide
WinGetPos,,, w, h
SysGet, wa, MonitorWorkArea
if (MG_LogPosition==1) {
x:=0, y:=0
} else if (MG_LogPosition==2) {
x:=waRight-w, y:=0
} else if (MG_LogPosition==3) {
x:=0, y:=waBottom-h
} else if (MG_LogPosition==4) {
x:=waRight-w, y:=waBottom-h
} else {
x:=MG_LogPosX, y:=MG_LogPosY
}
Gui, MGW_LogBG:Show, x%x% y%y% w%w% h%h% NA, MouseGestureL.ahk Logs
Gui, MGW_Log:Show, x%x% y%y% NA, MouseGestureL.ahk Logs
WinSet, Bottom
SetTimer, MG_UpdateLogDisplay, %MG_LogInterval%
}
 
;-------------------------------------------------------------------------------
; Update Logs
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateLogs(ges="")
{
global
MG_LogPtr := (MG_LogPtr<MG_LogMax) ? MG_LogPtr+1 : 1
MG_Log[MG_LogPtr] := MG_Gesture . "`t" . A_TickCount-MG_PrevTime . "ms" . "`tdX: " . MG_NowX-MG_PreX . "`tdY: " . MG_NowY-MG_PreY
if (ges) {
MG_ActionStr := ""
Gosub, MG_GetAction_%ges%
MG_Log[MG_LogPtr] .= "`t" . MG_ActionStr
}
}
 
;-------------------------------------------------------------------------------
; Update Log Display
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateLogDisplay()
{
global MG_Log, MG_LogPtr, MG_LogMax, MG_LogMax
static prevPtr := ""
if (prevPtr == MG_LogPtr) {
return
}
prevPtr := MG_LogPtr
Loop, %MG_LogMax%
{
ptr := MG_LogPtr - MG_LogMax + A_Index
ptr := ptr<1 ? ptr+MG_LogMax : ptr
szLog .= MG_Log[ptr] . (A_Index<MG_LogMax ? "`n" : "")
}
GuiControl, MGW_Log:, MG_LogList, %szLog%
}
 
;-------------------------------------------------------------------------------
; Copy Logs to Clipboard
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_CopyLogs() {
GuiControlGet, Clipboard, MGW_Log:, MG_LogList
}
 
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;
; Exit Process
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;-------------------------------------------------------------------------------
; Exit Operation
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_EndOperation()
{
global MG_hEventHook
if (MG_hEventHook) {
DllCall("UnhookWinEvent", "Ptr",MG_hEventHook)
}
}
 
MG_End:
#NoEnv

 

*1:hWnd != hPrev) && WinExist("ahk_id " hPrev

*2:szInTitle && !InStr(szTitle, szInTitle

*3:0<MG_ExNaviTranspcy) && (MG_ExNaviTranspcy<255

*4:MG_UseExNavi==3 || MG_UseExNavi==4)

&& (MG_AdNaviPosition > 0

*5:szArrows!=MG_PrevGesture) || bDpiChanged)

{
RegExMatch(szGesture, "(\w+)_", $)
local fgc := (MG_ExNaviFG_%$1% != "") ? MG_ExNaviIdvFG : MG_ExNaviFG2
local bgc := MG_ExNaviIdvBG ? MG_ExNaviIdvBG : MG_ExNaviBG2
local hDC := DllCall("GetWindowDC", "Ptr",MG_ExNaviHwnd, "Ptr")
local hFont := MG_CreateFont("Wingdings", MG_ExNaviSize)
local hFntOld := DllCall("SelectObject", "Ptr",hDC, "Ptr",hFont, "Ptr")
DllCall("SetTextColor","Ptr",hDC, "UInt",fgc)
DllCall("SetBkColor","Ptr",hDC, "UInt",bgc)
if (MG_UseExNavi==1) {
MG_UpdateArrowHints1(hDC, szGesture, szArrows, winX, winY, bgc)
} else if (MG_UseExNavi==2) {
MG_UpdateArrowHints2(hDC, szGesture, szArrows, winX, winY, bgc)
}
DllCall("SelectObject", "Ptr",hDC, "Ptr",hFntOld)
DllCall("DeleteObject", "Ptr",hFont)
DllCall("ReleaseDC", "Ptr",MG_ExNaviHwnd, "Ptr",hDC)
}
;...........................................................................
; Only Move Window
else if (prevX!=winX || prevY!=winY)
{
Gui, MGW_ExNavi:Show, x%winX% y%winY% NA
}
prevX:=winX, prevY:=winY
MG_PrevGesture := szArrows
fCritical := 0
}
 
;-------------------------------------------------------------------------------
; Update Hint Arrows Type 1
; Implemented by Pyonkichi
;-------------------------------------------------------------------------------
MG_UpdateArrowHints1(hDC, szGesture, szArrows, winX, winY, clrBG)
{
global
DllCall("SetTextCharacterExtra", "Ptr",hDC, "Int",MG_AdjustToDPI(MG_ExNaviSpacing

*6:szGesture!=MG_PrevGesture) || bDpiChanged) {

local hDC := DllCall("GetWindowDC", "Ptr",MG_ExNaviHwnd, "Ptr")
MG_hFntBtn := MG_CreateFont(MG_AdNaviFont, MG_AdNaviSize, 700)
MG_hFntDir := MG_CreateFont("Wingdings", MG_AdNaviSize)
MG_hFntAct := MG_CreateFont(MG_AdNaviFont, MG_AdNaviSize)
DllCall("SetBkColor", "Ptr",hDC, "UInt",MG_AdNaviBG2)
if (MG_UseExNavi==3) {
MG_UpdateAdNavi1(hDC, winX, winY, szGesture)
}
else if (MG_UseExNavi==4) {
MG_UpdateAdNavi2(hDC, winX, winY, szGesture)
}
DllCall("DeleteObject", "Ptr",MG_hFntBtn)
DllCall("DeleteObject", "Ptr",MG_hFntDir)
DllCall("DeleteObject", "Ptr",MG_hFntAct)
DllCall("ReleaseDC", "Ptr",MG_ExNaviHwnd, "Ptr",hDC)
}
;...........................................................................
; Only Move Window
else if ((MG_AdNaviPosition==0) && (prevX!=winX || prevY!=winY