[chore] Add persistence (#45)

[chore] Add persistence (#45)

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; DEVELOPMENT TOOLS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#Persistent

#c::
  WinGetActiveTitle, title
  MsgBox %title%
  title := ""
Return

#^c::
  WinGetClass, class, A
  MsgBox %class%
  class := ""
Return

f12::Reload

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; DEVELOPMENT TOOLS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#c::
  WinGetActiveTitle, title
  MsgBox %title%
  title := ""
Return

#^c::
  WinGetClass, class, A
  MsgBox %class%
  class := ""
Return

f12::Reload


Фикс добавления переноса строки при отработке выделения

; #IfWinActive  ahk_class V8TopLevelFrame
#IfWinActive ahk_class V8TopLevelFrame

; #include Clipboard_rus_subs.ahk

getTextFromFile() {
  FileRead, newText, tmp\module.txt
  ClipWait, 1
  Clipboard := newText
  ClipWait, 1

  Return %newText%
}

pasteTextFromFile() {
  FileRead, newText, tmp\module.txt
  StringTrimRight, newText, newText, 2
  ClipWait, 1
  Clipboard := newText
  ClipWait, 1
  SendInput +{ins}
}

set_locale_ru() {
	SendMessage, 0x50,, 0x4190419,, A
}

set_locale_en() {
  SendMessage, 0x50,, 0x4090409,, A
}

putSelectionInFile(fileName=0, flagSaveClipboard = 1) {
	clipboard :=
	set_locale_ru()
	if (flagSaveClipboard = 1)
		SaveClipboard()

	if (fileName = 0) {
		fileName = tmp\module.txt
	}

	module := fileName
	SendInput, ^{ins}
	ClipWait

	FileDelete %module%
	FileAppend, %clipboard%`r`n, %module%

	if (flagSaveClipboard = 1)
		RestoreClipboard()
}

putModuleInFile() {
	PutCurrentModuleTextIntoFileFast(0, 1)
}

putModuleInFileWithSavePosition() {

	module = tmp\module.txt

	FileDelete %module%

	set_locale_ru()

	clipboard :=
	SendInput, ^+{Home}^{ins}{Right}
	ClipWait
	ClipWait
	FileAppend, %clipboard%, %module%

	clipboard :=
	SendInput, ^+{End}^{ins}{Left}
	ClipWait
	ClipWait
	FileAppend, %clipboard%, %module%
}

/*
; Don't work selectValue, why?
putModuleInFile(fileName = 0) {

	if (fileName = 0) {
		module = tmp\module.txt
	} else {
		module = fileName
	}

	FileDelete %module%

	set_locale_ru()

	clipboard := ""
	SendInput, ^+{Home}^{ins}{Right}
	ClipWait
	ClipWait
	FileAppend, %clipboard%, %module%

	clipboard := ""
	SendInput, ^+{End}^{ins}{Left}
	ClipWait
	ClipWait
	FileAppend, %clipboard%, %module%

}
*/
getTextUp() {
	clipboard :=
	SendInput, {CTRLDOWN}{ALTDOWN}{SHIFTDOWN}{Home}{CTRLUP}{ALTUP}{SHIFTUP}{CTRLDOWN}{INS}{CTRLUP}{Right}
	ClipWait
	FileDelete tmp\module.txt
	FileAppend, %clipboard%, tmp\module.txt
	clipboard :=
}

getTextDown() {
	clipboard :=
	SendInput, ^+{End}^{ins}{Left}
	ClipWait
	FileDelete tmp\module.txt
	FileAppend, %clipboard%, tmp\module.txt
	clipboard :=
}

PutCurrentModuleTextIntoFileFast(fileName = 0, flagSaveClipboard = 1) {
	set_locale_ru()
	if (flagSaveClipboard = 1)
		SaveClipboard()

	module = tmp\module.txt
	if (fileName <> 0) {
		module = fileName
	}

	;Sleep 30
	SendInput ^{SC01E}^{ins}{Left}
	ClipWait

	FileDelete %module%
	FileAppend, %clipboard%, %module%

	if (flagSaveClipboard = 1)
		RestoreClipboard()
}

;       -
PutCurrentModuleTextIntoFile(fileName, flagSaveClipboard = 1) {
	set_locale_ru()
	if (flagSaveClipboard = 1)
		SaveClipboard()

	module := fileName
	;set_locale_ru()

	;Sleep 30
	SendInput ^{SC01E} ; CTRL-A
	;Sleep 30
	SendInput, ^{ins}
	;Sleep 30
	ClipWait

	FileDelete %module%
	FileAppend, %clipboard%, %module%

	if (flagSaveClipboard = 1)
		RestoreClipboard()
}

PutCurrentModuleTextIntoTempFile() {
	module = tmp\module.1s
	PutCurrentModuleTextIntoFile(module)
}

gClipSavedInner45 :=

SaveClipboard()
{
	global gClipSavedInner45 ;
	gClipSavedInner45 := ClipboardAll
	clipboard =

	ClipWait , 1
}

RestoreClipboard()
{
	global gClipSavedInner45 ;
	Clipboard := gClipSavedInner45
	gClipSavedInner45 =
}

; #IfWinActive  ahk_class V8TopLevelFrame
#IfWinActive ahk_class V8TopLevelFrame

; #include Clipboard_rus_subs.ahk

getTextFromFile() {
  FileRead, newText, tmp\module.txt
  ClipWait, 1
  Clipboard := newText
  ClipWait, 1

  Return %newText%
}

pasteTextFromFile() {
  FileRead, newText, tmp\module.txt
  ClipWait, 1
  Clipboard := newText
  ClipWait, 1
  SendInput +{ins}
}

set_locale_ru() {
	SendMessage, 0x50,, 0x4190419,, A
}

set_locale_en() {
  SendMessage, 0x50,, 0x4090409,, A
}

putSelectionInFile(fileName=0, flagSaveClipboard = 1) {
	clipboard :=
	set_locale_ru()
	if (flagSaveClipboard = 1)
		SaveClipboard()

	if (fileName = 0) {
		fileName = tmp\module.txt
	}

	module := fileName
	SendInput, ^{ins}
	ClipWait

	FileDelete %module%
	FileAppend, %clipboard%, %module%

	if (flagSaveClipboard = 1)
		RestoreClipboard()
}

putModuleInFile() {
	PutCurrentModuleTextIntoFileFast(0, 1)
}

putModuleInFileWithSavePosition() {

	module = tmp\module.txt

	FileDelete %module%

	set_locale_ru()

	clipboard :=
	SendInput, ^+{Home}^{ins}{Right}
	ClipWait
	ClipWait
	FileAppend, %clipboard%, %module%

	clipboard :=
	SendInput, ^+{End}^{ins}{Left}
	ClipWait
	ClipWait
	FileAppend, %clipboard%, %module%
}

/*
; Don't work selectValue, why?
putModuleInFile(fileName = 0) {

	if (fileName = 0) {
		module = tmp\module.txt
	} else {
		module = fileName
	}

	FileDelete %module%

	set_locale_ru()

	clipboard := ""
	SendInput, ^+{Home}^{ins}{Right}
	ClipWait
	ClipWait
	FileAppend, %clipboard%, %module%

	clipboard := ""
	SendInput, ^+{End}^{ins}{Left}
	ClipWait
	ClipWait
	FileAppend, %clipboard%, %module%

}
*/
getTextUp() {
	clipboard :=
	SendInput, {CTRLDOWN}{ALTDOWN}{SHIFTDOWN}{Home}{CTRLUP}{ALTUP}{SHIFTUP}{CTRLDOWN}{INS}{CTRLUP}{Right}
	ClipWait
	FileDelete tmp\module.txt
	FileAppend, %clipboard%, tmp\module.txt
	clipboard :=
}

getTextDown() {
	clipboard :=
	SendInput, ^+{End}^{ins}{Left}
	ClipWait
	FileDelete tmp\module.txt
	FileAppend, %clipboard%, tmp\module.txt
	clipboard :=
}

PutCurrentModuleTextIntoFileFast(fileName = 0, flagSaveClipboard = 1) {
	set_locale_ru()
	if (flagSaveClipboard = 1)
		SaveClipboard()

	module = tmp\module.txt
	if (fileName <> 0) {
		module = fileName
	}

	;Sleep 30
	SendInput ^{SC01E}^{ins}{Left}
	ClipWait

	FileDelete %module%
	FileAppend, %clipboard%, %module%

	if (flagSaveClipboard = 1)
		RestoreClipboard()
}

;       -
PutCurrentModuleTextIntoFile(fileName, flagSaveClipboard = 1) {
	set_locale_ru()
	if (flagSaveClipboard = 1)
		SaveClipboard()

	module := fileName
	;set_locale_ru()

	;Sleep 30
	SendInput ^{SC01E} ; CTRL-A
	;Sleep 30
	SendInput, ^{ins}
	;Sleep 30
	ClipWait

	FileDelete %module%
	FileAppend, %clipboard%, %module%

	if (flagSaveClipboard = 1)
		RestoreClipboard()
}

PutCurrentModuleTextIntoTempFile() {
	module = tmp\module.1s
	PutCurrentModuleTextIntoFile(module)
}

gClipSavedInner45 :=

SaveClipboard()
{
	global gClipSavedInner45 ;
	gClipSavedInner45 := ClipboardAll
	clipboard =

	ClipWait , 1
}

RestoreClipboard()
{
	global gClipSavedInner45 ;
	Clipboard := gClipSavedInner45
	gClipSavedInner45 =
}


fix test script output

fix test script output

Assert(a ? false : true, "Uninitialized var is not false")

c := 5
c += 8.2
Assert(c == 13.2, "+= failed")

; just testing if the expression isn't too long
b := 5
b .= ": " 5 + 8.2 " = " c " = " . 13.2 " != " 1 * 1 - 13.2 + 5.8 " + 4e-2 == " 0.001 * (0 + 1) * 10 ** 0 " += c"

var := ""
DriveGet(var, "List", "")
Assert(var != "", "'DriveGet List' failed")

Assert(A_YYYY "" == 2013 "", "The year has changed since 2013 :)")

Assert(A_WorkingDir != "", "A_WorkingDir is empty")

WD := A_WorkingDir
Assert(WD == A_WorkingDir, "Failed to set var to builtin var")

A_WorkingDir := A_WorkingDir . "/Tests"
Assert(A_WorkingDir == WD . "/Tests", "Failed to set A_WorkingDir")

Assert((5 < 3) ? false : true, "< failed")
Assert((5 < 3) "" == "0", "Bools as strings")

Assert((5 > 3) * 4 == 4, "Bool as int failed")

obj := { "a" : 4, 4 : 5, 5 : "a" }
Assert(obj.a "" == 4 "", "Object literal incorrect")

obj.a += 5
Assert(obj.a "" == 9 "", "+= on obj member failed")

obj.a := "a"
Assert(obj.a == "a", "obj member assignment failed")

a := 0
b := "b"
c := "c"
d := "d"
e := "e"
f := "f"
g := "g"

if (g) {
	Assert(g, "Assertion in if-Block failed")
}

; todo: fix parsing so it works without parentheses
result := (a ? b ? c : d : e ? f : g)
Assert(result == "f", "Chained ternary failed")

a := b .= c
Assert(b == "bc", "chained concat-assign failed")
Assert(a == b, "chained assignment failed")

Assert(cond, msg) {
	if (cond) {
		FileAppend("`tAssert (" cond ") : '" msg "'`n", "*")
	} else {
		throw(msg "")
	}
}

Assert(a ? false : true, "Uninitialized var is not false")

c := 5
c += 8.2
Assert(c == 13.2, "+= failed")

; just testing if the expression isn't too long
b := 5
b .= ": " 5 + 8.2 " = " c " = " . 13.2 " != " 1 * 1 - 13.2 + 5.8 " + 4e-2 == " 0.001 * (0 + 1) * 10 ** 0 " += c"

var := ""
DriveGet(var, "List", "")
Assert(var != "", "'DriveGet List' failed")

Assert(A_YYYY "" == 2013 "", "The year has changed since 2013 :)")

Assert(A_WorkingDir != "", "A_WorkingDir is empty")

WD := A_WorkingDir
Assert(WD == A_WorkingDir, "Failed to set var to builtin var")

A_WorkingDir := A_WorkingDir . "/Tests"
Assert(A_WorkingDir == WD . "/Tests", "Failed to set A_WorkingDir")

Assert((5 < 3) ? false : true, "< failed")
Assert((5 < 3) "" == "0", "Bools as strings")

Assert((5 > 3) * 4 == 4, "Bool as int failed")

obj := { "a" : 4, 4 : 5, 5 : "a" }
Assert(obj.a "" == 4 "", "Object literal incorrect")

obj.a += 5
Assert(obj.a "" == 9 "", "+= on obj member failed")

obj.a := "a"
Assert(obj.a == "a", "obj member assignment failed")

a := 0
b := "b"
c := "c"
d := "d"
e := "e"
f := "f"
g := "g"

if (g) {
	Assert(g, "Assertion in if-Block failed")
}

; todo: fix parsing so it works without parentheses
result := (a ? b ? c : d : e ? f : g)
Assert(result == "f", "Chained ternary failed")

a := b .= c
Assert(b == "bc", "chained concat-assign failed")
Assert(a == b, "chained assignment failed")

Assert(cond, msg) {
	if (cond) {
		FileAppend("Assert (" cond ") : '" msg "'\n", "*")
	} else {
		throw(msg "")
	}
}


Delete OLite.ahk

Delete OLite.ahk

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

////////////////////////////////////////////////////////////////////////////////////////
//  General                                                                           //
////////////////////////////////////////////////////////////////////////////////////////
#CommentFlag //
// The script is only active when dota2.exe is active.
#IfWinActive ahk_exe dota2.exe

////////////////////////////////////////////////////////////////////////////////////////
//  Keybinds                                                                          //
////////////////////////////////////////////////////////////////////////////////////////
// Unlocks the Second Modifier
*LAlt::
ControlSend, , {LWin down}, Dota 2
Keywait, LAlt
ControlSend, , {LWin up}, Dota 2
Return

// Binds Mouse5 as a Unified Orders Modifier
XButton2::LCtrl

////////////////////////////////////////////////////////////////////////////////////////
//  Workarounds and Fixes                                                             //
////////////////////////////////////////////////////////////////////////////////////////
// Fixes Alt + Tab
#If GetKeyState("LAlt", "p") && GetKeyState("Tab", "p")
Tab::
Send {LAlt down}
Send {Tab down}
Keywait, Tab
Send {Tab up}
Keywait, LAlt
Send {LAlt up}
return
#IfWinActive ahk_exe dota2.exe

// Keep CapsLock off
*CapsLock::
Send {CapsLock down}
Keywait, CapsLock
SetCapsLockState, off
Send {CapsLock up}
Return

// Disables Left Winkey by making it a Unified Orders Modifier
*LWin::LCtrl

////////////////////////////////////////////////////////////////////////////////////////
//  Colored Chat Hotstrings                                                           //
////////////////////////////////////////////////////////////////////////////////////////
#Hotstring EndChars :
//red = "r:"
::r::
Clipboard =
SendEvent ^v^v
Return

//blue = "b:"
::b::
Clipboard =
SendEvent ^v^v
Return

//green = "g:"
::g::
Clipboard =
SendEvent ^v^v
Return

//yellow = "y:"
::y::
Clipboard =
SendEvent ^v^v
Return

//magenta = "m:"
::m::
Clipboard =
SendEvent ^v^v
Return

//violet = "v:"
::v::
Clipboard =
SendEvent ^v^v
Return

//orange = "o:"
::o::
Clipboard =
SendEvent ^v^v
Return

//indigo = "i:"
::i::
Clipboard =
SendEvent ^v^v
Return

//pink = "p:"
::p::
Clipboard =
SendEvent ^v^v
Return

//dark green = "dg:"
::dg::
Clipboard =
SendEvent ^v^v
Return

//yellow-green = "yg:"
::yg::
Clipboard =
SendEvent ^v^v
Return

//olive = "ol:"
::ol::
Clipboard =
SendEvent ^v^v
Return

//red-pink = "rp:"
::rp::
Clipboard =
SendEvent ^v^v
Return

//silver = "s:"
::s::
Clipboard =
SendEvent ^v^v
Return


Updated dosbox.ahk for more flexible configuration