[feature] Get start/stop timekeeper working in monthly view

; Autohotkey configuration file
; AHK Version v.1.1.32.00
; Franklin Chou (franklin.chou@nelsonmullins.com)
; 14 Apr. 2020
; Tested to work on Lenovo X1 Yoga, Gen. 4

#SingleInstance Force
#Persistent

GLOBAL_DEBUG_MODE := 1
Return

CapsLock::Ctrl
LCtrl::Return
; LCtrl::CapsLock

; DEBUG TOOLS -----------------------------------------------------------------

#c::
  If(GLOBAL_DEBUG_MODE > 0) {
    ; WinGetClass, title, A
    WinGetActiveTitle, title
    MsgBox %title%
  }
Return

f12::
  If(GLOBAL_DEBUG_MODE > 0) {
    Reload
  }
Return

; SYSTEM ----------------------------------------------------------------------

; Access different windows of the same group
!`::
  WinGet, process_name, ProcessName, A ; get the active window's process name
  process_windows := GetWindowsOfProcess(process_name)

  n_process_windows := process_windows.Length()

  index := 1 ; AHK arrays are 1 indexed
  While(GetKeyState("Alt", "P")) {
    If (GetKeyState("``", "P")) {
      If (index < n_process_windows) {
        index := index + 1
      } Else {
        index := 1
      }
      active_id := process_windows[index]
      WinActivate, ahk_id %active_id%
    }
  }

  index := ""
  process_windows := ""
  n_process_windows := ""
Return

; Get the window ids of all the processes under that process name
GetWindowsOfProcess(process_name) {
  ids := Array()
  WinGet, window_ids, List ; get the IDs for all running windows
  Loop %window_ids% {
    id := window_ids%A_Index%
    WinGetTitle, title, ahk_id %id%
    WinGet, a_process_name, ProcessName, ahk_id %id%
    ; only include windows with visible title
    If (title && a_process_name = process_name) {
      ids.Push(id)
    }
  }
  Return, ids
}

; utility to get selected text (if any)
GetSelectedText() {
  temp := ClipboardAll
  Send ^c
  ClipWait, 0, 1
  selection := Clipboard
  Clipboard := temp
  Return, selection
}

; TIMEKEEPER ------------------------------------------------------------------

; Shift focus to the timekeeper app
#!e::
  timekeeper_app := WinExist("ahk_class WindowsForms10.Window.8.app.0.262fb3d")
  If(timekeeper_app > 0) {
    WinActivate, ahk_id %timekeeper_app%
  } Else {
    Run, DTE.exe, C:\Program Files (x86)\DTEAxiom
  }
Return

; Start the timer on the selected item in the daily view
#IfWinActive ahk_class WindowsForms10.Window.8.app.0.262fb3d
  >+s::
    WinGetActiveTitle, active_title

    selected := GetSelectedText()
    is_releasable := RegExMatch(selected, "Ready to be released")

    ; match monthly view; 2 application windows
    If(is_releaseable && RegExMatch(active_title, "^Entries for") > 0) {
      WinMove, 0, 0
      ; when figuring out how low to get the mouse to move aim for the area
      ; of the menu ar that says "Drag a column header here..."
      MouseMove, 100, 280
      DTEAppContextClick(4)
    } Else If (is_releasable && RegExMatch(active_title, "DTE Axiom") > 0) {
      WinMove, 0, 0
      MouseMove, 100, 440
      DTEAppContextClick(4)
    } Else {
      MsgBox Select releasable entry
      Return
    }
    is_releasable := ""
    selected := ""
Return

; click the item in the DTE context menu that is `position` from the top
DTEAppContextClick(position) {
    ; each item in the dropdown is approximately 25 pixels
    drop_down := 25
    Send {RButton}
    Sleep, 10 ; sleep to allow submenu time to come up
    MouseMove, 170, 300 + drop_down * position
    Send {LButton}
}

; MSOFFICE --------------------------------------------------------------------

; Let the print screen key open the application options key (for spell check)
; Word and Outlook
#If WinActive("ahk_class OpusApp") || WinActive("ahk_class rctrl_renwnd32")
  PrintScreen::AppsKey
Return

; This ridiculous keymapping is care of Lenovo
; which maps F12 to some bloatware keyboard manager utility
#If WinActive("ahk_class OpusApp") || WinActive("ahk_class XLMAIN")
  F12::
    Send {F12}
Return

; WORD ONLY -------------------------------------------------------------------

; Cycle through types of markup
#If WinActive("ahk_class OpusApp")
  >+m::
    Send !r
    Sleep, 10
    Send td
    Send {Down}
    Send {Enter}
Return

; Bring up the tab stop modification dialogue
#If WinActive("ahk_class OpusApp")
  >+t::
    Send !h
    Send pg
    Send !t
Return

; Autohotkey configuration file
; AHK Version v.1.1.32.00
; Franklin Chou (franklin.chou@nelsonmullins.com)
; 22 Mar. 2020
; Tested to work on Lenovo X1 Yoga, Gen. 4

#SingleInstance Force
#Persistent

GLOBAL_DEBUG_MODE := 0
Return

CapsLock::Ctrl
LCtrl::Return
; LCtrl::CapsLock

; DEBUG TOOLS -----------------------------------------------------------------

#c::
  If(GLOBAL_DEBUG_MODE > 0) {
    WinGetClass, title, A
    MsgBox %title%
  }
Return

f12::
  If(GLOBAL_DEBUG_MODE > 0) {
    Reload
  }
Return

; SYSTEM ----------------------------------------------------------------------

; Access different windows of the same group
!`::
  WinGet, process_name, ProcessName, A ; get the active window's process name
  process_windows := GetWindowsOfProcess(process_name)

  n_process_windows := process_windows.Length()

  index := 1 ; AHK arrays are 1 indexed
  While(GetKeyState("Alt", "P")) {
    If (GetKeyState("``", "P")) {
      If (index < n_process_windows) {
        index := index + 1
      } Else {
        index := 1
      }
      active_id := process_windows[index]
      WinActivate, ahk_id %active_id%
    }
  }

  index := ""
  process_windows := ""
  n_process_windows := ""
Return

; Get the window ids of all the processes under that process name
GetWindowsOfProcess(process_name) {
  ids := Array()
  WinGet, window_ids, List ; get the IDs for all running windows
  Loop %window_ids% {
    id := window_ids%A_Index%
    WinGetTitle, title, ahk_id %id%
    WinGet, a_process_name, ProcessName, ahk_id %id%
    ; only include windows with visible title
    If (title && a_process_name = process_name) {
      ids.Push(id)
    }
  }
  Return, ids
}

; TIMEKEEPER ------------------------------------------------------------------

; Shift focus to the timekeeper app
#!e::
  timekeeper_app := WinExist("ahk_class WindowsForms10.Window.8.app.0.262fb3d")
  If(timekeeper_app > 0) {
    WinActivate, ahk_id %timekeeper_app%
  } Else {
    Run, DTE.exe, C:\Program Files (x86)\DTEAxiom
  }
Return

; Start the timer on the selected item in the daily view
#IfWinActive ahk_class WindowsForms10.Window.8.app.0.262fb3d
  >+s::
    WinGetActiveTitle, active_title
    match_result := RegExMatch(active_title, "^Entries for")
    ; each item in the dropdown is approximately 25 pixels
    ; so item 4 (Start Timer) is 100 pixels down from the context menu
    drop_down := 100
    If(match_result > 0) {
      WinMove, 100, 100
      MouseMove, 100, 280
      Send {RButton}
      Sleep, 10 ; need to sleep to allow submenu time to come up
      MouseMove, 170, 300 + drop_down
      Send {LButton}
    }
Return

; MSOFFICE --------------------------------------------------------------------

; Let the print screen key open the application options key (for spell check)
; Word and Outlook
#If WinActive("ahk_class OpusApp") || WinActive("ahk_class rctrl_renwnd32")
  PrintScreen::AppsKey
Return

; This ridiculous keymapping is care of Lenovo
; which maps F12 to some bloatware keyboard manager utility
#If WinActive("ahk_class OpusApp") || WinActive("ahk_class XLMAIN")
  F12::
    Send {F12}
Return

; WORD ONLY -------------------------------------------------------------------

; Cycle through types of markup
#If WinActive("ahk_class OpusApp")
  >+m::
    Send !r
    Sleep, 10
    Send td
    Send {Down}
    Send {Enter}
Return

; Bring up the tab stop modification dialogue
#If WinActive("ahk_class OpusApp")
  >+t::
    Send !h
    Send pg
    Send !t
Return


Fix foobar2000 plugin

Fix foobar2000 plugin

foobar2000:
    global foobar2000_class:="{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}"

    ; insert模式
    vim.mode("insert", foobar2000_class)
    vim.map("<esc>", "<Normal_Mode_foobar2000>", foobar2000_class)

    ; normal模式
    vim.mode("normal", foobar2000_class)

    vim.map("i", "<Insert_Mode_foobar2000>", foobar2000_class)

    vim.map("0", "<0>", foobar2000_class)
    vim.map("1", "<1>", foobar2000_class)
    vim.map("2", "<2>", foobar2000_class)
    vim.map("3", "<3>", foobar2000_class)
    vim.map("4", "<4>", foobar2000_class)
    vim.map("5", "<5>", foobar2000_class)
    vim.map("6", "<6>", foobar2000_class)
    vim.map("7", "<7>", foobar2000_class)
    vim.map("8", "<8>", foobar2000_class)
    vim.map("9", "<9>", foobar2000_class)

    vim.map("j", "<down>", foobar2000_class)
    vim.map("k", "<up>", foobar2000_class)
    vim.map("l", "<enter>", foobar2000_class)
    vim.map("gg", "<home>", foobar2000_class)
    vim.map("G", "<end>", foobar2000_class)
    vim.map("<ctrl>f", "<pgdn>", foobar2000_class)
    vim.map("<ctrl>b", "<pgup>", foobar2000_class)
    vim.map("/", "<foobar2000_search>", foobar2000_class)
    vim.map("t", "<foobar2000_tree>", foobar2000_class)
    vim.map("m", "<foobar2000_list>", foobar2000_class)
    vim.map("n", "<Media_Next>", foobar2000_class)
    vim.map("p", "<Media_Prev>", foobar2000_class)
    vim.map("s", "<Media_Stop>", foobar2000_class)

    vim.map("gn", "<NextTab>", foobar2000_class)
    vim.map("gp", "<PrevTab>", foobar2000_class)

    vim.Comment("<Normal_Mode_foobar2000>", "进入normal模式")
    vim.Comment("<Insert_Mode_foobar2000>", "进入insert模式")
    vim.Comment("<foobar2000_search>", "打开搜索窗口")
    vim.Comment("<foobar2000_tree>", "定位到目录窗口")
    vim.Comment("<foobar2000_list>", "定位到播放列表")
return

<Normal_Mode_foobar2000>:
    global foobar2000_class
    vim.mode("normal", foobar2000_class)
return

<Insert_Mode_foobar2000>:
    global foobar2000_class
    vim.mode("insert", foobar2000_class)
return

<foobar2000_search>:
    send ^f
return

<foobar2000_tree>:
    ControlFocus, SysTreeView321
return

<foobar2000_list>:
    ControlFocus, {4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1
return

foobar2000:
    foobar2000_class:="{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}"

    ;插入模式
    vim.mode("insert",foobar2000_class)
    vim.map("<esc>","<General_mode_normal>",foobar2000_class)
    vim.map("<ctrl><esc>","<General_mode_disable>",foobar2000_class)

    ;normal模式
    vim.mode("normal",foobar2000_class)
    vim.map("<ctrl><esc>","<General_mode_disable>",foobar2000_class)
    vim.map("i","<General_mode_insert>",foobar2000_class)
    vim.map("0","<0>",foobar2000_class)
    vim.map("1","<1>",foobar2000_class)
    vim.map("2","<2>",foobar2000_class)
    vim.map("3","<3>",foobar2000_class)
    vim.map("4","<4>",foobar2000_class)
    vim.map("5","<5>",foobar2000_class)
    vim.map("6","<6>",foobar2000_class)
    vim.map("7","<7>",foobar2000_class)
    vim.map("8","<8>",foobar2000_class)
    vim.map("9","<9>",foobar2000_class)

    vim.map("j","<down>",foobar2000_class)
    vim.map("k","<up>",foobar2000_class)
    vim.map("l","<enter>",foobar2000_class)
    vim.map("gg", "<home>", foobar2000_class)
    vim.map("G", "<end>", foobar2000_class)
    vim.map("<ctrl>f", "<pgdn>", foobar2000_class)
    vim.map("<ctrl>b", "<pgup>", foobar2000_class)
    vim.map("/", "<foobar2000_search>", foobar2000_class)
    vim.map("t", "<foobar2000_tree>", foobar2000_class)
    vim.map("m", "<foobar2000_list>", foobar2000_class)
    vim.map("n", "<Media_Next>", foobar2000_class)
    vim.map("p", "<Media_Prev>", foobar2000_class)
    vim.map("s", "<Media_Stop>", foobar2000_class)

    vim.map("zj","<WindowMoveDown>",foobar2000_class)
    vim.map("zk","<WindowMoveUp>",foobar2000_class)
    vim.map("zh","<WindowMoveLeft>",foobar2000_class)
    vim.map("zl","<WindowMoveRight>",foobar2000_class)
    vim.map("zc","<WindowMoveCenter>",foobar2000_class)
    vim.map("zf","<fullscreen>",foobar2000_class)
    vim.map("zm","<WindowMax>",foobar2000_class)
    vim.map("zn","<WindowMin>",foobar2000_class)
    vim.map("zr","<WindowRestore>",foobar2000_class)

    vim.map("gn","<NextTab>",foobar2000_class)
    vim.map("gp","<PrevTab>",foobar2000_class)
    vim.map("g1","<ActivateTab1>",foobar2000_class)
    vim.map("g2","<ActivateTab2>",foobar2000_class)
    vim.map("g3","<ActivateTab3>",foobar2000_class)
    vim.map("g4","<ActivateTab4>",foobar2000_class)
    vim.map("g5","<ActivateTab5>",foobar2000_class)
    vim.map("g6","<ActivateTab6>",foobar2000_class)
    vim.map("g7","<ActivateTab7>",foobar2000_class)
    vim.map("g8","<ActivateTab8>",foobar2000_class)
    vim.map("g9","<ActivateTab9>",foobar2000_class)
    vim.map("g0","<ActivateTab0>",foobar2000_class)

    vim.Comment("<foobar2000_search>","打开搜索窗口")
    vim.Comment("<foobar2000_tree>","定位到目录窗口")
    vim.Comment("<foobar2000_list>","定位到播放列表")
return

<foobar2000_search>:
    send ^f
return

<foobar2000_tree>:
    ControlFocus, SysTreeView321
return

<foobar2000_list>:
    ControlFocus, {4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1
return


Update MBWindow.ahk

Update MBWindow.ahk

#IfWinActive ahk_exe MapInfoPro.exe ;THIS WILL NEED EXTENSION THROUGH "isMapBasicWindow()"
$Enter::    ;$ so Enter can be re-used

    If Not isMapBasicWindow() {
        send, {Enter}
        return
    }

    ;Get the MapBasic source from the MapBasic Window
    old_clipboard := ClipboardAll
	Clipboard=
	send, ^c
	clipwait,0.1
	MBSource := clipboard
	clipboard := old_clipboard

	MBSource := preCompile(MBSource)

	If (MBSource <> "") {
	    Compile(MBSource)
	} else {
	    send,{Enter}
	}
return

isMapBasicWindow(){
    ;TO DO: This should have more (fast) checks.
    MapInfo = ComObjGet("MapInfo.Application.x64")
    return MapInfo.Eval("ActiveWindow()") = 1002
}

preCompile(src){
	If (LTrim(SubStr(src,1,2)) = "::") {
	    return LTrim(SubStr(src,3))
	} else {
	    ;Separated RegEx - This may require simplifying...:
		i := 0
		i := i + regexmatch(src,"i)\bAlter\b\s+\b(Control|MapInfoDialog)\b")		;matches {Alter Control,Alter MapInfoDialog}
		i := i + regexmatch(src,"i)\bCall\b")						            	;matches Call
		i := i + regexmatch(src,"i)\bDeclare\b\s+\b(Function|Sub)\b")				;matches {Declare Function, Declare Sub}
		i := i + regexmatch(src,"i)\bDefine\b")						            	;matches Define
		i := i + regexmatch(src,"i)\bDialog\b")						            	;matches {Dialog, Dialog Preserve, Dialog Remove}
		i := i + regexmatch(src,"i)\bDim\s+\w+\s*(,\s*\w+\s*)+\s+as\b")				;matches Dim {2 variable declarations} as
		i := i + regexmatch(src,"i)\bDo\s+Case\s+(.|\s)*?\bEnd\s+Case\b")			;matches Do Case … End Case,
		i := i + regexmatch(src,"i)\bDo\b\s+(.|\s)*?\bLoop\b")				    	;matches Do … Loop
		i := i + regexmatch(src,"i)\bEnd\s+Program\b")					         	;matches End Program
		i := i + regexmatch(src,"i)\bExit\s+(Do|For|Function|Sub)\b")				;matches {Exit Do, Exit For, Exit Function, Exit Sub}
		i := i + regexmatch(src,"i)\bFor\b(.|\s)*?\bNext\b")				    	;matches For … Next,
		i := i + regexmatch(src,"i)\bFunction\b(.|\s)*\bEnd\s+Function\b")			;matches Function … End Function
		i := i + regexmatch(src,"i)\bGoTo\b")			            				;matches GoTo
		i := i + regexmatch(src,"i)\bSub\b(.|\s)*\bEnd\s+Sub\b")				    ;matches Sub … End Sub
		i := i + regexmatch(src,"i)\bIf\b(.|\s)*?\bThen\b(.|\s)*?\bEnd\s+If\b")		;matches If .*? then … End If
		i := i + regexmatch(src,"i)\bInclude\b\s+\b"".*""\b")				    	;matches Include “…”
		i := i + regexmatch(src,"i)\bOnError\s+GoTo\b")					        	;matches OnError GoTo
		i := i + regexmatch(src,"i)\bOpen\s+File\b")					    	    ;matches Open File
		i := i + regexmatch(src,"i)\bProgressBar\b")    					    	;matches ProgressBar
		i := i + regexmatch(src,"i)\bResume\b")			    				        ;matches Resume
		i := i + regexmatch(src,"i)\bSet\s+Handler\b")		    				    ;matches Set Handler
		i := i + regexmatch(src,"i)\bType\b(.|\s)*?\bEnd\s+Type\b") 				;matches Type … End Type
		i := i + regexmatch(src,"i)\bWhile\b(.|\s)*?\bWend\b")		    			;matches While … Wend

		if (i>0) {
		    return src
		} else {
		    return ""
		}
	}
}

#IfWinActive ahk_exe MapInfoPro.exe ;THIS WILL NEED EXTENSION THROUGH "isMapBasicWindow()"
$Enter::    ;$ so Enter can be re-used

    If Not isMapBasicWindow() {
        send, {Enter}
        return
    }

    ;Get the MapBasic source from the MapBasic Window
    old_clipboard := ClipboardAll
	Clipboard=
	send, ^c
	clipwait,0.1
	MBSource := clipboard
	clipboard := old_clipboard

	MBSource := preCompile(MBSource)

	If (MBSource <> "") {
	    Compile(MBSource)
	} else {
	    send,{Enter}
	}
return

isMapBasicWindow(){
    ;TO DO: This should have more (fast) checks.
    return 1
}

preCompile(src){
	If (LTrim(SubStr(src,1,2)) = "::") {
	    return LTrim(SubStr(src,3))
	} else {
	    ;Separated RegEx - This may require simplifying...:
		i := 0
		i := i + regexmatch(src,"i)\bAlter\b\s+\b(Control|MapInfoDialog)\b")		;matches {Alter Control,Alter MapInfoDialog}
		i := i + regexmatch(src,"i)\bCall\b")						            	;matches Call
		i := i + regexmatch(src,"i)\bDeclare\b\s+\b(Function|Sub)\b")				;matches {Declare Function, Declare Sub}
		i := i + regexmatch(src,"i)\bDefine\b")						            	;matches Define
		i := i + regexmatch(src,"i)\bDialog\b")						            	;matches {Dialog, Dialog Preserve, Dialog Remove}
		i := i + regexmatch(src,"i)\bDim\s+\w+\s*(,\s*\w+\s*)+\s+as\b")				;matches Dim {2 variable declarations} as
		i := i + regexmatch(src,"i)\bDo\s+Case\s+(.|\s)*?\bEnd\s+Case\b")			;matches Do Case … End Case,
		i := i + regexmatch(src,"i)\bDo\b\s+(.|\s)*?\bLoop\b")				    	;matches Do … Loop
		i := i + regexmatch(src,"i)\bEnd\s+Program\b")					         	;matches End Program
		i := i + regexmatch(src,"i)\bExit\s+(Do|For|Function|Sub)\b")				;matches {Exit Do, Exit For, Exit Function, Exit Sub}
		i := i + regexmatch(src,"i)\bFor\b(.|\s)*?\bNext\b")				    	;matches For … Next,
		i := i + regexmatch(src,"i)\bFunction\b(.|\s)*\bEnd\s+Function\b")			;matches Function … End Function
		i := i + regexmatch(src,"i)\bGoTo\b")			            				;matches GoTo
		i := i + regexmatch(src,"i)\bSub\b(.|\s)*\bEnd\s+Sub\b")				    ;matches Sub … End Sub
		i := i + regexmatch(src,"i)\bIf\b(.|\s)*?\bThen\b(.|\s)*?\bEnd\s+If\b")		;matches If .*? then … End If
		i := i + regexmatch(src,"i)\bInclude\b\s+\b"".*""\b")				    	;matches Include “…”
		i := i + regexmatch(src,"i)\bOnError\s+GoTo\b")					        	;matches OnError GoTo
		i := i + regexmatch(src,"i)\bOpen\s+File\b")					    	    ;matches Open File
		i := i + regexmatch(src,"i)\bProgressBar\b")    					    	;matches ProgressBar
		i := i + regexmatch(src,"i)\bResume\b")			    				        ;matches Resume
		i := i + regexmatch(src,"i)\bSet\s+Handler\b")		    				    ;matches Set Handler
		i := i + regexmatch(src,"i)\bType\b(.|\s)*?\bEnd\s+Type\b") 				;matches Type … End Type
		i := i + regexmatch(src,"i)\bWhile\b(.|\s)*?\bWend\b")		    			;matches While … Wend

		if (i>0) {
		    return src
		} else {
		    return ""
		}
	}
}


Update Parent2Gem.ahk

Update Parent2Gem.ahk

; AutoHotkey Version: 1.1x
; Language:       English
; Author:         8thSeaOfRhye
;
;                     #####         Parent2Gem.ahk - Version 2       #####
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
InitialMode := False ; Initialisation
CoordMode, Mouse, Screen
CurrentCustom := "(g+g)+(g+g)"
LastDDL := 6
CombineMode := True
LastGemPos := 1
SetDefaultMouseSpeed, 0		; #### Here you can change mouse speed (0=instant, 100=slowest)

TopLeftCornerX := 1590
TopLeftCornerY := 338
BottomRightCornerX := 1436
BottomRightCornerY := 686

ParentStr := "(g+g)+(g+g)"

!V::
	OptionsMenu()
return

OptionsMenu() {
	Global ParentStr
	Global ChosenCombine
	Global ParentNewStr
	Global InitialMode
	Global CustomFormula
	Global PGScript
	Global CustomTemp
	Global LastDDL
	Global CurrentCustom
	Global LastDDLTemp
	Global TempReadOnly

	Gui, New,, Options
	GuiHWND := WinExist()

; ################# DDL #####################

	TempReadOnly := ""
	If LastDDL != 6
		TempReadOnly := "readonly"
	Gui, Add, Text,, Choose your desired combine
	Gui, Add, DropDownList, w200 Choose%LastDDL% vChosenCombine gShowCustomField, killgem_amps64-5-gem|killgem_amps64-5-amps|managem_amps256-30_ieee-gem|managem_amps256-30_ieee-amps|universal16c|Custom
	Gui, Add, Text,, Custom Bracket Formula:        Attention! Syntaxerrors may lead to chaos!
	Gui, Add, Edit, w400 r3 vCustomFormula %TempReadOnly%, %CurrentCustom%

; ################# INITMODE ################

	Gui, Add, Text, w400, `n`nIn order to setup the script for your screen-resolution press the following button and follow the instructions`: `n
	Gui, Add, Button, , Setup Script
	Gui, Add, Text,, You have to run this setup each time your screen-resolution changes

;############## Wait For Input ##############

	Gui, Add, Button, default, Ok
	Gui, Show
	WinWaitClose, ahk_id %GuiHWND%
	return

;############### SUBS / Labels #############

	ShowCustomField:
		GuiControlGet, StatusOfDll, , ChosenCombine
		if (StatusOfDll = "custom")
			GuiControl, -readonly, CustomFormula
		else
			GuiControl, +readonly, CustomFormula
	return

	ButtonSetupScript:
		if (InitialMode = False) {
			PGScript := RegExReplace(PGScript, "InitialMode := False `; Init", "InitialMode := True  `; Init", , 1)
			InitialMode := True
		}
		FileRead, PGScript, Parent2Gem.ahk
		FileDelete, Parent2Gem.ahk
		MsgBox Place your mouse over the top-left corner of the 12*3 craftingfield and press ENTER
			MouseGetPos, TLCX, TLCY
			PGScript := RegExReplace(PGScript, "TopLeftCornerX := [0-9]+", "TopLeftCornerX := " TLCX, , 1)
			PGScript := RegExReplace(PGScript, "TopLeftCornerY := [0-9]+", "TopLeftCornerY := " TLCY, , 1)
		MsgBox Place your mouse over the bottom-right corner of the 12*3 craftingfield and press ENTER
			MouseGetPos, BRCX, BRCY
			PGScript := RegExReplace(PGScript, "BottomRightCornerX := [0-9]+", "BottomRightCornerX := "BRCX, , 1)
			PGScript := RegExReplace(PGScript, "BottomRightCornerY := [0-9]+", "BottomRightCornerY := "BRCY, , 1)

		FileAppend, %PGScript%, Parent2Gem.ahk

		TopLeftCornerX := TLCX
		TopLeftCornerY := TLCY
		BottomRightCornerX := BRCX
		BottomRightCornerY := BRCY
		MsgBox The Script has been adapted to your screen-resolution. `nRemember to do this whenever your screen-resolution changes!

	return

	ButtonOk:
		Gui, Submit
		if (ChosenCombine = "killgem_amps64-5-gem") {
			ParentNewStr := "((((b+((b+y)+(y+y)))+((b+(b+y))+(b+(b+(b+b)))))+(((b+b)+(b+(y+y)))+(((b+y)+(y+y))+((y+y)+(y+(y+(y+(y+y))))))))+((((b+(b+y))+(b+(y+y)))+((b+(b+y))+(b+(b+(b+(b+b))))))+(((b+(b+y))+(b+(b+(b+b))))+((b+(b+(b+b)))+((b+(b+b))+((b+(b+b))+(b+(b+(b+(b+b))))))))))"
			LastDDL := 1
		}
		if (ChosenCombine = "killgem_amps64-5-amps") {
			ParentNewStr := "((y+y)+(y+(y+y)))"
			LastDDL := 2
		}

		if (ChosenCombine = "managem_amps256-30_ieee-gem") {
			ParentNewStr := "(((((((b+o)+(b+b))+(b+((o+o)+(b+o))))+(((b+o)+(b+b))+((b+b)+(b+(b+(b+(b+b)))))))+((((b+o)+(b+b))+(b+((o+o)+(o+(o+o)))))+((b+((o+o)+(b+o)))+(((o+o)+(b+o))+((o+o)+(o+(o+(o+(o+(o+(o+o)))))))))))+(((((b+o)+(b+b))+(b+((o+o)+(o+(o+o)))))+(((b+o)+(b+b))+((b+b)+(b+(b+(b+(b+b)))))))+((((b+o)+(b+b))+((b+b)+(b+(b+(b+(b+b))))))+(((b+b)+(b+(b+(b+(b+b)))))+((b+(b+(b+(b+b))))+((b+(b+(b+b)))+((b+(b+b))+((b+b)+(b+(b+(b+(b+(b+b)))))))))))))+((((((b+o)+(b+b))+(b+((b+o)+(o+(o+o)))))+(((b+o)+(b+b))+((b+b)+(b+(b+(b+(b+b)))))))+((((b+o)+(b+b))+(b+((b+o)+(o+(o+o)))))+((b+((o+o)+(b+o)))+(((o+o)+(b+o))+((o+(o+o))+(o+(o+(o+(o+(o+(o+o)))))))))))+(((((b+o)+(b+b))+(b+((b+o)+(o+(o+o)))))+((b+((o+o)+(b+o)))+(((b+o)+(o+(o+o)))+((o+(o+o))+(o+(o+(o+(o+(o+(o+o))))))))))+(((b+((o+o)+(b+o)))+((b+(o+o))+((o+o)+(o+(o+(o+(o+(o+o))))))))+((((o+o)+(b+o))+((o+(o+o))+(o+(o+(o+(o+(o+(o+o))))))))+(((o+o)+(o+(o+(o+(o+(o+o))))))+(((o+o)+(o+(o+(o+(o+(o+o))))))+((o+(o+(o+(o+o))))+((o+(o+(o+o)))+((o+(o+o))+((o+(o+o))+(o+(o+(o+(o+(o+(o+(o+o))))))))))))))))))"
			LastDDL := 3
		}

		if (ChosenCombine = "managem_amps256-30_ieee-amps") {
			ParentNewStr := "((((o+o)+(o+o))+((o+o)+(o+(o+(o+o)))))+(((o+o)+(o+(o+(o+o))))+((o+(o+o))+((o+(o+o))+(o+(o+(o+(o+(o+(o+(o+o)))))))))))"
			LastDDL := 4
		}

		if (ChosenCombine = "universal16c") {
			ParentNewStr := "(((((((((g+g)+g)+g)+g)+g)+g)+(g+g))+(g+g))+(((g+g)+g)+(g+g)))"
			LastDDL := 5
		}

		if (ChosenCombine = "Custom") {
			ParentNewStr := CustomFormula
			LastDDL := 6
		}

;		if (ChosenCombine = "") {
;			ParentNewStr := ""
;			LastDDL := 1
;		}

		if (ChosenCombine = "")
			ParentNewStr := ParentStr

		ParentStr := ParentNewStr

		FileRead, PGScript, Parent2Gem.ahk
		FileDelete, Parent2Gem.ahk
		ParentNewStr = ParentStr := "%ParentNewStr%"
		PGScript := RegExReplace(PGScript, "ParentStr := ""[A-Za-z0-9()+]*""", ParentNewStr, , 1)

		CustomTemp = CurrentCustom := "%CustomFormula%"
		if (ChosenCombine = "Custom")
			PGScript := RegExReplace(PGScript, "CurrentCustom := "".*""", CustomTemp, , 1)

		LastDDLTemp = LastDDL := %LastDDL%
		PGScript := RegExReplace(PGScript, "LastDDL := [0-9]*", LastDDLTemp, , 1)

		FileAppend, %PGScript%, Parent2Gem.ahk

		Gui, Destroy
	Return
}
!C::

if (InitialMode = False) {
	MsgBox, You have to adapt the script to your screen-resolution. You will be redirected to the options-menu, where you can hit the "Setup Script"-Button to do this.
	OptionsMenu()
}
else {
	FieldWidth := (BottomRightCornerX - TopLeftCornerX) / 3
	FieldHeight := (BottomRightCornerY - TopLeftCornerY) / 12
	CraftingField := [BottomRightCornerX -(FieldWidth / 2), BottomRightCornerY -(FieldHeight / 2)]

	i := 0
	j := 0
	StkCount := 1
	initPos := [TopLeftCornerX + (FieldWidth / 2), BottomRightCornerY - (FieldHeight * 1.5)]
	StackFields := []
	While i < 12
	{
		while j < 3
		{
			StackFields[StkCount, 1] := initPos[1] + (j * FieldWidth)
			StackFields[StkCount, 2] := initPos[2] - (i * FieldHeight)
			StkCount := StkCount + 1
			j := j + 1
		}
		j := 0
		i := i + 1
	}

	CurrentStk := 0

	OGem() {
		global CraftingField
		Send {Numpad7}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}
	YGem() {
		global CraftingField
		Send {Numpad8}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}
	BGem() {
		global CraftingField
		Send {Numpad1}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}
	RGem() {
		global CraftingField
		Send {Numpad4}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}
	WGem() {
		global CraftingField
		Send {Numpad9}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}

	GGem() {
		global CraftingField
		global FieldWidth
		MouseMove, CraftingField[1]-(2*FieldWidth), CraftingField[2]
		send d
	}

	AddtoStk() {
		global CraftingField
		global CurrentStk
		global StackFields
		if CurrentStk != 0
			{
			Send g
			MouseClickDrag, L, CraftingField[1], CraftingField[2], StackFields[CurrentStk][1], StackFields[CurrentStk][2]
			}
	}

	MovetoStk() {
		global CraftingField
		global CurrentStk
		global StackFields
		CurrentStk := CurrentStk + 1
		MouseClickDrag, L, CraftingField[1], CraftingField[2], StackFields[CurrentStk][1], StackFields[CurrentStk][2]
	}

	PopStk() {
		global CraftingField
		global CurrentStk
		global StackFields
		if CurrentStk > 1
			{
			Send g
			MouseClickDrag, L, StackFields[CurrentStk][1], StackFields[CurrentStk][2], StackFields[CurrentStk - 1][1], StackFields[CurrentStk - 1][2]
			CurrentStk := CurrentStk - 1
			}
	}

	if (CombineMode = True) {
		StrPosEnd := StrLen(ParentStr)
		ElementFound := False
		While ElementFound = False {
			if (SubStr(ParentStr, StrPosEnd, 1) != ")") {
				ElementFound := True
				LastGemPos := StrPosEnd
			}
			StrPosEnd := StrPosEnd - 1
		}
	}

	StrPos := 1
	Parents := []

	While StrPos < StrLen(ParentStr) {
		if (SubStr(ParentStr, StrPos, 1) = "(") {
			if ((SubStr(ParentStr, StrPos - 1, 1) = "(") or (StrPos = 1))
				Parents.Insert(False)
			else
				Parents.Insert(True)
		}

		if (SubStr(ParentStr, StrPos, 1) = ")") {
			if (Parents[Parents.MaxIndex()] = True)
				PopStk()
			Parents.remove(Parents.MaxIndex())
		}

		if (SubStr(ParentStr, StrPos, 1) = "o") {
			OGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}

		if (SubStr(ParentStr, StrPos, 1) = "r") {
			RGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}

		if (SubStr(ParentStr, StrPos, 1) = "b") {
			BGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}

		if (SubStr(ParentStr, StrPos, 1) = "y") {
			YGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}
		if (SubStr(ParentStr, StrPos, 1) = "w") {
			WGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}
		if ((SubStr(ParentStr, StrPos, 1) = "g") or (SubStr(ParentStr, StrPos, 1) = "k") or (SubStr(ParentStr, StrPos, 1) = "m")) {
			if (LastGemPos != StrPos)
				GGem()
			else
				MouseClickDrag, L, CraftingField[1]-(2*FieldWidth), CraftingField[2], CraftingField[1], CraftingField[2]
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}

		if ((SubStr(ParentStr, StrPos, 1) < 10) and (SubStr(ParentStr, StrPos, 1) > 1)) {
			if (SubStr(ParentStr, StrPos + 1, 1) = "o")
				OGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "y")
				YGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "b")
				BGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "r")
				RGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "w")
				WGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "g") {
				if (LastGemPos != StrPos + 1)
					GGem()
				else
					MouseClickDrag, L, CraftingField[1]-(2*FieldWidth), CraftingField[2], CraftingField[1], CraftingField[2]
			}
			UCount := 1
			While UCount <= SubStr(ParentStr, StrPos + 1, 1) {
				MouseMove, CraftingField[1], CraftingField[2]
				send u
				UCount := UCount + 1
			}

			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
			StrPos := StrPos + 1
		}

		if (SubStr(ParentStr, StrPos, 1) = "a") {
			MouseClickDrag, L, TopLeftCornerX + (FieldWidth / 2), TopLeftCornerY + (FieldHeight / 2), CraftingField[1], CraftingField[2]
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()

		}
		if (SubStr(ParentStr, StrPos, 1) = "s") {
			MouseClickDrag, L, TopLeftCornerX + (FieldWidth * 1.5), TopLeftCornerY + (FieldHeight / 2), CraftingField[1], CraftingField[2]
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()

		}
		if (SubStr(ParentStr, StrPos, 1) = "d") {
			MouseClickDrag, L, TopLeftCornerX + (FieldWidth * 2.5), TopLeftCornerY + (FieldHeight / 2), CraftingField[1], CraftingField[2]
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()

		}
		StrPos := StrPos + 1
	}
	while CurrentStk > 1 {
		PopStk()
	}
}

Return

; AutoHotkey Version: 1.1x
; Language:       English
; Author:         8thSeaOfRhye
;
;                     #####         Parent2Gem.ahk - Version 2       #####
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
InitialMode := False ; Initialisation
CoordMode, Mouse, Screen
CurrentCustom := "(g+g)+(g+g)"
LastDDL := 6
CombineMode := True
LastGemPos := 1
SetDefaultMouseSpeed, 0		; #### Here you can change mouse speed (0=instant, 100=slowest)

TopLeftCornerX := 1590
TopLeftCornerY := 338
BottomRightCornerX := 1436
BottomRightCornerY := 686

ParentStr := "(g+g)+(g+g)"

!V::
	OptionsMenu()
return

OptionsMenu() {
	Global ParentStr
	Global ChosenCombine
	Global ParentNewStr
	Global InitialMode
	Global CustomFormula
	Global PGScript
	Global CustomTemp
	Global LastDDL
	Global CurrentCustom
	Global LastDDLTemp
	Global TempReadOnly

	Gui, New,, Options
	GuiHWND := WinExist()

; ################# DDL #####################

	TempReadOnly := ""
	If LastDDL != 6
		TempReadOnly := "readonly"
	Gui, Add, Text,, Choose your desired combine
	Gui, Add, DropDownList, w200 Choose%LastDDL% vChosenCombine gShowCustomField, killgem_amps64-5-gem|killgem_amps64-5-amps|managem_amps256-30_ieee-gem|managem_amps256-30_ieee-amps|universal16c|Custom
	Gui, Add, Text,, Custom Bracket Formula:        Attention! Syntaxerrors may lead to chaos!
	Gui, Add, Edit, w400 r3 vCustomFormula %TempReadOnly%, %CurrentCustom%

; ################# INITMODE ################

	Gui, Add, Text, w400, `n`nIn order to setup the script for your screen-resolution press the following button and follow the instructions`: `n
	Gui, Add, Button, , Setup Script
	Gui, Add, Text,, You have to run this setup each time your screen-resolution changes

;############## Wait For Input ##############

	Gui, Add, Button, default, Ok
	Gui, Show
	WinWaitClose, ahk_id %GuiHWND%
	return

;############### SUBS / Labels #############

	ShowCustomField:
		GuiControlGet, StatusOfDll, , ChosenCombine
		if (StatusOfDll = "custom")
			GuiControl, -readonly, CustomFormula
		else
			GuiControl, +readonly, CustomFormula
	return

	ButtonSetupScript:
		if (InitialMode = False)
			PGScript := RegExReplace(PGScript, "InitialMode := False `; Init", "InitialMode := True  `; Init", , 1)
		FileRead, PGScript, Parent2Gem.ahk
		FileDelete, Parent2Gem.ahk
		MsgBox Place your mouse over the top-left corner of the 12*3 craftingfield and press ENTER
			MouseGetPos, TLCX, TLCY
			PGScript := RegExReplace(PGScript, "TopLeftCornerX := [0-9]+", "TopLeftCornerX := " TLCX, , 1)
			PGScript := RegExReplace(PGScript, "TopLeftCornerY := [0-9]+", "TopLeftCornerY := " TLCY, , 1)
		MsgBox Place your mouse over the bottom-right corner of the 12*3 craftingfield and press ENTER
			MouseGetPos, BRCX, BRCY
			PGScript := RegExReplace(PGScript, "BottomRightCornerX := [0-9]+", "BottomRightCornerX := "BRCX, , 1)
			PGScript := RegExReplace(PGScript, "BottomRightCornerY := [0-9]+", "BottomRightCornerY := "BRCY, , 1)

		FileAppend, %PGScript%, Parent2Gem.ahk

		TopLeftCornerX := TLCX
		TopLeftCornerY := TLCY
		BottomRightCornerX := BRCX
		BottomRightCornerY := BRCY
		MsgBox The Script has been adapted to your screen-resolution. `nRemember to do this whenever your screen-resolution changes!

	return

	ButtonOk:
		Gui, Submit
		if (ChosenCombine = "killgem_amps64-5-gem") {
			ParentNewStr := "((((b+((b+y)+(y+y)))+((b+(b+y))+(b+(b+(b+b)))))+(((b+b)+(b+(y+y)))+(((b+y)+(y+y))+((y+y)+(y+(y+(y+(y+y))))))))+((((b+(b+y))+(b+(y+y)))+((b+(b+y))+(b+(b+(b+(b+b))))))+(((b+(b+y))+(b+(b+(b+b))))+((b+(b+(b+b)))+((b+(b+b))+((b+(b+b))+(b+(b+(b+(b+b))))))))))"
			LastDDL := 1
		}
		if (ChosenCombine = "killgem_amps64-5-amps") {
			ParentNewStr := "((y+y)+(y+(y+y)))"
			LastDDL := 2
		}

		if (ChosenCombine = "managem_amps256-30_ieee-gem") {
			ParentNewStr := "(((((((b+o)+(b+b))+(b+((o+o)+(b+o))))+(((b+o)+(b+b))+((b+b)+(b+(b+(b+(b+b)))))))+((((b+o)+(b+b))+(b+((o+o)+(o+(o+o)))))+((b+((o+o)+(b+o)))+(((o+o)+(b+o))+((o+o)+(o+(o+(o+(o+(o+(o+o)))))))))))+(((((b+o)+(b+b))+(b+((o+o)+(o+(o+o)))))+(((b+o)+(b+b))+((b+b)+(b+(b+(b+(b+b)))))))+((((b+o)+(b+b))+((b+b)+(b+(b+(b+(b+b))))))+(((b+b)+(b+(b+(b+(b+b)))))+((b+(b+(b+(b+b))))+((b+(b+(b+b)))+((b+(b+b))+((b+b)+(b+(b+(b+(b+(b+b)))))))))))))+((((((b+o)+(b+b))+(b+((b+o)+(o+(o+o)))))+(((b+o)+(b+b))+((b+b)+(b+(b+(b+(b+b)))))))+((((b+o)+(b+b))+(b+((b+o)+(o+(o+o)))))+((b+((o+o)+(b+o)))+(((o+o)+(b+o))+((o+(o+o))+(o+(o+(o+(o+(o+(o+o)))))))))))+(((((b+o)+(b+b))+(b+((b+o)+(o+(o+o)))))+((b+((o+o)+(b+o)))+(((b+o)+(o+(o+o)))+((o+(o+o))+(o+(o+(o+(o+(o+(o+o))))))))))+(((b+((o+o)+(b+o)))+((b+(o+o))+((o+o)+(o+(o+(o+(o+(o+o))))))))+((((o+o)+(b+o))+((o+(o+o))+(o+(o+(o+(o+(o+(o+o))))))))+(((o+o)+(o+(o+(o+(o+(o+o))))))+(((o+o)+(o+(o+(o+(o+(o+o))))))+((o+(o+(o+(o+o))))+((o+(o+(o+o)))+((o+(o+o))+((o+(o+o))+(o+(o+(o+(o+(o+(o+(o+o))))))))))))))))))"
			LastDDL := 3
		}

		if (ChosenCombine = "managem_amps256-30_ieee-amps") {
			ParentNewStr := "((((o+o)+(o+o))+((o+o)+(o+(o+(o+o)))))+(((o+o)+(o+(o+(o+o))))+((o+(o+o))+((o+(o+o))+(o+(o+(o+(o+(o+(o+(o+o)))))))))))"
			LastDDL := 4
		}

		if (ChosenCombine = "universal16c") {
			ParentNewStr := "(((((((((g+g)+g)+g)+g)+g)+g)+(g+g))+(g+g))+(((g+g)+g)+(g+g)))"
			LastDDL := 5
		}

		if (ChosenCombine = "Custom") {
			ParentNewStr := CustomFormula
			LastDDL := 6
		}

;		if (ChosenCombine = "") {
;			ParentNewStr := ""
;			LastDDL := 1
;		}

		if (ChosenCombine = "")
			ParentNewStr := ParentStr

		ParentStr := ParentNewStr

		FileRead, PGScript, Parent2Gem.ahk
		FileDelete, Parent2Gem.ahk
		ParentNewStr = ParentStr := "%ParentNewStr%"
		PGScript := RegExReplace(PGScript, "ParentStr := ""[A-Za-z0-9()+]*""", ParentNewStr, , 1)

		CustomTemp = CurrentCustom := "%CustomFormula%"
		if (ChosenCombine = "Custom")
			PGScript := RegExReplace(PGScript, "CurrentCustom := "".*""", CustomTemp, , 1)

		LastDDLTemp = LastDDL := %LastDDL%
		PGScript := RegExReplace(PGScript, "LastDDL := [0-9]*", LastDDLTemp, , 1)

		FileAppend, %PGScript%, Parent2Gem.ahk

		Gui, Destroy
	Return
}
!C::

if (InitialMode = False) {
	MsgBox, You have to adapt the script to your screen-resolution. You will be redirected to the options-menu, where you can hit the "Setup Script"-Button to do this.
	OptionsMenu()
}
else {
	FieldWidth := (BottomRightCornerX - TopLeftCornerX) / 3
	FieldHeight := (BottomRightCornerY - TopLeftCornerY) / 12
	CraftingField := [BottomRightCornerX -(FieldWidth / 2), BottomRightCornerY -(FieldHeight / 2)]

	i := 0
	j := 0
	StkCount := 1
	initPos := [TopLeftCornerX + (FieldWidth / 2), BottomRightCornerY - (FieldHeight * 1.5)]
	StackFields := []
	While i < 12
	{
		while j < 3
		{
			StackFields[StkCount, 1] := initPos[1] + (j * FieldWidth)
			StackFields[StkCount, 2] := initPos[2] - (i * FieldHeight)
			StkCount := StkCount + 1
			j := j + 1
		}
		j := 0
		i := i + 1
	}

	CurrentStk := 0

	OGem() {
		global CraftingField
		Send {Numpad7}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}
	YGem() {
		global CraftingField
		Send {Numpad8}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}
	BGem() {
		global CraftingField
		Send {Numpad1}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}
	RGem() {
		global CraftingField
		Send {Numpad4}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}
	WGem() {
		global CraftingField
		Send {Numpad9}
		MouseClick, left, CraftingField[1], CraftingField[2]
	}

	GGem() {
		global CraftingField
		global FieldWidth
		MouseMove, CraftingField[1]-(2*FieldWidth), CraftingField[2]
		send d
	}

	AddtoStk() {
		global CraftingField
		global CurrentStk
		global StackFields
		if CurrentStk != 0
			{
			Send g
			MouseClickDrag, L, CraftingField[1], CraftingField[2], StackFields[CurrentStk][1], StackFields[CurrentStk][2]
			}
	}

	MovetoStk() {
		global CraftingField
		global CurrentStk
		global StackFields
		CurrentStk := CurrentStk + 1
		MouseClickDrag, L, CraftingField[1], CraftingField[2], StackFields[CurrentStk][1], StackFields[CurrentStk][2]
	}

	PopStk() {
		global CraftingField
		global CurrentStk
		global StackFields
		if CurrentStk > 1
			{
			Send g
			MouseClickDrag, L, StackFields[CurrentStk][1], StackFields[CurrentStk][2], StackFields[CurrentStk - 1][1], StackFields[CurrentStk - 1][2]
			CurrentStk := CurrentStk - 1
			}
	}

	if (CombineMode = True) {
		StrPosEnd := StrLen(ParentStr)
		ElementFound := False
		While ElementFound = False {
			if (SubStr(ParentStr, StrPosEnd, 1) != ")") {
				ElementFound := True
				LastGemPos := StrPosEnd
			}
			StrPosEnd := StrPosEnd - 1
		}
	}

	StrPos := 1
	Parents := []

	While StrPos < StrLen(ParentStr) {
		if (SubStr(ParentStr, StrPos, 1) = "(") {
			if ((SubStr(ParentStr, StrPos - 1, 1) = "(") or (StrPos = 1))
				Parents.Insert(False)
			else
				Parents.Insert(True)
		}

		if (SubStr(ParentStr, StrPos, 1) = ")") {
			if (Parents[Parents.MaxIndex()] = True)
				PopStk()
			Parents.remove(Parents.MaxIndex())
		}

		if (SubStr(ParentStr, StrPos, 1) = "o") {
			OGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}

		if (SubStr(ParentStr, StrPos, 1) = "r") {
			RGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}

		if (SubStr(ParentStr, StrPos, 1) = "b") {
			BGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}

		if (SubStr(ParentStr, StrPos, 1) = "y") {
			YGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}
		if (SubStr(ParentStr, StrPos, 1) = "w") {
			WGem()
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}
		if ((SubStr(ParentStr, StrPos, 1) = "g") or (SubStr(ParentStr, StrPos, 1) = "k") or (SubStr(ParentStr, StrPos, 1) = "m")) {
			if (LastGemPos != StrPos)
				GGem()
			else
				MouseClickDrag, L, CraftingField[1]-(2*FieldWidth), CraftingField[2], CraftingField[1], CraftingField[2]
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
		}

		if ((SubStr(ParentStr, StrPos, 1) < 10) and (SubStr(ParentStr, StrPos, 1) > 1)) {
			if (SubStr(ParentStr, StrPos + 1, 1) = "o")
				OGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "y")
				YGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "b")
				BGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "r")
				RGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "w")
				WGem()
			if (SubStr(ParentStr, StrPos + 1, 1) = "g") {
				if (LastGemPos != StrPos + 1)
					GGem()
				else
					MouseClickDrag, L, CraftingField[1]-(2*FieldWidth), CraftingField[2], CraftingField[1], CraftingField[2]
			}
			UCount := 1
			While UCount <= SubStr(ParentStr, StrPos + 1, 1) {
				MouseMove, CraftingField[1], CraftingField[2]
				send u
				UCount := UCount + 1
			}

			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()
			StrPos := StrPos + 1
		}

		if (SubStr(ParentStr, StrPos, 1) = "a") {
			MouseClickDrag, L, TopLeftCornerX + (FieldWidth / 2), TopLeftCornerY + (FieldHeight / 2), CraftingField[1], CraftingField[2]
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()

		}
		if (SubStr(ParentStr, StrPos, 1) = "s") {
			MouseClickDrag, L, TopLeftCornerX + (FieldWidth * 1.5), TopLeftCornerY + (FieldHeight / 2), CraftingField[1], CraftingField[2]
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()

		}
		if (SubStr(ParentStr, StrPos, 1) = "d") {
			MouseClickDrag, L, TopLeftCornerX + (FieldWidth * 2.5), TopLeftCornerY + (FieldHeight / 2), CraftingField[1], CraftingField[2]
			if (SubStr(ParentStr, StrPos - 1, 1) = "(")
				MovetoStk()
			else
				AddtoStk()

		}
		StrPos := StrPos + 1
	}
	while CurrentStk > 1 {
		PopStk()
	}
}

Return


Delete OLite.ahk

Delete OLite.ahk


RunZ: add SearchInWeb to fallback function

global Arg

Functions:
    @("Help", "帮助信息")
    @("AhkRun", "使用 Ahk 的 Run 运行 `; cmd", true)
    @("CmdRun", "使用 cmd 运行 : cmd", true)
    @("RunAndDisplay", "使用 cmd 运行，并显示结果", true)
    @("ReloadFiles", "重新加载需要搜索的文件")
    @("Clip", "显示剪切板内容")
    @("Calc", "计算器")
    @("SearchInWeb", "在浏览器（百度）搜索剪切板或输入内容", true)
    @("EditConfig", "编辑配置文件")
    @("ClearClipboardFormat", "清除剪切板中文字的格式")
    @("RunClipboard", "使用 ahk 的 Run 运行剪切板内容")
    @("T2S", "繁体转简体剪切板内容")
    @("ShowIp", "显示 IP")
    @("Calendar", "用浏览器打开万年历")
    @("Dictionary", "词典，依赖 bash 和 ydcv")
    @("ArgTest", "参数测试：ArgTest arg1,arg2,...")
return

Help:
    helpText := ""
        . "键入内容 搜索，回车 执行（a），Alt + 字母 执行，F1 帮助，Esc 退出`n"
        . "Tab + 字母 也可执行字母对应功能`n"
        . "Tab + 大写字母 可将字母对应功能加入到配置文件，以便优先显示`n"
        . "Ctrl + r 重新创建待搜索文件列表`n"
        . "Ctrl + j 清除编辑框内容`n"
        . "Ctrl + d 用 TC 打开第一个文件所在目录`n"
        . "Ctrl + s 显示并复制第一个文件的完整路径`n"
        . "Ctrl + x 删除第一个文件`n"
        . "F2 编辑配置文件`n`n"
        . "可直接输入网址，如 www.baidu.com`n"
        . "分号开头则使用 ahk 的 Run 运行命令，如 `;ping www.bidu.com`n"
        . "冒号开头则在 cmd 运行命令，如 :ping www.baidu.com`n"
        . "当搜索无结果时，回车 也等同 run 输入内容`n"
        . "当输入内容包含空格时，列表锁定，逗号作为命令参数的分隔符"

    DisplayResult(helpText)
return

CmdRun:
    RunWithCmd(Arg)
return

AhkRun:
    Run, %Arg%
return

Clip:
    DisplayResult("剪切板内容长度 " . StrLen(clipboard) . " ：`n`n" . clipboard)
return

EditConfig:
    Run, % g_ConfFile
return

ArgTest:
    Args := StrSplit(Arg, ",")
    result := "共有 " . Args.Length() . " 个参数。`n`n"

    for index, argument in Args
    {
        result .= "第 " . index - 1 " 个参数：" . argument . "`n"
    }

    DisplayResult(result)
return

ShowIp:
    DisplayResult(A_IPAddress1
            . "`r`n" . A_IPAddress2
            . "`r`n" . A_IPAddress3
            . "`r`n" . A_IPAddress4)
return

Dictionary:
    word := Arg
    if (word == "")
    {
        word := clipboard
    }

    DisplayResult(RunAndGetOutput("echo " . word . " | ydcv"))
return

Calendar:
    Run % "http://www.baidu.com/baidu?wd=%CD%F2%C4%EA%C0%FA"
return

T2S:
    Run, notepad
    clipboard := Kanji_t2s(clipboard)
    Send, ^v
return

ClearClipboardFormat:
    clipboard := clipboard
return

SearchInWeb:
    word := clipboard
    if (Arg != "")
    {
        word := Arg
    }

    Run, https://www.baidu.com/s?wd=%word%
return

RunClipboard:
    Run, %clipboard%
return

Calc:
    result := Eval(Arg)
    DisplayResult(result)
    clipboard := result
return

RunAndDisplay:
    DisplayResult(RunAndGetOutput(Arg))
return

global Arg

Functions:
    @("Help", "帮助信息")
    @("AhkRun", "使用 Ahk 的 Run 运行 `; cmd", true)
    @("CmdRun", "使用 cmd 运行 : cmd", true)
    @("RunAndDisplay", "运行命令，并显示结果", true)
    @("ReloadFiles", "重新加载需要搜索的文件")
    @("Clip", "显示剪切板内容")
    @("Calc", "计算器")
    @("SearchInWeb", "在浏览器（百度）搜索剪切板或输入内容")
    @("EditConfig", "编辑配置文件")
    @("ClearClipboardFormat", "清除剪切板中文字的格式")
    @("RunClipboard", "使用 ahk 的 Run 运行剪切板内容")
    @("T2S", "繁体转简体剪切板内容")
    @("ShowIp", "显示 IP")
    @("Calendar", "用浏览器打开万年历")
    @("Dictionary", "词典，依赖 bash 和 ydcv")
    @("ArgTest", "参数测试：ArgTest arg1,arg2,...")
return

Help:
    helpText := ""
        . "键入内容 搜索，回车 执行（a），Alt + 字母 执行，F1 帮助，Esc 退出`n"
        . "Tab + 字母 也可执行字母对应功能`n"
        . "Tab + 大写字母 可将字母对应功能加入到配置文件，以便优先显示`n"
        . "Ctrl + r 重新创建待搜索文件列表`n"
        . "Ctrl + j 清除编辑框内容`n"
        . "Ctrl + d 用 TC 打开第一个文件所在目录`n"
        . "Ctrl + s 显示并复制第一个文件的完整路径`n"
        . "Ctrl + x 删除第一个文件`n"
        . "F2 编辑配置文件`n`n"
        . "可直接输入网址，如 www.baidu.com`n"
        . "分号开头则使用 ahk 的 Run 运行命令，如 `;ping www.bidu.com`n"
        . "冒号开头则在 cmd 运行命令，如 :ping www.baidu.com`n"
        . "当搜索无结果时，回车 也等同 run 输入内容`n"
        . "当输入内容包含空格时，列表锁定，逗号作为命令参数的分隔符"

    DisplayResult(helpText)
return

CmdRun:
    RunWithCmd(Arg)
return

AhkRun:
    Run, %Arg%
return

Clip:
    DisplayResult("剪切板内容长度 " . StrLen(clipboard) . " ：`n`n" . clipboard)
return

EditConfig:
    Run, % g_ConfFile
return

ArgTest:
    Args := StrSplit(Arg, ",")
    result := "共有 " . Args.Length() . " 个参数。`n`n"

    for index, argument in Args
    {
        result .= "第 " . index - 1 " 个参数：" . argument . "`n"
    }

    DisplayResult(result)
return

ShowIp:
    DisplayResult(A_IPAddress1
            . "`r`n" . A_IPAddress2
            . "`r`n" . A_IPAddress3
            . "`r`n" . A_IPAddress4)
return

Dictionary:
    word := Arg
    if (word == "")
    {
        word := clipboard
    }

    DisplayResult(RunAndGetOutput("echo " . word . " | ydcv"))
return

Calendar:
    Run % "http://www.baidu.com/baidu?wd=%CD%F2%C4%EA%C0%FA"
return

T2S:
    Run, notepad
    clipboard := Kanji_t2s(clipboard)
    Send, ^v
return

ClearClipboardFormat:
    clipboard := clipboard
return

SearchInWeb:
    word := clipboard
    if (Arg != "")
    {
        word := Arg
    }

    Run, https://www.baidu.com/s?wd=%word%
return

RunClipboard:
    Run, %clipboard%
return

Calc:
    result := Eval(Arg)
    DisplayResult(result)
    clipboard := result
return

RunAndDisplay:
    DisplayResult(RunAndGetOutput(Arg))
return


修改关闭显示器前等待时间

修改关闭显示器前等待时间

; RunZ:System
; 操作系统相关功能

System:
    @("Clip", "显示剪切板内容")
    @("ClearClipboardFormat", "清除剪切板中文字的格式")
    @("EmptyRecycle", "清空回收站")
    @("Logoff", "注销 登出")
    @("RestartMachine", "重启")
    @("ShutdownMachine", "关机")
    @("SuspendMachine", "挂起 睡眠 待机")
    @("HibernateMachine", "休眠")
    @("TurnMonitorOff", "关闭显示器")
    @("ListProcess", "列出进程 ps")
    @("DiskSpace", "查看磁盘空间 df")
    @("IncreaseVolume", "提高音量")
    @("DecreaseVolume", "降低音量")
    @("SystemState", "系统状态 top")
    @("KillProcess", "杀死进程")
    @("SendToClip", "发送到剪切板")
    @("ListWindow", "窗口列表")
    @("ActivateWindow", "激活窗口")
    @("ListRunningService", "列出运行的服务")
    @("ListAllService", "列出所有的服务")
    @("ShowService", "显示服务详情")
    @("ShowProcess", "显示进程详情")
return

Clip:
    GoSub, ActivateRunZ
    DisplayResult("剪切板内容长度 " . StrLen(clipboard) . " ：`n`n" . clipboard)
return

ClearClipboardFormat:
    clipboard := clipboard
return

Logoff:
    MsgBox, 4, , 将要注销，是否执行？
    IfMsgBox Yes
    {
        Shutdown, 0
    }
return

ShutdownMachine:
    MsgBox, 4, , 将要关机，是否执行？
    IfMsgBox Yes
    {
        Shutdown, 1
    }
return

RestartMachine:
    MsgBox, 4, , 将要重启机器，是否执行？
    IfMsgBox Yes
    {
        Shutdown, 2
    }
return

HibernateMachine:
    MsgBox, 4, , 将要休眠，是否执行？
    IfMsgBox Yes
    {
        ; 参数 #1: 使用 1 代替 0 来进行休眠而不是挂起。
        ; 参数 #2: 使用 1 代替 0 来立即挂起而不询问每个应用程序以获得许可。
        ; 参数 #3: 使用 1 而不是 0 来禁止所有的唤醒事件。
        DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)
    }
return

SuspendMachine:
    MsgBox, 4, , 将要待机，是否执行？
    IfMsgBox Yes
    {
        DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
    }
return

TurnMonitorOff:
    ; 关闭显示器:
    Sleep, 200
    SendMessage, 0x112, 0xF170, 2, , Program Manager
    ; 0x112 is WM_SYSCOMMAND, 0xF170 is SC_MONITORPOWER.
    ; 对上面命令的注释: 使用 -1 代替 2 来打开显示器.
    ; 使用 1 代替 2 来激活显示器的节能模式.
return

EmptyRecycle:
    MsgBox, 4, , 将要清空回收站，是否执行？
    IfMsgBox Yes
    {
        FileRecycleEmpty,
    }
return

ListProcess:
    result := ""

    for process in ComObjGet("winmgmts:").ExecQuery("select * from Win32_Process")
    {
        result .= "* | 进程 | " process.Name " | " process.CommandLine "`n"
    }
    Sort, result

    SetCommandFilter("KillProcess|ShowProcess|CountNumber")
    DisplayResult(FilterResult(AlignText(result), Arg))
    TurnOnResultFilter()
return

DiskSpace:
    result := ""

    DriveGet, list, list
    Loop, Parse, list
    {
        drive := A_LoopField ":"
        DriveGet, label, label, %drive%
        DriveGet, cap, capacity, %drive%
        DrivespaceFree, free, %drive%
        SetFormat, float, 5.2
        percent := 100 * (cap - free) / cap
        SetFormat, float, 6.2
        cap /= 1024.0
        free /= 1024.0
        result = %result%* | %drive% | 总共: %cap% G  可用: %free% G | 已使用：%percent%`%  卷标: %label%`n
    }

    DisplayResult(AlignText(result))
return

IncreaseVolume:
    SoundSet, +5
return

DecreaseVolume:
    SoundSet, -5
return

SystemState:
    if (!SetExecInterval(1))
    {
        return
    }

    GMSEx := GlobalMemoryStatusEx()
    result := "* | 状态 | 运行时间 | " Round(A_TickCount / 1000 / 3600, 3) " 小时`n"
    result .= "* | 状态 | CPU 占用 | " CPULoad() "% `n"
    result .= "* | 状态 | 内存占用 | " Round(100 * (GMSEx[2] - GMSEx[3]) / GMSEx[2], 2) "% `n"
    result .= "* | 状态 | 进程总数 | " GetProcessCount() "`n"
    result .= "* | 状态 | 内存总量 | " Round(GMSEx[2] / 1024**2, 2) "MB `n"
    result .= "* | 状态 | 可用内存 | " Round(GMSEx[3] / 1024**2, 2) "MB `n"
    DisplayResult(AlignText(result))
return

KillProcess:
    args := StrSplit(Arg, " ")
    for index, argument in args
    {
        Process, Close, %argument%
    }

    DisplayResult("已尝试杀死 " Arg " 进程")
return

SendToClip:
    clipboard := Arg
    GoSub, Clip
return

ListWindow:
    result := ""

    WinGet, id, list, , , Program Manager
    Loop, %id%
    {
        thisId := id%A_Index%
        WinGetTitle, title, ahk_id %thisId%
        WinGet, name, ProcessName, ahk_id %thisId%
        if (title == "")
        {
            continue
        }
        result .= "* | 窗口 | " name " | " title "`n"
    }

    SetCommandFilter("ActivateWindow|KillProcess")
    DisplayResult(AlignText(result))
    TurnOnResultFilter()
return

ActivateWindow:
    DisplayResult()
    ClearInput()

    if (FullPipeArg != "")
    {
        Loop, Parse, FullPipeArg, `n, `r
        {
            if (A_LoopField == "")
            {
                return
            }
            splitedLine := StrSplit(A_LoopField, " | ")
            WinActivate, % Trim(splitedLine[4])
        }
    }
    else
    {
        for index, argument in StrSplit(Arg, " ")
        {
            WinActivate, ahk_exe %argument%
        }
    }
return

ListAllService:
    result :=
    for service in ComObjGet("winmgmts:").ExecQuery("select * from Win32_Service")
    {
        result .= "* | 服务 | " service.Name " | " service.DisplayName "`n"
    }
    Sort, result

    SetCommandFilter("CountNumber|ShowService")
    DisplayResult(FilterResult(AlignText(result), Arg))
    TurnOnResultFilter()
return

ListRunningService:
    result :=
    for service in ComObjGet("winmgmts:").ExecQuery("select * from Win32_Service")
    {
        if (service.Started != 0)
        {
            result .= "* | 服务 | " service.Name " | " service.DisplayName "`n"
        }
    }
    Sort, result

    SetCommandFilter("CountNumber|ShowService")
    DisplayResult(FilterResult(AlignText(result), Arg))
    TurnOnResultFilter()
return

ShowService:
    result :=
    ; 暂时只支持一个，选得多了查起来太慢
    for service in ComObjGet("winmgmts:")
        .ExecQuery("select * from Win32_Service where Name = '" StrSplit(Arg, " ")[1] "'")
    {
        ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa394418%28v=vs.85%29.aspx
        result .= "* | 服务 | 名称 | " service.Name "`n"
        result .= "* | 服务 | 描述 | " service.Description "`n"
        result .= "* | 服务 | 是否在运行 | " service.Started "`n"
        result .= "* | 服务 | 路径 | " service.PathName "`n"
        result .= "* | 服务 | 进程 ID | " service.ProcessId "`n"
        result .= "* | 服务 | 类型 | " service.ServiceType "`n"
        break
    }

    DisplayResult(AlignText(result))
return

ShowProcess:
    result :=
    ; 暂时只支持一个，选得多了查起来太慢
    for process in ComObjGet("winmgmts:")
        .ExecQuery("select * from Win32_Process where Name = '" StrSplit(Arg, " ")[1] "'")
    {
        ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa394372%28v=vs.85%29.aspx
        result .= "* | 服务 | 名称 | " process.Name "`n"
        result .= "* | 服务 | 描述 | " process.Description "`n"
        result .= "* | 服务 | 命令行 | " process.CommandLine "`n"
        result .= "* | 服务 | 启动时间 | " process.CreationDate "`n"
        result .= "* | 服务 | ID | " process.ProcessId "`n"
        break
    }

    DisplayResult(AlignText(result))
return

; RunZ:System
; 操作系统相关功能

System:
    @("Clip", "显示剪切板内容")
    @("ClearClipboardFormat", "清除剪切板中文字的格式")
    @("EmptyRecycle", "清空回收站")
    @("Logoff", "注销 登出")
    @("RestartMachine", "重启")
    @("ShutdownMachine", "关机")
    @("SuspendMachine", "挂起 睡眠 待机")
    @("HibernateMachine", "休眠")
    @("TurnMonitorOff", "关闭显示器")
    @("ListProcess", "列出进程 ps")
    @("DiskSpace", "查看磁盘空间 df")
    @("IncreaseVolume", "提高音量")
    @("DecreaseVolume", "降低音量")
    @("SystemState", "系统状态 top")
    @("KillProcess", "杀死进程")
    @("SendToClip", "发送到剪切板")
    @("ListWindow", "窗口列表")
    @("ActivateWindow", "激活窗口")
    @("ListRunningService", "列出运行的服务")
    @("ListAllService", "列出所有的服务")
    @("ShowService", "显示服务详情")
    @("ShowProcess", "显示进程详情")
return

Clip:
    GoSub, ActivateRunZ
    DisplayResult("剪切板内容长度 " . StrLen(clipboard) . " ：`n`n" . clipboard)
return

ClearClipboardFormat:
    clipboard := clipboard
return

Logoff:
    MsgBox, 4, , 将要注销，是否执行？
    IfMsgBox Yes
    {
        Shutdown, 0
    }
return

ShutdownMachine:
    MsgBox, 4, , 将要关机，是否执行？
    IfMsgBox Yes
    {
        Shutdown, 1
    }
return

RestartMachine:
    MsgBox, 4, , 将要重启机器，是否执行？
    IfMsgBox Yes
    {
        Shutdown, 2
    }
return

HibernateMachine:
    MsgBox, 4, , 将要休眠，是否执行？
    IfMsgBox Yes
    {
        ; 参数 #1: 使用 1 代替 0 来进行休眠而不是挂起。
        ; 参数 #2: 使用 1 代替 0 来立即挂起而不询问每个应用程序以获得许可。
        ; 参数 #3: 使用 1 而不是 0 来禁止所有的唤醒事件。
        DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)
    }
return

SuspendMachine:
    MsgBox, 4, , 将要待机，是否执行？
    IfMsgBox Yes
    {
        DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
    }
return

TurnMonitorOff:
    ; 关闭显示器:
    Sleep, 100
    SendMessage, 0x112, 0xF170, 2, , Program Manager
    ; 0x112 is WM_SYSCOMMAND, 0xF170 is SC_MONITORPOWER.
    ; 对上面命令的注释: 使用 -1 代替 2 来打开显示器.
    ; 使用 1 代替 2 来激活显示器的节能模式.
return

EmptyRecycle:
    MsgBox, 4, , 将要清空回收站，是否执行？
    IfMsgBox Yes
    {
        FileRecycleEmpty,
    }
return

ListProcess:
    result := ""

    for process in ComObjGet("winmgmts:").ExecQuery("select * from Win32_Process")
    {
        result .= "* | 进程 | " process.Name " | " process.CommandLine "`n"
    }
    Sort, result

    SetCommandFilter("KillProcess|ShowProcess|CountNumber")
    DisplayResult(FilterResult(AlignText(result), Arg))
    TurnOnResultFilter()
return

DiskSpace:
    result := ""

    DriveGet, list, list
    Loop, Parse, list
    {
        drive := A_LoopField ":"
        DriveGet, label, label, %drive%
        DriveGet, cap, capacity, %drive%
        DrivespaceFree, free, %drive%
        SetFormat, float, 5.2
        percent := 100 * (cap - free) / cap
        SetFormat, float, 6.2
        cap /= 1024.0
        free /= 1024.0
        result = %result%* | %drive% | 总共: %cap% G  可用: %free% G | 已使用：%percent%`%  卷标: %label%`n
    }

    DisplayResult(AlignText(result))
return

IncreaseVolume:
    SoundSet, +5
return

DecreaseVolume:
    SoundSet, -5
return

SystemState:
    if (!SetExecInterval(1))
    {
        return
    }

    GMSEx := GlobalMemoryStatusEx()
    result := "* | 状态 | 运行时间 | " Round(A_TickCount / 1000 / 3600, 3) " 小时`n"
    result .= "* | 状态 | CPU 占用 | " CPULoad() "% `n"
    result .= "* | 状态 | 内存占用 | " Round(100 * (GMSEx[2] - GMSEx[3]) / GMSEx[2], 2) "% `n"
    result .= "* | 状态 | 进程总数 | " GetProcessCount() "`n"
    result .= "* | 状态 | 内存总量 | " Round(GMSEx[2] / 1024**2, 2) "MB `n"
    result .= "* | 状态 | 可用内存 | " Round(GMSEx[3] / 1024**2, 2) "MB `n"
    DisplayResult(AlignText(result))
return

KillProcess:
    args := StrSplit(Arg, " ")
    for index, argument in args
    {
        Process, Close, %argument%
    }

    DisplayResult("已尝试杀死 " Arg " 进程")
return

SendToClip:
    clipboard := Arg
    GoSub, Clip
return

ListWindow:
    result := ""

    WinGet, id, list, , , Program Manager
    Loop, %id%
    {
        thisId := id%A_Index%
        WinGetTitle, title, ahk_id %thisId%
        WinGet, name, ProcessName, ahk_id %thisId%
        if (title == "")
        {
            continue
        }
        result .= "* | 窗口 | " name " | " title "`n"
    }

    SetCommandFilter("ActivateWindow|KillProcess")
    DisplayResult(AlignText(result))
    TurnOnResultFilter()
return

ActivateWindow:
    DisplayResult()
    ClearInput()

    if (FullPipeArg != "")
    {
        Loop, Parse, FullPipeArg, `n, `r
        {
            if (A_LoopField == "")
            {
                return
            }
            splitedLine := StrSplit(A_LoopField, " | ")
            WinActivate, % Trim(splitedLine[4])
        }
    }
    else
    {
        for index, argument in StrSplit(Arg, " ")
        {
            WinActivate, ahk_exe %argument%
        }
    }
return

ListAllService:
    result :=
    for service in ComObjGet("winmgmts:").ExecQuery("select * from Win32_Service")
    {
        result .= "* | 服务 | " service.Name " | " service.DisplayName "`n"
    }
    Sort, result

    SetCommandFilter("CountNumber|ShowService")
    DisplayResult(FilterResult(AlignText(result), Arg))
    TurnOnResultFilter()
return

ListRunningService:
    result :=
    for service in ComObjGet("winmgmts:").ExecQuery("select * from Win32_Service")
    {
        if (service.Started != 0)
        {
            result .= "* | 服务 | " service.Name " | " service.DisplayName "`n"
        }
    }
    Sort, result

    SetCommandFilter("CountNumber|ShowService")
    DisplayResult(FilterResult(AlignText(result), Arg))
    TurnOnResultFilter()
return

ShowService:
    result :=
    ; 暂时只支持一个，选得多了查起来太慢
    for service in ComObjGet("winmgmts:")
        .ExecQuery("select * from Win32_Service where Name = '" StrSplit(Arg, " ")[1] "'")
    {
        ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa394418%28v=vs.85%29.aspx
        result .= "* | 服务 | 名称 | " service.Name "`n"
        result .= "* | 服务 | 描述 | " service.Description "`n"
        result .= "* | 服务 | 是否在运行 | " service.Started "`n"
        result .= "* | 服务 | 路径 | " service.PathName "`n"
        result .= "* | 服务 | 进程 ID | " service.ProcessId "`n"
        result .= "* | 服务 | 类型 | " service.ServiceType "`n"
        break
    }

    DisplayResult(AlignText(result))
return

ShowProcess:
    result :=
    ; 暂时只支持一个，选得多了查起来太慢
    for process in ComObjGet("winmgmts:")
        .ExecQuery("select * from Win32_Process where Name = '" StrSplit(Arg, " ")[1] "'")
    {
        ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa394372%28v=vs.85%29.aspx
        result .= "* | 服务 | 名称 | " process.Name "`n"
        result .= "* | 服务 | 描述 | " process.Description "`n"
        result .= "* | 服务 | 命令行 | " process.CommandLine "`n"
        result .= "* | 服务 | 启动时间 | " process.CreationDate "`n"
        result .= "* | 服务 | ID | " process.ProcessId "`n"
        break
    }

    DisplayResult(AlignText(result))
return


Minor refactor

Minor refactor

; JKLmouse for AutoHotkey by Michael Geary
; http://www.jklmouse.com/ - documentation
; http://unlicense.org/ - public domain statement
; Version 0.1: 11/3/2011

#SingleInstance force

SetKeyDelay, -1
SetMouseDelay, -1

repeat = 0

SetKey( mod, key, action ) {
	keydown = %mod% & %key%
	Hotkey %keydown%, %action%
	Hotkey %keydown% UP, StopAcceleration
}

SetKeys( mod ) {

	; Left hand
	SetKey( mod, "W", "MouseLeftUp" )
	SetKey( mod, "E", "MouseUp" )
	SetKey( mod, "R", "MouseRightUp" )
	SetKey( mod, "S", "MouseLeft" )
	SetKey( mod, "D", "MouseDown" )
	SetKey( mod, "F", "MouseRight" )
	SetKey( mod, "X", "MouseLeftDown" )
	SetKey( mod, "C", "MouseDown" )
	SetKey( mod, "V", "MouseRightDown" )

	; Right hand
	SetKey( mod, "U", "MouseLeftUp" )
	SetKey( mod, "I", "MouseUp" )
	SetKey( mod, "O", "MouseRightUp" )
	SetKey( mod, "J", "MouseLeft" )
	SetKey( mod, "K", "MouseDown" )
	SetKey( mod, "L", "MouseRight" )
	SetKey( mod, "M", "MouseLeftDown" )
;	SetKey( mod", "`, "," MoveDown )
;	SetKey( mod", "`. "," MoveRightDown )

	; Numeric
	SetKey( mod, "7", "MouseLeftUp" )
	SetKey( mod, "8", "MouseUp" )
	SetKey( mod, "9", "MouseRightUp" )
	SetKey( mod, "4", "MouseLeft" )
	SetKey( mod, "5", "MouseDown" )
	SetKey( mod, "6", "MouseRight" )
	SetKey( mod, "1", "MouseLeftDown" )
	SetKey( mod, "2", "MouseDown" )
	SetKey( mod, "3", "MouseRightDown" )

	; Arrows
	SetKey( mod, "Up", "MouseUp" )
	SetKey( mod, "Down", "MouseDown" )
	SetKey( mod, "Left", "MouseLeft" )
	SetKey( mod, "Right", "MouseRight" )

}

SetKeys( "CapsLock" )
SetKeys( "~LButton" )
SetKeys( "~RButton" )
SetKeys( "~MButton" )
SetKeys( "~XButton1" )
SetKeys( "~XButton2" )

return

Move( x, y ) {
	global repeat
	++repeat
	factor := Floor( ( repeat + 1 ) / 2 )
	x := x * factor
	y := y * factor
	MouseMove, x, y, 0, R
}

MouseUp:
	Move( 0, -1 )
	return
MouseDown:
	Move( 0, 1 )
	return
MouseLeft:
	Move( -1, 0 )
	return
MouseRight:
	Move( 1, 0 )
	return
MouseLeftUp:
	Move( -1, -1 )
	return
MouseRightUp:
	Move( 1, -1 )
	return
MouseLeftDown:
	Move( -1, 1 )
	return
MouseRightDown:
	Move( 1, 1 )
	return

StopAcceleration:
	repeat = 0
	return

; JKLmouse for AutoHotkey by Michael Geary
; http://www.jklmouse.com/ - documentation
; http://unlicense.org/ - public domain statement
; Version 0.1: 11/3/2011

#SingleInstance force

SetKeyDelay, -1
SetMouseDelay, -1

repeat = 0

SetKey( mod, key, action ) {
	keydown = %mod% & %key%
	keyup = %keydown% UP
	Hotkey %keydown%, %action%
	Hotkey %keyup%, StopAcceleration
}

SetKeys( mod ) {

	; Left hand
	SetKey( mod, "W", "MouseLeftUp" )
	SetKey( mod, "E", "MouseUp" )
	SetKey( mod, "R", "MouseRightUp" )
	SetKey( mod, "S", "MouseLeft" )
	SetKey( mod, "D", "MouseDown" )
	SetKey( mod, "F", "MouseRight" )
	SetKey( mod, "X", "MouseLeftDown" )
	SetKey( mod, "C", "MouseDown" )
	SetKey( mod, "V", "MouseRightDown" )

	; Right hand
	SetKey( mod, "U", "MouseLeftUp" )
	SetKey( mod, "I", "MouseUp" )
	SetKey( mod, "O", "MouseRightUp" )
	SetKey( mod, "J", "MouseLeft" )
	SetKey( mod, "K", "MouseDown" )
	SetKey( mod, "L", "MouseRight" )
	SetKey( mod, "M", "MouseLeftDown" )
;	SetKey( mod", "`, "," MoveDown )
;	SetKey( mod", "`. "," MoveRightDown )

	; Numeric
	SetKey( mod, "7", "MouseLeftUp" )
	SetKey( mod, "8", "MouseUp" )
	SetKey( mod, "9", "MouseRightUp" )
	SetKey( mod, "4", "MouseLeft" )
	SetKey( mod, "5", "MouseDown" )
	SetKey( mod, "6", "MouseRight" )
	SetKey( mod, "1", "MouseLeftDown" )
	SetKey( mod, "2", "MouseDown" )
	SetKey( mod, "3", "MouseRightDown" )

	; Arrows
	SetKey( mod, "Up", "MouseUp" )
	SetKey( mod, "Down", "MouseDown" )
	SetKey( mod, "Left", "MouseLeft" )
	SetKey( mod, "Right", "MouseRight" )

}

SetKeys( "CapsLock" )
SetKeys( "~LButton" )
SetKeys( "~RButton" )
SetKeys( "~MButton" )
SetKeys( "~XButton1" )
SetKeys( "~XButton2" )

return

Move( x, y ) {
	global repeat
	++repeat
	factor := Floor( ( repeat + 1 ) / 2 )
	x := x * factor
	y := y * factor
	MouseMove, x, y, 0, R
}

MouseUp:
	Move( 0, -1 )
	return
MouseDown:
	Move( 0, 1 )
	return
MouseLeft:
	Move( -1, 0 )
	return
MouseRight:
	Move( 1, 0 )
	return
MouseLeftUp:
	Move( -1, -1 )
	return
MouseRightUp:
	Move( 1, -1 )
	return
MouseLeftDown:
	Move( -1, 1 )
	return
MouseRightDown:
	Move( 1, 1 )
	return

StopAcceleration:
	repeat = 0
	return