Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #singleInstance Force
- ;****************************************************************************
- ;* TODO *********************************************************************
- ;****************************************************************************
- /* === Objectively === === Subjectively ===
- 1 GUI 1 Check active window
- 2 Tray 2
- */
- ;****************************************************************************
- ;* Startup ******************************************************************
- ;****************************************************************************
- SendMode Input
- ;myIni := A_ScriptDir "\" "conf.ini"
- confDir = %A_ScriptDir%\QC_Conf
- ; checking for config files
- if ! ( fileExist(confDir "\config.ini") == "A" )
- { ; Default config file
- fileCreateDir, % confDir
- iniwrite template.ini,%confDir%\config.ini, main, activeLayout
- ; default skill template
- myIni = %confDir%\template.ini
- suspendKey = SC029
- termKey = !ESC
- KeyList := ["~F1","~F2","~F3","~F4","~F5","~F6","~F7","~F8"]
- QuickKeys := ["~F5","~F6"]
- Toggled := ["^LALT"]
- Rebound := []
- Rebound[0,0] := "~F"
- Rebound[0,1] := "F3"
- Rebound[1,0] := "~SPACE"
- Rebound[1,1] := "F5"
- Rebound[2,0] := "~E"
- Rebound[2,1] := "F6"
- Rebound[3,0] := "RBUTTON"
- Rebound[3,1] := "F2"
- Rebound[4,0] := "+RBUTTON"
- Rebound[4,1] := "F1"
- toIni("# Default settings for " A_ScriptName )
- iniWrite % suspendKey, % myIni, core, SuspendKey
- iniWrite % termKey, % myIni, core, termKey
- iniWrite % arr2String(Toggled), % myIni, hotkeys, Toggled
- iniWrite % arr2String(KeyList), % myIni, hotkeys, KeyList
- iniWrite % arr2String(QuickKeys), % myIni, hotkeys, QuickKeys
- for a, b in Rebound
- IniWrite % Rebound[a,0] ">" Rebound[a,1], % myIni, reboundkeys, % a
- msgbox, config directory created at`n%confDir%`n`nClosing
- , Please restart
- exitapp
- } else
- { iniRead myIni, %confDir%\config.ini, main, activeLayout
- myIni := confDir "\" myIni
- iniRead suspendKey, % myIni, core, SuspendKey
- iniRead termKey, % myIni, core, termKey
- iniRead xtmp, % myIni, hotkeys, KeyList
- keylist := []
- loop, parse, xtmp, "|", %A_Space%%A_Tab%
- KeyList[A_Index] := A_LoopField
- iniRead xtmp, % myIni, hotkeys, QuickKeys
- QuickKeys := []
- loop, parse, xtmp, "|", %A_Space%%A_Tab%
- QuickKeys[A_Index] := A_LoopField
- rebound := []
- loop 8
- { iniRead xtmp, % myIni, reboundkeys, % A_Index-1
- if ( xtmp ~= "ERROR" )
- break
- rebound[A_Index-1] := []
- rebound[A_Index-1,0] := regExReplace(xtmp,">.*$","")
- rebound[A_Index-1,1] := regExReplace(xtmp,"^.*>","")
- }
- iniRead xtmp, % myIni, hotkeys, Toggled
- Toggled := []
- loop, parse, xtmp, "|", %A_Space%%A_Tab%
- Toggled[A_Index] := A_LoopField
- xtmp := "", temp := "", temp0 := "", temp1 := ""
- }
- ;****************************************************************************
- ;* Binding hotkeys **********************************************************
- ;****************************************************************************
- outer:
- for a, b in KeyList
- { for b, c in QuickKeys
- { if KeyList[a] == QuickKeys[b]
- { hotkey, % KeyList[a], Bound, Enable
- continue outer
- }
- } hotkey, % "~" KeyList[a], UnBound, Enable
- }
- for a, b in rebound
- { xtmp := regExReplace(rebound[a,0],"~","")
- xtmp := regExReplace(xtmp,"\+","a")
- xtmp := regExReplace(xtmp,"!","b")
- xtmp := regExReplace(xtmp,"\^","c")
- %xtmp%act := rebound[a,1]
- hotkey, % rebound[a,0], testRebind, Enable
- }
- for a, b in Toggled
- hotkey, % Toggled[a], TogKey, Enable
- hotkey, % "~" suspendKey, suspendMe, Enable
- hotkey, % "~" termKey, killme, Enable
- Return ; End of Startup
- ;****************************************************************************
- ;* Hotkey actions ***********************************************************
- ;****************************************************************************
- UnBound: ; Every click of KeyList keys is saved as last active
- lastKey := regExReplace(A_ThisHotkey,"\W?","")
- return
- Bound: ; Bound are thy QuickKeys
- thiskey := regExReplace(A_ThisHotkey,"\W?","")
- send {%thiskey%}
- send {RBUTTON DOWN}
- keywait %thiskey%
- send {RBUTTON UP}
- send {%lastKey%}
- return
- testRebind: ; This is a terrible idea
- thisKey := regExReplace(A_ThisHotkey,"~","")
- thisKey := regExReplace(thisKey,"\+","a")
- thisKey := regExReplace(thisKey,"!","b")
- thisKey := regExReplace(thisKey,"\^","c")
- xtmp := % ( thisKey . "act" ) ;variable that holds rebound[x,1]
- xtmp := %xtmp% ; translated into rebound[x,1]
- send {%xtmp%} ; sent
- send {RBUTTON DOWN}
- keywait % regExReplace(A_ThisHotkey,"\W","")
- send {RBUTTON UP}
- send {%lastKey%}
- return
- togKey:
- thisKey := regExReplace(A_ThisHotkey,"\W?","")
- if tog%thisKey% := ! tog%thisKey%
- send {%thisKey% DOWN}
- else
- send {%thisKey% UP}
- return
- suspendMe:
- suspend
- return
- killme:
- exitapp
- ;****************************************************************************
- ;* Functions ****************************************************************
- ;****************************************************************************
- arr2String(byref tBody)
- { for key, obj in tBody
- aTip := aTip . tBody[key] ( tBody[key+1] != "" ? "|" : "" )
- return aTip
- }
- toIni(text)
- { Global myIni
- FileAppend, % text "`n", % myIni
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement