Remove #AllowSameLineComments

Remove #AllowSameLineComments

; 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

; Use either the embedded icon in a compiled .exe,
; or a separate .ico file when running the .ahk script.
iconPath := RegExReplace( A_ScriptFullPath, "i).ahk$", ".ico" )

keyMap := ""

keyMaps :=
(join
{
	Arrows: "Up~Up Down~Down Left~Left Right~Right",
	NumPad: "7~UpLeft 8~Up 9~UpRight 4~Left 5~Down 6~Right 1~DownLeft 2~Down 3~DownRight",
	IJKL: "U~UpLeft I~Up O~UpRight J~Left K~Down L~Right M~DownLeft ,~Down .~DownRight",
	HJKL: "H~Left J~Down K~Up L~Right",
	ESDF: "W~UpLeft E~Up R~UpRight S~Left D~Down F~Right X~DownLeft C~Down V~DownRight",
	WASD: "Q~UpLeft W~Up E~UpRight A~Left S~Down D~Right Z~DownLeft X~Down C~DownRight"
}
)

; Set up the tray icon and menu
Menu, Tray, Icon, %iconPath%
Menu, Tray, Tip, JKLmouse
Menu, Tray, Add
Menu, Tray, Add, Left Hand: ESDF, MenuESDF
Menu, Tray, Add, Left Hand: WASD, MenuWASD
Menu, Tray, Add
Menu, Tray, Add, Right Hand: IJKL, MenuIJKL
Menu, Tray, Add, Right Hand: HJKL, MenuHJKL
Menu, Tray, Add
Menu, Tray, Add, About JKLmouse, MenuAbout

Menu, Tray, Check, Left Hand: ESDF
Menu, Tray, Check, Right Hand: IJKL

; Display tray balloon
; TODO: more useful content?
; TODO: display this only during an install
TrayTip JKLmouse, The Automatic Keyboard Mouse

; Remove forced delay between triggered mouse events.
; TODO: experiment with this when accelerated
SetMouseDelay, -1

; Hotkey repeat count for acceleration
repeat := 0

SetKeyMap( "Arrows", "NumPad", "IJKL", "ESDF" )
;SetKeyMap( "Arrows", "NumPad", "HJKL", "WASD" )

;MsgBox % keyMap

SetAllKeys( true )

return

SetKeyMap( keys* ) {
	global keyMap, keyMaps
    for index, value in keys
        keyMap .= keyMaps[value] . " "
    return SubStr( str, 1, -StrLen(sep) )
}

SetAllKeys( on ) {
	; Each of these modifier keys enables the same set of JKLmouse hotkeys
	SetKeys( on, "CapsLock" )
	SetKeys( on, "~LButton" )
	SetKeys( on, "~RButton" )
	SetKeys( on, "~MButton" )
	SetKeys( on, "~XButton1" )
	SetKeys( on, "~XButton2" )
}

; Set up or remove all the hotkeys for a specific modifier key
SetKeys( on, mod ) {
	global keyMap
	Loop, Parse, keyMap, %A_Space%
	{
		StringSplit map, A_LoopField, ~
		SetKey( on, mod, map1, "Mouse" . map2 )
	}
}

; Set up or remove one hotkey by combining the modifier and key names.
; Take the specified action on key down,
; and always stop acceleration on key up.
SetKey( on, mod, key, action ) {
	keydown = %mod% & %key%
	if( on ) {
		Hotkey %keydown%, %action%
		Hotkey %keydown% UP, StopAcceleration
	}
	else {
		Hotkey %keydown%, Off
		Hotkey %keydown% UP, Off
	}
}

; Move the mouse the specifed x and y distances, both scaled by the
; mouse acceleration factor calculated from the key repeat count.
Move( x, y ) {
	global repeat
	++repeat
	factor := Floor( ( repeat + 1 ) / 2 )
	x := x * factor
	y := y * factor
	MouseMove, x, y, 0, R
}

;ArrayJoin( sep, ary ) {
;    for index, value in ary
;		MsgBox % index
;        ;str .= value . sep
;	MsgBox % str
;    return SubStr( str, 1, -StrLen(sep) )
;}

; Handle the keydown for each of the mouse movement directions
; TODO: Maybe a way to simplify this?
MouseUp:
	Move( 0, -1 )
	return
MouseDown:
	Move( 0, 1 )
	return
MouseLeft:
	Move( -1, 0 )
	return
MouseRight:
	Move( 1, 0 )
	return
MouseUpLeft:
	Move( -1, -1 )
	return
MouseUpRight:
	Move( 1, -1 )
	return
MouseDownLeft:
	Move( -1, 1 )
	return
MouseDownRight:
	Move( 1, 1 )
	return

; Handle the keyup for all hotkeys
StopAcceleration:
	repeat = 0
	return

; Handle the About menu item
MenuAbout:
	Run, http://www.jklmouse.com/
	return

MenuESDF:
	return

MenuWASD:
	return

MenuIJKL:
	return

MenuHJKL:
	return

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

#AllowSameLineComments
#SingleInstance force

; Use either the embedded icon in a compiled .exe,
; or a separate .ico file when running the .ahk script.
iconPath := RegExReplace( A_ScriptFullPath, "i).ahk$", ".ico" )

keyMap := ""

keyMaps :=
(join
{
	Arrows: "Up~Up Down~Down Left~Left Right~Right",
	NumPad: "7~UpLeft 8~Up 9~UpRight 4~Left 5~Down 6~Right 1~DownLeft 2~Down 3~DownRight",
	IJKL: "U~UpLeft I~Up O~UpRight J~Left K~Down L~Right M~DownLeft ,~Down .~DownRight",
	HJKL: "H~Left J~Down K~Up L~Right",
	ESDF: "W~UpLeft E~Up R~UpRight S~Left D~Down F~Right X~DownLeft C~Down V~DownRight",
	WASD: "Q~UpLeft W~Up E~UpRight A~Left S~Down D~Right Z~DownLeft X~Down C~DownRight"
}
)

; Set up the tray icon and menu
Menu, Tray, Icon, %iconPath%
Menu, Tray, Tip, JKLmouse
Menu, Tray, Add
Menu, Tray, Add, Left Hand: ESDF, MenuESDF
Menu, Tray, Add, Left Hand: WASD, MenuWASD
Menu, Tray, Add
Menu, Tray, Add, Right Hand: IJKL, MenuIJKL
Menu, Tray, Add, Right Hand: HJKL, MenuHJKL
Menu, Tray, Add
Menu, Tray, Add, About JKLmouse, MenuAbout

Menu, Tray, Check, Left Hand: ESDF
Menu, Tray, Check, Right Hand: IJKL

; Display tray balloon
; TODO: more useful content?
; TODO: display this only during an install
TrayTip JKLmouse, The Automatic Keyboard Mouse

; Remove forced delay between triggered mouse events.
; TODO: experiment with this when accelerated
SetMouseDelay, -1

; Hotkey repeat count for acceleration
repeat := 0

SetKeyMap( "Arrows", "NumPad", "IJKL", "ESDF" )
;SetKeyMap( "Arrows", "NumPad", "HJKL", "WASD" )

;MsgBox % keyMap

SetAllKeys( true )

return

SetKeyMap( keys* ) {
	global keyMap, keyMaps
    for index, value in keys
        keyMap .= keyMaps[value] . " "
    return SubStr( str, 1, -StrLen(sep) )
}

SetAllKeys( on ) {
	; Each of these modifier keys enables the same set of JKLmouse hotkeys
	SetKeys( on, "CapsLock" )
	SetKeys( on, "~LButton" )
	SetKeys( on, "~RButton" )
	SetKeys( on, "~MButton" )
	SetKeys( on, "~XButton1" )
	SetKeys( on, "~XButton2" )
}

; Set up or remove all the hotkeys for a specific modifier key
SetKeys( on, mod ) {
	global keyMap
	Loop, Parse, keyMap, %A_Space%
	{
		StringSplit map, A_LoopField, ~
		SetKey( on, mod, map1, "Mouse" . map2 )
	}
}

; Set up or remove one hotkey by combining the modifier and key names.
; Take the specified action on key down,
; and always stop acceleration on key up.
SetKey( on, mod, key, action ) {
	keydown = %mod% & %key%
	if( on ) {
		Hotkey %keydown%, %action%
		Hotkey %keydown% UP, StopAcceleration
	}
	else {
		Hotkey %keydown%, Off
		Hotkey %keydown% UP, Off
	}
}

; Move the mouse the specifed x and y distances, both scaled by the
; mouse acceleration factor calculated from the key repeat count.
Move( x, y ) {
	global repeat
	++repeat
	factor := Floor( ( repeat + 1 ) / 2 )
	x := x * factor
	y := y * factor
	MouseMove, x, y, 0, R
}

;ArrayJoin( sep, ary ) {
;    for index, value in ary
;		MsgBox % index
;        ;str .= value . sep
;	MsgBox % str
;    return SubStr( str, 1, -StrLen(sep) )
;}

; Handle the keydown for each of the mouse movement directions
; TODO: Maybe a way to simplify this?
MouseUp:
	Move( 0, -1 )
	return
MouseDown:
	Move( 0, 1 )
	return
MouseLeft:
	Move( -1, 0 )
	return
MouseRight:
	Move( 1, 0 )
	return
MouseUpLeft:
	Move( -1, -1 )
	return
MouseUpRight:
	Move( 1, -1 )
	return
MouseDownLeft:
	Move( -1, 1 )
	return
MouseDownRight:
	Move( 1, 1 )
	return

; Handle the keyup for all hotkeys
StopAcceleration:
	repeat = 0
	return

; Handle the About menu item
MenuAbout:
	Run, http://www.jklmouse.com/
	return

MenuESDF:
	return

MenuWASD:
	return

MenuIJKL:
	return

MenuHJKL:
	return


Closed #6

Closed #6

;Control key Ctrl- ^
;Alt key Alt- !
;Shift key Shift- +
;Windows key Win- #

#Persistent
;#NoTrayIcon
#SingleInstance Force
DetectHiddenWindows, On
DetectHiddenText, On
SetTitleMatchMode, RegEx ;match titles and classes using regular expressions
SetTitleMatchMode Slow ;match titles and classes using regular expressions
CoordMode, Mouse, Screen
CoordMode, ToolTip, Screen
OldTicks = 0

GroupAdd, adobe, ahk_class OWL.DocumentWindow
GroupAdd, adobe, ahk_class illustrator
GroupAdd, adobe, ahk_class PSViewC
GroupAdd, adobe, ahk_class Photoshop
GroupAdd, adobe, Photoshop

;fun functions
;activate/run
FRun(window, path, folder)
{
	if (!window or !WinExist(window))
	{
		Run, %path%, %folder%
	}
	else
	{
		WinShow
		WinActivate
	}
	return
}

;create random file name
RandomFileName()
{
	FormatTime, fileName,, yyyyMMdd_HHmmss_
	characters := "abcdefghijklmnopqrstuvwxyz"
	Loop 3
	{
		Random, rand, 1, strlen(characters)
		fileName := fileName . substr(characters, rand, 1)
	}
	return fileName
}

;check for cygwin path
CygPath = C:\Program Files (x86)\cygwin
IfNotExist %CygPath%
{
	CygPath = C:\Cygwin
}

IfExist %CygPath%
{
	;cygwin related functions go in here...

	UploadFiles()
	{
		ToolTip, Uploading files..., -1920+50, 50
		RunWait, %CygPath%\bin\mintty.exe "/bin/bash -l -c send_to_pinkyard.py|clip", %CygPath%
		ToolTip
		return
	}

	MakeScreen(arguments)
	{
		baseFileName := "Z:\hub\pinkyard\queued\" . RandomFileName()
		PNGFileName := "Z:\tmp.png"
		JPGFileName := "Z:\tmp.jpg"
		RunWait, % "C:\program files (x86)\scrsh.exe --path " . PNGFileName . " " . arguments, "Z:\", Hide
		if %ErrorLevel% = 0
		{
			RunWait, % "Z:\src\optipng\support\optipng.exe -o1 " . PNGFileName, "Z:\", Hide
			RunWait, % CygPath . "bin\convert.exe " . PNGFileName . " -quality 80 " . JPGFileName, "Z:\", Hide
			FileGetSize, JPGFileSize, % JPGFileName
			FileGetSize, PNGFileSize, % PNGFileName
			if % PNGFileSize > JPGFileSize
			{
				path1 := JPGFileName
				path2 := baseFileName . ".jpg"
			}
			else
			{
				path1 := PNGFileName
				path2 := baseFileName . ".png"
			}
			FileCopy, % path1, % path2
			FileDelete, % JPGFileName
			FileDelete, % PNGFileName
			SoundPlay, Z:\clutter\sounds\ping.wav
		}
		return path
	}

	;cygwin - activate/run
	+^![::
		Run, %CygPath%\bin\mintty.exe --size "120`,40" --position "1050`,45" --class "mintty_thetty" --exec /bin/bash --login -i, %CygPath%
		return
	 ^![::
		if (!WinExist("ahk_class mintty_thetty"))
		{
			Run, %CygPath%\bin\mintty.exe --size "120`,40" --position "1050`,45" --class "mintty_thetty" --exec /bin/bash --login -i -c 'while /bin/true; do /bin/bash; cygstart "%A_AhkPath%" "Z:\src\hide.ahk"; clear; done', %CygPath%
			WinWait ahk_class mintty_thetty
		}
		else
		{
			WinShow
			WinActivate
		}
		WinSet, Style, -0x004b0000
		return

	;ssh to burza - activate/run
	+^!]::Run, %CygPath%\bin\mintty.exe --size "200`,70" --position "100`,45" --class mintty_ssh --exec /bin/ssh -p 65000 rr-@sakuya.pl, %CygPath%/bin
	^!]::
		if (!WinExist("ahk_class mintty_ssh"))
		{
			Run, %CygPath%\bin\mintty.exe --size "200`,70" --position "100`,45" --class mintty_ssh --exec /bin/ssh -p 65000 rr-@sakuya.pl, %CygPath%/bin
			WinWait ahk_class mintty_ssh
		}
		else
		{
			WinShow
			WinActivate
		}
		return

	;text editor - activate/run + fix screen position
	+^!N::
		IfWinExist, ahk_class Vim
		{
			WinShow
			WinActivate
		}
		else
		{
			Run, %CygPath%\bin\mintty.exe --size "240`,90" --position "100`,45" --class "Vim" --exec "/bin/vim" --cmd 'cd /cygdrive/z', %CygPath%/bin
			WinWait, ahk_class Vim
		}
		WinMove, , , 100, 100, 1600, 900
		return

	+PrintScreen::MakeScreen("-g")
	!PrintScreen::MakeScreen("-r active-window --shift -8,-8,+16,+16 --force-gui")
	!#PrintScreen::MakeScreen("-r active-monitor")
	#PrintScreen::MakeScreen("-r all-monitors")

	+^!U::UploadFiles() ;upload files
}

;explorer - activate/run
#E::FRun("ahk_class CabinetWClass", "Z:\", "Z:\")

;foobar - activate/run
Launch_Media::FRun("ahk_class {97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}", "C:\program files (x86)\foobar2000\foobar2000.exe", "C:\Program Files (x86)\foobar2000")

;wtw - activate/run
+^!M::
	if (!WinExist("^WTW"))
	{
		Run, "C:\Program Files\WTW\WTW.exe" -x, "C:\Program Files\WTW"
	}
	else
	{
		WinShow
		WinActivate
	}
	return

;cdisplayex - activate/run
^!/::FRun("CDisplayEx", "C:\Program Files (x86)\CDisplayEx\cdisplayex.exe", "Z:\")

;web browser - activate/run
^!;::
	if WinExist("Mozilla Firefox")
	{
		WinShow
		WinActivate
		Send, !d
	}
	else if WinExist("ahk_class Chrome_WidgetWin_1")
	{
		WinActivate
		ControlFocus, Chrome_OmniboxView1
		SendInput, {Home}+{End}
	}
	else
	{
		BrowserPath = C:\Program Files (x86)\Mozilla Firefox\firefox.exe
		IfNotExist %BrowserPath%
		{
			BrowserPath = "C:\Users\vleeshue\AppData\Local\Google\Chrome\Application\chrome.exe"
		}
		IfExist %BrowserPath%
		{
			Run, %BrowserPath%
		}
	}
	return

;windows powershell / cmd functionalities
#IfWinActive ahk_class ConsoleWindowClass
^V::SendInput {Raw}%clipboard% ;paste on ctrl+v
^!PgUp::Send ! el{PgUp}{Enter} ;scroll on ctrl+page up
^!PgDn::Send ! el{PgDn}{Enter} ;scroll on ctrl+page down
#IfWinActive

;acdsee functionalities
#IfWinActive ahk_class ACDBrowser
	WheelDown::Send, ^{Down}^{Space}
	WheelUp::Send, ^{Up}^{Space}
#IfWinActive
#IfWinActive ACDSee
	WheelDown::
		if (A_TickCount - OldTicks >= 80)
		{
			Send, {WheelDown}
			OldTicks := A_TickCount
		}
		return
	]:: ;send to document folder
	RButton & ~LButton::
		FormatTime, Folder,, 'Z:\'
		Send {LAlt down}c
		Send {LAlt up}
		SendInput %Folder%
		Send {Return}
		return
	[:: ;send to upload folder
	~LButton & RButton::
		Send {LAlt down}c
		Send {LAlt up}
		SendInput Z:\hub\pinkyard\queued
		Send {Return}
		Sleep 100
		return
	XButton1::
		WinGet, Transparency, Transparent, A
		if ! Transparency
			WinSet, Transparent, 255, A
		else if Transparency = 255
			WinSet, Transparent, 0, A
		return
	XButton2:: ;start slideshow
		Send {Pause}
		return
#IfWinActive

;other functionalities

;autohotkey - reload this script
!F12::Reload

;maximize active window
!M::
	ActiveHwnd := WinExist("A")
	PostMessage 0x112, 0xf030 ;WM_SYSCOMMAND, SC_MAXIMIZE
	return

;restore active window
!R::
	ActiveHwnd := WinExist("A")
	PostMessage 0x112, 0xf120 ;WM_SYSCOMMAND, SC_RESTORE
	return

;minimize active window
!W::
	if WinActive("WTW$")
	{
		WinHide
	}
	else
	{
		ActiveHwnd := WinExist("A")
		PostMessage 0x112, 0xF020 ;WM_SYSCOMMAND, SC_MINIMIZE
	}
	return

;always on top
!A::WinSet, AlwaysOnTop, Toggle, A

;transparency
#1::WinSet, Transparent, 0, A
#2::WinSet, Transparent, 64, A
#3::WinSet, Transparent, 255, A
#WheelUp::
	WinGet, Transparency, Transparent, A
	if ! Transparency
		Transparency = 255
	Transparency := Transparency + 16
	if Transparency <= 10
	{
		WinSet, Transparent, 10, A
	}
	else if Transparency >= 255
	{
		WinSet, Transparent, 255, A
		WinSet, Transparent, OFF, A
	}
	else
	{
		WinSet, Transparent, %Transparency%, A
	}
	return
#WheelDown::
	WinGet, Transparency, Transparent, A
	if ! Transparency
		Transparency = 255
	Transparency := Transparency - 16
	if Transparency <= 10
	{
		WinSet, Transparent, 10, A
	}
	else if Transparency >= 255
	{
		WinSet, Transparent, 255, A
		WinSet, Transparent, OFF, A
	}
	else
	{
		WinSet, Transparent, %Transparency%, A
	}
	return

;explorer
#IfWinActive ahk_class CabinetWClass
	;new folder
	^n::
		Send {AppsKey}wf
		return
#IfWinActive

;putty
#IfWinActive ahk_class PuTTY
	;putty ctrl+alt+pageup/pagedown
	^!PgUp::SendInput {Escape}:tabprev{Return}
	^!PgDn::SendInput {Escape}:tabnext{Return}
	;putty pasting
	+Numpad0::
	+NumpadIns::
	+Insert::
		WinGetPos, winX, winY, winW, winH
		tempX := winX+(winW//2)
		tempY := winY+(winH//2)
		MouseClick, Right, %tempX%, %tempY%
		return
#IfWinActive

;adobe products
#IfWinActive ahk_group adobe
	~LAlt::return
	LAlt UP::Send {Escape}
#IfWinActive

return
;replace stuff in clipboard when it changes
OnClipboardChange:
{
	if (A_EventInfo == 1) and (SubStr(clipboard, 1, 7) == "http://")
	{
		StringReplace, clipboard, clipboard, `%5b, [, All
		StringReplace, clipboard, clipboard, `%5d, ], All
	}
	return
}

;Control key Ctrl- ^
;Alt key Alt- !
;Shift key Shift- +
;Windows key Win- #

#Persistent
;#NoTrayIcon
#SingleInstance Force
DetectHiddenWindows, On
DetectHiddenText, On
SetTitleMatchMode, RegEx ;match titles and classes using regular expressions
SetTitleMatchMode Slow ;match titles and classes using regular expressions
CoordMode, Mouse, Screen
CoordMode, ToolTip, Screen
OldTicks = 0

GroupAdd, adobe, ahk_class OWL.DocumentWindow
GroupAdd, adobe, ahk_class illustrator
GroupAdd, adobe, ahk_class PSViewC
GroupAdd, adobe, ahk_class Photoshop
GroupAdd, adobe, Photoshop

;fun functions
;activate/run
FRun(window, path, folder)
{
	if (!window or !WinExist(window))
	{
		Run, %path%, %folder%
	}
	else
	{
		WinShow
		WinActivate
	}
	return
}

;create random file name
RandomFileName()
{
	FormatTime, fileName,, yyyyMMdd_HHmmss_
	characters := "abcdefghijklmnopqrstuvwxyz"
	Loop 3
	{
		Random, rand, 1, strlen(characters)
		fileName := fileName . substr(characters, rand, 1)
	}
	return fileName
}

;check for cygwin path
CygPath = C:\Program Files (x86)\cygwin
IfNotExist %CygPath%
{
	CygPath = C:\Cygwin
}

IfExist %CygPath%
{
	;cygwin related functions go in here...

	UploadFiles()
	{
		ToolTip, Uploading files..., -1920+50, 50
		RunWait, %CygPath%\bin\mintty.exe "/bin/bash -l -c send_to_pinkyard.py|clip", %CygPath%
		ToolTip
		return
	}

	MakeScreen(arguments)
	{
		baseFileName := "Z:\hub\pinkyard\queued\" . RandomFileName()
		PNGFileName := "Z:\tmp.png"
		JPGFileName := "Z:\tmp.jpg"
		RunWait, % "C:\program files (x86)\scrsh.exe --path " . PNGFileName . " " . arguments, "Z:\", Hide
		if %ErrorLevel% = 0
		{
			RunWait, % "Z:\src\optipng\support\optipng.exe -o1 " . PNGFileName, "Z:\", Hide
			RunWait, % CygPath . "bin\convert.exe " . PNGFileName . " -quality 80 " . JPGFileName, "Z:\", Hide
			FileGetSize, JPGFileSize, % JPGFileName
			FileGetSize, PNGFileSize, % PNGFileName
			if % PNGFileSize > JPGFileSize
			{
				path1 := JPGFileName
				path2 := baseFileName . ".jpg"
			}
			else
			{
				path1 := PNGFileName
				path2 := baseFileName . ".png"
			}
			FileCopy, % path1, % path2
			FileDelete, % JPGFileName
			FileDelete, % PNGFileName
			SoundPlay, Z:\clutter\sounds\ping.wav
		}
		return path
	}

	;cygwin - activate/run
	+^![::
		Run, %CygPath%\bin\mintty.exe --size "120`,40" --position "1050`,45" --class "mintty_thetty" --exec /bin/bash --login -i, %CygPath%
		return
	 ^![::
		if (!WinExist("ahk_class mintty_thetty"))
		{
			Run, %CygPath%\bin\mintty.exe --size "120`,40" --position "1050`,45" --class "mintty_thetty" --exec /bin/bash --login -i -c 'while /bin/true; do /bin/bash; cygstart "%A_AhkPath%" "Z:\src\hide.ahk"; clear; done', %CygPath%
			WinWait ahk_class mintty_thetty
		}
		else
		{
			WinShow
			WinActivate
		}
		WinSet, Style, -0x004b0000
		return

	;ssh to burza - activate/run
	+^!]::Run, %CygPath%\bin\mintty.exe --size "200`,70" --position "100`,45" --class mintty_ssh --exec /bin/ssh -p 65000 rr-@sakuya.pl, %CygPath%/bin
	^!]::
		if (!WinExist("ahk_class mintty_ssh"))
		{
			Run, %CygPath%\bin\mintty.exe --size "200`,70" --position "100`,45" --class mintty_ssh --exec /bin/ssh -p 65000 rr-@sakuya.pl, %CygPath%/bin
			WinWait ahk_class mintty_ssh
		}
		else
		{
			WinShow
			WinActivate
		}
		return

	;text editor - activate/run + fix screen position
	+^!N::
		IfWinExist, ahk_class Vim
		{
			WinShow
			WinActivate
		}
		else
		{
			Run, %CygPath%\bin\mintty.exe --size "240`,90" --position "100`,45" --class "Vim" --exec "/bin/vim" --cmd 'cd /cygdrive/z', %CygPath%/bin
			WinWait, ahk_class Vim
		}
		WinMove, , , 100, 100, 1600, 900
		return

	+PrintScreen::MakeScreen("-g")
	!PrintScreen::MakeScreen("-r active-window --shift -8,-8,+16,+16 --force-gui")
	!#PrintScreen::MakeScreen("-r active-monitor")
	#PrintScreen::MakeScreen("-r all-monitors")

	+^!U::UploadFiles() ;upload files
}

;explorer - activate/run
#E::FRun("ahk_class CabinetWClass", "Z:\", "Z:\")

;foobar - activate/run
Launch_Media::FRun("ahk_class {97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}", "C:\program files (x86)\foobar2000\foobar2000.exe", "C:\Program Files (x86)\foobar2000")

;wtw - activate/run
+^!M::
	if (!WinExist("^WTW"))
	{
		Run, "C:\Program Files\WTW\WTW.exe" -x, "C:\Program Files\WTW"
	}
	else
	{
		WinShow
		WinActivate
	}
	return

;cdisplayex - activate/run
^!/::FRun("CDisplayEx", "C:\Program Files (x86)\CDisplayEx\cdisplayex.exe", "Z:\")

;web browser - activate/run
^!;::
	IfWinExist, Mozilla Firefox
	{
		WinShow
		WinActivate
		Send, !d
	}
	else
	{
		Run, "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
	}
	return

;windows powershell / cmd functionalities
#IfWinActive ahk_class ConsoleWindowClass
^V::SendInput {Raw}%clipboard% ;paste on ctrl+v
^!PgUp::Send ! el{PgUp}{Enter} ;scroll on ctrl+page up
^!PgDn::Send ! el{PgDn}{Enter} ;scroll on ctrl+page down
#IfWinActive

;acdsee functionalities
#IfWinActive ahk_class ACDBrowser
	WheelDown::Send, ^{Down}^{Space}
	WheelUp::Send, ^{Up}^{Space}
#IfWinActive
#IfWinActive ACDSee
	WheelDown::
		if (A_TickCount - OldTicks >= 80)
		{
			Send, {WheelDown}
			OldTicks := A_TickCount
		}
		return
	]:: ;send to document folder
	RButton & ~LButton::
		FormatTime, Folder,, 'Z:\'
		Send {LAlt down}c
		Send {LAlt up}
		SendInput %Folder%
		Send {Return}
		return
	[:: ;send to upload folder
	~LButton & RButton::
		Send {LAlt down}c
		Send {LAlt up}
		SendInput Z:\hub\pinkyard\queued
		Send {Return}
		Sleep 100
		return
	XButton1::
		WinGet, Transparency, Transparent, A
		if ! Transparency
			WinSet, Transparent, 255, A
		else if Transparency = 255
			WinSet, Transparent, 0, A
		return
	XButton2:: ;start slideshow
		Send {Pause}
		return
#IfWinActive

;other functionalities

;autohotkey - reload this script
!F12::Reload

;maximize active window
!M::
	ActiveHwnd := WinExist("A")
	PostMessage 0x112, 0xf030 ;WM_SYSCOMMAND, SC_MAXIMIZE
	return

;restore active window
!R::
	ActiveHwnd := WinExist("A")
	PostMessage 0x112, 0xf120 ;WM_SYSCOMMAND, SC_RESTORE
	return

;minimize active window
!W::
	if WinActive("WTW$")
	{
		WinHide
	}
	else
	{
		ActiveHwnd := WinExist("A")
		PostMessage 0x112, 0xF020 ;WM_SYSCOMMAND, SC_MINIMIZE
	}
	return

;always on top
!A::WinSet, AlwaysOnTop, Toggle, A

;transparency
#1::WinSet, Transparent, 0, A
#2::WinSet, Transparent, 64, A
#3::WinSet, Transparent, 255, A
#WheelUp::
	WinGet, Transparency, Transparent, A
	if ! Transparency
		Transparency = 255
	Transparency := Transparency + 16
	if Transparency <= 10
	{
		WinSet, Transparent, 10, A
	}
	else if Transparency >= 255
	{
		WinSet, Transparent, 255, A
		WinSet, Transparent, OFF, A
	}
	else
	{
		WinSet, Transparent, %Transparency%, A
	}
	return
#WheelDown::
	WinGet, Transparency, Transparent, A
	if ! Transparency
		Transparency = 255
	Transparency := Transparency - 16
	if Transparency <= 10
	{
		WinSet, Transparent, 10, A
	}
	else if Transparency >= 255
	{
		WinSet, Transparent, 255, A
		WinSet, Transparent, OFF, A
	}
	else
	{
		WinSet, Transparent, %Transparency%, A
	}
	return

;explorer
#IfWinActive ahk_class CabinetWClass
	;new folder
	^n::
		Send {AppsKey}wf
		return
#IfWinActive

;putty
#IfWinActive ahk_class PuTTY
	;putty ctrl+alt+pageup/pagedown
	^!PgUp::SendInput {Escape}:tabprev{Return}
	^!PgDn::SendInput {Escape}:tabnext{Return}
	;putty pasting
	+Numpad0::
	+NumpadIns::
	+Insert::
		WinGetPos, winX, winY, winW, winH
		tempX := winX+(winW//2)
		tempY := winY+(winH//2)
		MouseClick, Right, %tempX%, %tempY%
		return
#IfWinActive

;adobe products
#IfWinActive ahk_group adobe
	~LAlt::return
	LAlt UP::Send {Escape}
#IfWinActive

return
;replace stuff in clipboard when it changes
OnClipboardChange:
{
	if (A_EventInfo == 1) and (SubStr(clipboard, 1, 7) == "http://")
	{
		StringReplace, clipboard, clipboard, `%5b, [, All
		StringReplace, clipboard, clipboard, `%5d, ], All
	}
	return
}


TCMatch.ahk: free dll every 1000 calls

TCMatch.ahk: free dll every 1000 calls

global g_TCMatchDllPath
global g_TCMatchModule

TCMatchOn(dllPath = "")
{
    if (g_TCMatchModule != "")
    {
        return g_TCMatchModule
    }

    if (dllPath == "" && g_TCMatchDllPath == "")
    {
        return 0
    }
    else if (dllPath != "")
    {
        if (!FileExist(dllPath))
        {
            return 0
        }
        else
        {
            g_TCMatchDllPath := dllPath
        }
    }

    g_TCMatchModule := DllCall("LoadLibrary", "Str", g_TCMatchDllPath, "Ptr")
    return g_TCMatchModule
}

TCMatchOff()
{
    DllCall("FreeLibrary", "Ptr", g_TCMatchModule)
    g_TCMatchModule := ""
}

TCMatch(aHaystack, aNeedle)
{
    ; 这个函数有内存泄漏...
    static matchTimes := 0
    matchTimes++
    if (matchTimes > 1000)
    {
        TCMatchOff()
        TCMatchOn()
        matchTimes := 0
    }

    return DllCall("TCMatch\MatchFileW", "WStr", aNeedle, "WStr", aHaystack)
}

TCMatchOn(aDllPath, aOff:=False)
{
    Static hModule := 0
    If !hModule && FileExist(aDllPath)
        hModule := DllCall("LoadLibrary", "Str", aDllPath, "Ptr")
    If aOff
        hModule := 0
    Return hModule
}

TCMatchOff()
{
    DllCall("FreeLibrary", "Ptr", hModule)
}

TCMatch(aString, aMatch)
{
    Return DllCall("TCMatch\MatchFileW",  "WStr", aMatch, "WStr", aString)
}


Code style

Code style

TotalCommander_Dialog:
;本插件尝试将TotalCommander作为文件打开对话框
; * 默认添加快捷键<lwin>o , 在文件对话框或任意文字编辑界面按下快捷键跳转至TC--TC中选定文件后再次按下快捷键可实现文件打开功能
; * 尝试在打开文件对话框时，自动跳转到TC进行文件选择：#32770，焦点Edit1且内无文字, 对话框内不含密码、password等内容
; * 增加select模式，按下回车或Ctrl+回车均可直接选定文件;未多选情况下在文件夹上按下回车时，进入该文件夹而非选定

vim.comment("<OpenTCDialog>", "激活TC选择文件, 需再次按下快捷键触发对话框打开事件")

;初始化设置：全局快捷键跳转到TC
IniWriteIfNullValue(ConfigPath, "Global", "*<lwin>o", "<OpenTCDialog>")

;初始化设置：自动跳转到TC作为文件选择对话框
IniWriteIfNull(ConfigPath, "TotalCommander_Config", "AsOpenFileDialog", "0")

;初始化设置：还有下面文字的窗口将排除TC作为文件选择对话框--由于不支持中文，无法初始化"密码"，在后面代码中添加
IniWriteIfNull(ConfigPath, "TotalCommander_Config", "OpenFileDialogExclude", "password, pwd")

;读取配置参数，禁用时直接跳过
IniRead, AsOpenFileDialog, %ConfigPath%, TotalCommander_Config, AsOpenFileDialog, 1
if AsOpenFileDialog <> 1
    return

;读取排除窗体文字
;IniRead, OpenFileDialogExclude, %ConfigPath%, TotalCommander_Config, OpenFileDialogExclude, "密码, password"
Loop, read, %ConfigPath%
{
    ifInString, A_LoopReadLine, OpenFileDialogExclude
    {
        OpenFileDialogExclude := SubStr(A_LoopReadLine, InStr(A_LoopReadLine, "=")+1)
        IfNotInString, OpenFileDialogExclude, 密码
            OpenFileDialogExclude .= ", 密码"
        break
    }
}

;未发现TC路径时自动禁用该功能
if StrLen(TCPath) = 0
    return

;用于记录文件打开对话框所属窗体
global CallerId := 0

;等待OpenFileDialog出现
SetTimer, <CheckFileDialog>, 1000

return

;===============================================

;仅在执行文件选定时，开启select模式
;拷贝normal全部快捷键，并增加回车确认功能
<Select_Mode_TC>:
    vim.mode("select", "TTOTAL_CMD")

    if Select_Copyed = 1
        return

    Select_Copyed := 1
    vim.CopyMode("TTOTAL_CMD", "normal", "select")
    ;怀疑这里会导致tc里边回车失效，先去掉
    ;vim.map("<enter>", "<TC_PreSelected>", "TTOTAL_CMD")
    vim.map("<ctrl><enter>", "<TC_Selected>", "TTOTAL_CMD")
    vim.map("<esc>", "<Return_To_Caller>", "TTOTAL_CMD")
    return

;返回调用者
<Return_To_Caller>:
    gosub, <Normal_Mode_TC>
    ;未发现可激活的调用窗体时，最小化TC
    if CallerId = 0
    {
        Winminimize, AHK_CLASS TTOTAL_CMD
        sleep, 500
        CallerId := WinExist("A")
        if CallerId = 0
            return
    }

    WinActivate, ahk_id %CallerId%
    return

;发现标准打开文件对话框，未记录，焦点控件为Edit1=>记录，并激活TC
<CheckFileDialog>:
{
    WinGetClass, class, A
    if class <> #32770
        return

    ControlGetFocus, ct, ahk_class #32770
    if ct <> Edit1
        return

    ;以此排除“另存为”，或其它已经包含文字的对话框
    ControlGetText, str, Edit1, ahk_class #32770
    if StrLen(str) > 0
        return

    ;排除用户自定义窗体
    WinGetText, str, ahk_class #32770
    WinGetTitle, title, ahk_class #32770
    if StrLen(title)=0
        return
    str .= title
    Loop, parse, OpenFileDialogExclude, `, , %A_Space%%A_Tab%
    {
        If StrLen(A_LoopField) = 0
            continue
        IfInString, str, %A_LoopField%
            return
    }

    id := WinExist("A")
    if id = 0
        return
    if id = %CallerId%
        return

    CallerId := id
    gosub, <FocusTC>
    gosub, <Select_Mode_TC>
    return
}

; * 非TC窗口按下后激活TC窗口
; * TC窗口按下后复制当前选中文件返回原窗口后粘贴
<OpenTCDialog>:
{
    WinGetClass, class, A

    ;在Total Commander按下快捷键时，激活调用窗体并执行粘贴操作
    if class = TTOTAL_CMD
    {
        gosub, <TC_Selected>
        return
    }

    if class <> TTOTAL_CMD
    {
        CallerId := WinExist("A")
        if CallerId = 0
            return

        gosub, <FocusTC>
        gosub, <Select_Mode_TC>
        return
    }

    return
}

<TC_PreSelected>:
    SendPos(2021)
    sleep, 100 ; 此处用clipwait貌似会出错？

    ;未多选
    IfNotInString, clipboard, `n
    {
        ;当前复制项为文件夹时
        StringRight, str, clipboard, 1
        IfInString, str, \
            {
                SendPos(2003)
                return
            }
    }

    ;return 注意，此处无需return

<TC_Selected>:
{
    vim.mode("normal", "TTOTAL_CMD")
    SendPos(2021)
    sleep, 100

    ;仅在多选时两侧增加双引号
    IfInString, clipboard, `n
    {
        files := ""
        Loop, parse, clipboard, `n, `r
            files .= """" A_LoopField  """ "
        clipboard := files
    }

    ;未发现可激活的调用窗体时，最小化TC
    if CallerId = 0
    {
        Winminimize, AHK_CLASS TTOTAL_CMD
        sleep, 500
        CallerId := WinExist("A")
        if CallerId = 0
            return
    }

    WinActivate, ahk_id %CallerId%
    WinWait, ahk_id %CallerId%
    send, ^v
    send, {Enter}
    return
}

TotalCommander_Dialog:
;本插件尝试将TotalCommander作为文件打开对话框
; * 默认添加快捷键<lwin>o ,在文件对话框或任意文字编辑界面按下快捷键跳转至TC--TC中选定文件后再次按下快捷键可实现文件打开功能
; * 尝试在打开文件对话框时，自动跳转到TC进行文件选择：#32770，焦点Edit1且内无文字,对话框内不含密码、password等内容
; * 增加select模式，按下回车或Ctrl+回车均可直接选定文件;未多选情况下在文件夹上按下回车时，进入该文件夹而非选定

vim.comment("<OpenTCDialog>","激活TC选择文件,需再次按下快捷键触发对话框打开事件")

;初始化设置：全局快捷键跳转到TC
IniWriteIfNullValue(ConfigPath,"Global","*<lwin>o","<OpenTCDialog>")

;初始化设置：自动跳转到TC作为文件选择对话框
IniWriteIfNull(ConfigPath,"TotalCommander_Config","AsOpenFileDialog","0")

;初始化设置：还有下面文字的窗口将排除TC作为文件选择对话框--由于不支持中文，无法初始化"密码"，在后面代码中添加
IniWriteIfNull(ConfigPath,"TotalCommander_Config","OpenFileDialogExclude","password,pwd")

;读取配置参数，禁用时直接跳过
IniRead,AsOpenFileDialog,%ConfigPath%,TotalCommander_Config,AsOpenFileDialog,1
if AsOpenFileDialog <> 1
	return

;读取排除窗体文字
;IniRead,OpenFileDialogExclude,%ConfigPath%,TotalCommander_Config,OpenFileDialogExclude,"密码,password"
Loop, read, %ConfigPath%
{
	ifInString, A_LoopReadLine, OpenFileDialogExclude
	{
		OpenFileDialogExclude := SubStr(A_LoopReadLine,InStr(A_LoopReadLine,"=")+1)
		IfNotInString, OpenFileDialogExclude, 密码
			OpenFileDialogExclude .= ",密码"
		break
	}
}

;未发现TC路径时自动禁用该功能
if StrLen(TCPath) = 0
	return

;用于记录文件打开对话框所属窗体
global CallerId := 0

;等待OpenFileDialog出现
SetTimer, <CheckFileDialog>, 1000

return

;===============================================

;仅在执行文件选定时，开启select模式
;拷贝normal全部快捷键，并增加回车确认功能
<Select_Mode_TC>:
	vim.mode("select","TTOTAL_CMD")

	if Select_Copyed = 1
		return

	Select_Copyed := 1
	vim.CopyMode("TTOTAL_CMD","normal","select")
	;怀疑这里会导致tc里边回车失效，先去掉
	;vim.map("<enter>","<TC_PreSelected>","TTOTAL_CMD")
	vim.map("<ctrl><enter>","<TC_Selected>","TTOTAL_CMD")
	vim.map("<esc>","<Return_To_Caller>","TTOTAL_CMD")
	return

;返回调用者
<Return_To_Caller>:
	gosub,<Normal_Mode_TC>
	;未发现可激活的调用窗体时，最小化TC
	if CallerId = 0
	{
		Winminimize,AHK_CLASS TTOTAL_CMD
		sleep,500
		CallerId := WinExist("A")
		if CallerId = 0
			return
	}

	WinActivate,ahk_id %CallerId%
	return

;发现标准打开文件对话框，未记录，焦点控件为Edit1=>记录，并激活TC
<CheckFileDialog>:
{
	WinGetClass, class, A
	if class <> #32770
		return

	ControlGetFocus,ct, ahk_class #32770
	if ct <> Edit1
		return

	;以此排除“另存为”，或其它已经包含文字的对话框
	ControlGetText,str,Edit1,ahk_class #32770
	if StrLen(str) > 0
		return

	;排除用户自定义窗体
	WinGetText,str,ahk_class #32770
	WinGetTitle,title,ahk_class #32770
	if StrLen(title)=0
		return
	str .= title
	Loop, parse, OpenFileDialogExclude, `,, %A_Space%%A_Tab%
	{
		If StrLen(A_LoopField) = 0
			continue
		IfInString,str,%A_LoopField%
			return
	}

	id := WinExist("A")
	if id = 0
		return
	if id = %CallerId%
		return

	CallerId := id
	gosub,<FocusTC>
	gosub,<Select_Mode_TC>
	return
}

; * 非TC窗口按下后激活TC窗口
; * TC窗口按下后复制当前选中文件返回原窗口后粘贴
<OpenTCDialog>:
{
	WinGetClass, class, A

	;在Total Commander按下快捷键时，激活调用窗体并执行粘贴操作
	if class = TTOTAL_CMD
	{
		gosub,<TC_Selected>
		return
	}

	if class <> TTOTAL_CMD
	{
		CallerId := WinExist("A")
		if CallerId = 0
			return

		gosub,<FocusTC>
		gosub,<Select_Mode_TC>
		return
	}

	return
}

<TC_PreSelected>:
	SendPos(2021)
	sleep,100 ; 此处用clipwait貌似会出错？

	;未多选
	IfNotInString,clipboard,`n
	{
		;当前复制项为文件夹时
		StringRight,str,clipboard,1
		IfInString,str,\
			{
				SendPos(2003)
				return
			}
	}

	;return 注意，此处无需return

<TC_Selected>:
{
	vim.mode("normal","TTOTAL_CMD")
	SendPos(2021)
	sleep,100

	;仅在多选时两侧增加双引号
	IfInString,clipboard,`n
	{
		files := ""
		Loop, parse, clipboard, `n, `r
			files .= """" A_LoopField  """ "
		clipboard := files
	}

	;未发现可激活的调用窗体时，最小化TC
	if CallerId = 0
	{
		Winminimize,AHK_CLASS TTOTAL_CMD
		sleep,500
		CallerId := WinExist("A")
		if CallerId = 0
			return
	}

	WinActivate,ahk_id %CallerId%
	WinWait,ahk_id %CallerId%
	send, ^v
	send, {Enter}
	return
}


add test case for nested returns (failed previously, works now)

; truth values:
; ==========================================================
Assert(""    ? false : true, "Empty string is true")
Assert(0     ? false : true, "0 is true")
Assert(0.0   ? false : true, "0.0 is true")
Assert(false ? false : true, "false is true")
Assert(null  ? false : true, "null is true")
Assert(a     ? false : true, "Uninitialized var is not false")

Assert("a", "Non-empty string is false")
Assert(1, "1 is false")
Assert(true, "true is false")
; ==========================================================

Assert(0x2 "" == "2", "Hex-Int to string conversion failed")

five() {
	return(5)
}

Assert(five() "" == "5", "Return value failed")
Assert(5 ** 2 == 25.0, "Power failed")

cond() {
	if (true) {
		return(true)
	}
}
Assert(cond(), "function return in if failed")

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 != null, "Object literal failed")
Assert(obj.a "" == 4 "", "Object literal incorrect")

Assert(obj.b == null, "Retrieval of undefined object member failed")

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

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

; just testing for errors on empty literals
obj := {}
arr := []

arr := [2, 4, 9]
Assert(arr != null, "Array literal failed")

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

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

; just a comment - divider

if (false) {
	throw "False is true"
} else {
	Assert(g, "Assertion in else-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 "")
	}
}

; truth values:
; ==========================================================
Assert(""    ? false : true, "Empty string is true")
Assert(0     ? false : true, "0 is true")
Assert(0.0   ? false : true, "0.0 is true")
Assert(false ? false : true, "false is true")
Assert(null  ? false : true, "null is true")
Assert(a     ? false : true, "Uninitialized var is not false")

Assert("a", "Non-empty string is false")
Assert(1, "1 is false")
Assert(true, "true is false")
; ==========================================================

Assert(0x2 "" == "2", "Hex-Int to string conversion failed")

five() {
	return(5)
}
Assert(five() "" == "5", "Return value failed")
Assert(5 ** 2 == 25.0, "Power failed")

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 != null, "Object literal failed")
Assert(obj.a "" == 4 "", "Object literal incorrect")

Assert(obj.b == null, "Retrieval of undefined object member failed")

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

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

; just testing for errors on empty literals
obj := {}
arr := []

arr := [2, 4, 9]
Assert(arr != null, "Array literal failed")

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

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

; just a comment - divider

if (false) {
	throw "False is true"
} else {
	Assert(g, "Assertion in else-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 "")
	}
}


no message

no message

#Include init_global.init.inc.ahk

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
lll(ln, scriptName, text="")
{
   global GLOBAL_lllog_only_this_scriptName
   	scriptName := trim(scriptName)
   	GLOBAL_lllog_only_this_scriptName := trim(GLOBAL_lllog_only_this_scriptName)
   	if(StrLen(GLOBAL_lllog_only_this_scriptName)>0) {
      do_createLog_notAppendLog:=true
      		if(scriptName != GLOBAL_lllog_only_this_scriptName)
      			return false
   	}

   ;~ logFileName=log\%A_ScriptName%.log.txt
   	logFileName=log\%scriptName%.log.txt

   					; M = Modification time (this is the default if the parameter is omitted)
   		FileGetTime, cFileMTime, %logFileName%, M

   		diff_cFileMTime_Now_hour:=A_Now
   		EnvSub, diff_cFileMTime_Now_hour, %cFileMTime%, hours

   		diff_cFileMTime_Now_min:= Round(diff_cFileMTime_Now_hour / 60)

   		diff_cFileMTime_Now_day:=A_Now
   		EnvSub, diff_cFileMTime_Now_day, %cFileMTime%, days

   		diff_cFileMTime_Now_year:= Round(diff_cFileMTime_Now_day / 365)
   		;~ EnvSub, diff_cFileMTime_Now_year, %cFileMTime%, year

   		if(diff_cFileMTime_Now_hour > 1)
   			FileDelete,%logFileName%

   		;~ if(diff_cFileMTime_Now_day > 7)
   			;~ FileDelete,%logFileName%

   	if(StrLen(scriptName) < 5 ) ; || "functions_global.inc.ahk" != A_ScriptName ... for that we need a PreCompiler !!!
   	{
      lll(A_LineNumber, "functions_global.inc.ahk")

      		;~ t := ""
      		;~ t .= "#Include init_global.init.inc.ahk" . "`n"
      		;~ t .= "#Include functions_global.inc.ahk" . "`n"
      		;~ Clipboard := t

      		Clipboard="%A_ScriptName%"
      		MsgBox, functions_global.inc.ahk `n ln=%ln% `n  scriptName = %scriptName% `n parameter FILE must not be empty `n `n you find this now inside your clipboard : %Clipboard% `n `n move to line %ln% and fix the bug. `n `n or let run the SL5_AHK_preparser.ahk
      		return -1
   	}
   	;~ tipp: use notepadd++ , diverses> ohne rckfraen aktuallisieren
   	;~ tipp: use notepadd++ , diverses> nach aktuallisierung zum ende springen
   	msg:=""
   	;~ msg.= ";<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<`n"

   	if(strlen(text)>0)
   		msgtext := """" . text . """"
   	else
   		msgtext := text
   	msg.= scriptName . ">" . ln  . msgtext  . "`n"
   	;~ msg.= ";>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`n`n"

   	global lll
   	if(StrLen(lll)>0)
   		lll .= msg
   	else
   		lll := msg
   	Suspend,on
   	if(!FileExist("log"))
   	{
      FileCreateDir,log
      		if(true != InStr(FileExist("log"), "D") )
      		{
         ;~ would be true only if the file exists and is a directory
         		MsgBox,15-05-15_17-00 ops Who could we store logfiles ?
      		}
   	}

   ;~if(StrLen(GLOBAL_lllog_only_this_scriptName)>0
   	if(do_createLog_notAppendLog)
   	{
      FileDelete,%logFileName%
      		while(FileExist(logFileName))
      			Sleep,100
      		gLOBAL_lllog = GLOBAL_lllog_only_this_scriptName
      		strLen_GLOBAL_lllog := StrLen(gLOBAL_lllog)
      		subStr_lll__strLen := SubStr(lll,1,strLen_GLOBAL_lllog)
      		if(subStr_lll__strLen != gLOBAL_lllog)
      		{
         ;~ MsgBox,%subStr_lll__strLen% %GLOBAL_lllog_only_this_scriptName% := GLOBAL_lllog_only_this_scriptName `n
         		lll := "GLOBAL_lllog_only_this_scriptName = " . GLOBAL_lllog_only_this_scriptName . "`n" . lll
      		}
   	}

   	FileAppend, % lll, %logFileName%
   	;~ ToolTip,%logFileName% := logFileName `n
   	;~ MsgBox,%lll%
   	Suspend,off
   	return
}
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

runCopyQ_Ctrl_Shift_v(){
   MsgBox,,ShortCut CopyQ,Ctrl Shift V `n  dont work actually. `n please use Ctrl Shift 1. `n Sorry about that. thanks. 15.06.2015 , 3
   ;~ MsgBox [, Options, Title, Text, Timeout]
   	return
   	; <LEER> - CopyQ ahk_cl!A_ScriptDir!A_ScriptDir!A_ScriptDiraA_ScriptDirA_ScriptDirss QWidget... (3 Zeilen) - CopyQ ahk_class1`11`n`n`n
   		SetTitleMatchMode,2
   		DetectHiddenWindows,on
   	IfWinNotExist,CopyQ ahk_class QWidget
   	{
      MsgBox,it not exist
      		run,%A_ScriptDir%\SL5_AHK_Refactor_engine\copyq-windows\copyq.exe
      		Sleep,2000
   	}
   ; ^+v!; ^+v!; ^+v!; ^+v!; ^+v!; ^+v!; ^+v!; ^+vCopyQ ahk_class QWidget
   ; ^+v7!; ^+v!; ^+v!; ^+v!; ^+v!; ^+v\SL5_AHK_Refactor_engine\SL5_AHK_Refactor_engine\SL5_AHK_Refactor_engine
   Last_A_This:=A_ThisFunc . A_ThisLabel . " p"
   lll(A_LineNumber, "keysEveryWhere.ahk",Last_A_This)

   ToolTip1sec(A_LineNumber . " " . A_ScriptName . " " . Last_A_This)
   ;
   SetKeyDelay,80,80
		send,{Blind}
		Sleep,500
		 ;~ if(GetKeyState("ctrl", "P") )
		;~ {
			;~ ToolTip,:( oops 15-06-14_23-49
			;~ return
		;~ }CopyQ ahk_class QWidgetCopyQ ahk_class QWidget
		SetTitleMatchMode,2
		; {ShiftDown}^1{ShiftUp}
	DetectHiddenWindows,on
	Send,{CtrlDown}{ShiftDown}
	Loop,10
	{
   ;~ ControlSend, , - CopyQ{ShiftDown}^1{ShiftUp},ahk_class QWidget- CopyQ
   		;~ Sen- CopyQd,{S- CopyQhiftDown}^1{ShiftUp} 1runCopyQ_Ctrl_Shift_v1runCopyQ_Ctrl_Shift_v
   		Suspend,on
   		send,{Numpad1}1
   		WinActivate,- CopyQ
   		Sleep,100
   		IfWinActive,- CopyQ
   			break
	}
		Send,{ShiftUp}{CtrlUp}
		Suspend,Off
		;~ MsgBox, :) great CopyQ is active
	; CopyQCopyQ CopyQCopyQCopyQCopyQCopyQ{CtrlDown}{ShiftDown}1{ShiftUp}{CtrlUp}{CtrlDown}{- CopyQShiftDown}1{ShiftUp}{CtrlUp}
	WinSet, AlwaysOnTop,On,- CopyQ ; Toggle the always-on-top status of Calculator.
WinWaitActive, - CopyQ ,,2
if !WinExist("- CopyQ")
MsgBox, please install CopyQ and add a global hotkey STRG+SHIFT+1 (v is not possible there - or?)

WinWaitNotActive, - CopyQ
	; - CopyQ- CopyQ
	; cl- CopyQeanUp
	Clipboard = %Clipboard%

return
}

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
convert123To_NumPad123(t)
{
   StringReplace, t, t, 1 , {numpad1}, All
   StringReplace, t, t, 2 , {numpad2}, All
   StringReplace, t, t, 3 , {numpad3}, All
   StringReplace, t, t, 4 , {numpad4}, All
   StringReplace, t, t, 5 , {numpad5}, All
   StringReplace, t, t, 6 , {numpad6}, All
   StringReplace, t, t, 7 , {numpad7}, All
   StringReplace, t, t, 8 , {numpad8}, All
   StringReplace, t, t, 9 , {numpad9}, All
   StringReplace, t, t, 0 , {numpad0}, All
   return t
}
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
drawButtons(str , fontSize){
   return
   ; maximal button size, recomandet:  drawButtons("1234567980" , 260)

   strLen := StrLen(str) + 1 ; some extra letters becouse some buttons are larger strg or so
   if(strLen<1)
      return false
   bx36 := 170
   by36 := 52
   W36 := 51
   H36 := 52
   R36 := 5
   ;    ;~ WinSet, Region, 142-62 W102 H102 R20-20, Shortcut  ; Same as above but with corners rounded to 40x40.
   bx72:= 142
   by72 := 62
   W72 := 105
   H72 := 102
   R72 := 20

   m := (72 - 36) / (W72-W36)
   W0 :=  72 - m * W72
   WFS1  := Round( (fontSize - W0) / m )
   WFS  := WFS1 *  strLen   + Round(  WFS1 * ( strLen - 1 )  * 0.3 )
   ;~ WFS  := Round( (fontSize - W0) / m) ; * StrLen(str+1)
   ; ; 284-62 W105 H102 R20-20
   ; 284-62 W105 H102 R20-20
   ; 284-62 W315 H102 R20-20

   ; 0-0 W774 H363 R98-98

   m := (72 - 36) / (bx72 - bx36)
   bx0 :=  72 - m * bx72
   ;~ bxFS  := Round( (fontSize - bx0) / m  + ( WFS - WFS1) / 2
   bxFStemp  := Round( (fontSize - bx0) / m )
   bxFS  := Round(bxFStemp  - WFS / 2 )
   bxFS  := -100
   bxFS  := 10
   ; -100-0 W774 H363 R98-98

   ;~ bxFS  := Round( WFS / 2 )

   m := (72 - 36) / (by72 - by36)
   by0 :=  72 - m * by72
   byFS  := Round( (fontSize - by0) / m )
   ;~ byFS := 0

   m := (72 - 36) / (H72-H36)
   H0 :=  72 - m * H72
   HFS  := Round(  (fontSize - H0) / m )
   ;~ HFS = 300

   m := (72 - 36) / (R72-R36)
   R0 :=  72 - m * R72
   RFS  := Round(  (fontSize - R0) / m )
   Progress, ZX0 ZH60 m2  fs%fontSize% zh0 CTFFFFFF CW000000, %str% ,, Shortcut , Keycaps Regular
   SetTitleMatchMode,2
   CoordMode, Pixel , Screen
   CoordMode, Caret , Screen
   WinGetPos, x , y , w , h , SciTE4AutoHotkey

   ; top of scite window
   WinMove, Shortcut, , % x , % y - 70 , % WFS + 50, % HFS + 100

   ; bottom of scite window
   ;~ WinMove, Shortcut, , % x , % (y + w - HFS - byFS - 350) , % WFS + 50, % HFS + 100

   ;~ Progress, fs%fontSize% CTFFFFFF CW000000, %str% ,, Shortcut , Keycaps Regular
   ;~ temp=%bx36%-%by36% W%W36% H%H36% R%R36%-%R36%
   temp= %bxFS%-%byFS% W%WFS% H%HFS% R%RFS%-%RFS%

   ;~ Clipboard = `; %temp%
   ;~ WinMove
   ;~ Sleep,2500
   x:=""
   y:=""
   WinSet, Region, %temp%, Shortcut  ; Same as above but with corners rounded to 40x40.

   SetTimer,ButtonsOffLabel,2000
   return
   ;~ Progress, ZX0 ZH60 m2  fs36 zh0 CTFFFFFF CW000000,L,, Shortcut , Keycaps Regular
   ; 170-52 W51 H52 R5-5
   ;                             170-52 W51 H52 R5-5
   ;                             284-62 W0 H102 R20-20
   ;~ WinSet, Region, 170-52 W51 H52 R5-5, Shortcut  ; Same as above but with corners rounded to 40x40.

   ;~ Progress, ZX0 ZH60 m2  fs72 zh0 CTFFFFFF CW000000,L,, Shortcut , Keycaps Regular
   ;~ WinSet, Region, 142-62 W102 H102 R20-20, Shortcut  ; Same as above but with corners rounded to 40x40.
   ;~ return WinSet, Region, 142-62 W102 H102 R20-20, Shortcut  ; Same as above but with corners rounded to 40x40.

   ;~ Progress, ZW-1 ZX0 ZH600 m2 b fs36 zh0 CTFF0000 CW0000FF,   L=l M=m N=n  O=o P=p Q=q R=r S=s T=t U=u V=v W=w  X=x Y=y Z=z   , , , Keycaps Regular
;~ Progress, ZW-1 ZX0 ZH600 m2 b fs24 zh0 CTFF0000 CW0000FF, \u232B x <    <= x /  = ~ ``    _ - : . `; `, ' " $ & ( ) { }     ? \  ( ] [  @  | `%  * +    # * ~  a b c d e f g h  i j k  Q  < > , , , Keycaps Regular

}

ButtonsOffLabel:
SetTimer,ButtonsOffLabel,Off
;~ SplashImage, Off
Progress, Off

return

; 15-07-07_16-22
lll(A_LineNumber, "functions_global.inc.ahk")
#Include ToolTipSec.inc.ahk ; ein kommentar
lll(A_LineNumber, "functions_global.inc.ahk")
#Include UPDATEDSCRIPT_global.inc.ahk
lll(A_LineNumber, "functions_global.inc.ahk")

#Include init_global.init.inc.ahk

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
lll(ln, scriptName, text="")
{
   global GLOBAL_lllog_only_this_scriptName
   	scriptName := trim(scriptName)
   	GLOBAL_lllog_only_this_scriptName := trim(GLOBAL_lllog_only_this_scriptName)
   	if(StrLen(GLOBAL_lllog_only_this_scriptName)>0) {
      do_createLog_notAppendLog:=true
      		if(scriptName != GLOBAL_lllog_only_this_scriptName)
      			return false
   	}

   ;~ logFileName=log\%A_ScriptName%.log.txt
   	logFileName=log\%scriptName%.log.txt

   					; M = Modification time (this is the default if the parameter is omitted)
   		FileGetTime, cFileMTime, %logFileName%, M

   		diff_cFileMTime_Now_hour:=A_Now
   		EnvSub, diff_cFileMTime_Now_hour, %cFileMTime%, hours

   		diff_cFileMTime_Now_min:= Round(diff_cFileMTime_Now_hour / 60)

   		diff_cFileMTime_Now_day:=A_Now
   		EnvSub, diff_cFileMTime_Now_day, %cFileMTime%, days

   		diff_cFileMTime_Now_year:= Round(diff_cFileMTime_Now_day / 365)
   		;~ EnvSub, diff_cFileMTime_Now_year, %cFileMTime%, year

   		if(diff_cFileMTime_Now_hour > 1)
   			FileDelete,%logFileName%

   		;~ if(diff_cFileMTime_Now_day > 7)
   			;~ FileDelete,%logFileName%

   	if(StrLen(scriptName) < 5 ) ; || "functions_global.inc.ahk" != A_ScriptName ... for that we need a PreCompiler !!!
   	{
      lll(A_LineNumber, "functions_global.inc.ahk")

      		;~ t := ""
      		;~ t .= "#Include init_global.init.inc.ahk" . "`n"
      		;~ t .= "#Include functions_global.inc.ahk" . "`n"
      		;~ Clipboard := t

      		Clipboard="%A_ScriptName%"
      		MsgBox, functions_global.inc.ahk `n ln=%ln% `n  scriptName = %scriptName% `n parameter FILE must not be empty `n `n you find this now inside your clipboard : %Clipboard% `n `n move to line %ln% and fix the bug. `n `n or let run the SL5_AHK_preparser.ahk
      		return -1
   	}
   	;~ tipp: use notepadd++ , diverses> ohne rckfraen aktuallisieren
   	;~ tipp: use notepadd++ , diverses> nach aktuallisierung zum ende springen
   	msg:=""
   	;~ msg.= ";<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<`n"

   	if(strlen(text)>0)
   		msgtext := """" . text . """"
   	else
   		msgtext := text
   	msg.= scriptName . ">" . ln  . msgtext  . "`n"
   	;~ msg.= ";>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`n`n"

   	global lll
   	if(StrLen(lll)>0)
   		lll .= msg
   	else
   		lll := msg
   	Suspend,on
   	if(!FileExist("log"))
   	{
      FileCreateDir,log
      		if(true != InStr(FileExist("log"), "D") )
      		{
         ;~ would be true only if the file exists and is a directory
         		MsgBox,15-05-15_17-00 ops Who could we store logfiles ?
      		}
   	}

   ;~if(StrLen(GLOBAL_lllog_only_this_scriptName)>0
   	if(do_createLog_notAppendLog)
   	{
      FileDelete,%logFileName%
      		while(FileExist(logFileName))
      			Sleep,100
      		gLOBAL_lllog = GLOBAL_lllog_only_this_scriptName
      		strLen_GLOBAL_lllog := StrLen(gLOBAL_lllog)
      		subStr_lll__strLen := SubStr(lll,1,strLen_GLOBAL_lllog)
      		if(subStr_lll__strLen != gLOBAL_lllog)
      		{
         ;~ MsgBox,%subStr_lll__strLen% %GLOBAL_lllog_only_this_scriptName% := GLOBAL_lllog_only_this_scriptName `n
         		lll := "GLOBAL_lllog_only_this_scriptName = " . GLOBAL_lllog_only_this_scriptName . "`n" . lll
      		}
   	}

   	FileAppend, % lll, %logFileName%
   	;~ ToolTip,%logFileName% := logFileName `n
   	;~ MsgBox,%lll%
   	Suspend,off
   	return
}
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

runCopyQ_Ctrl_Shift_v(){
   MsgBox,,ShortCut CopyQ,Ctrl Shift V `n  dont work actually. `n please use Ctrl Shift 1. `n Sorry about that. thanks. 15.06.2015 , 3
   ;~ MsgBox [, Options, Title, Text, Timeout]
   	return
   	; <LEER> - CopyQ ahk_cl!A_ScriptDir!A_ScriptDir!A_ScriptDiraA_ScriptDirA_ScriptDirss QWidget... (3 Zeilen) - CopyQ ahk_class1`11`n`n`n
   		SetTitleMatchMode,2
   		DetectHiddenWindows,on
   	IfWinNotExist,CopyQ ahk_class QWidget
   	{
      MsgBox,it not exist
      		run,%A_ScriptDir%\SL5_AHK_Refactor_engine\copyq-windows\copyq.exe
      		Sleep,2000
   	}
   ; ^+v!; ^+v!; ^+v!; ^+v!; ^+v!; ^+v!; ^+v!; ^+vCopyQ ahk_class QWidget
   ; ^+v7!; ^+v!; ^+v!; ^+v!; ^+v!; ^+v\SL5_AHK_Refactor_engine\SL5_AHK_Refactor_engine\SL5_AHK_Refactor_engine
   Last_A_This:=A_ThisFunc . A_ThisLabel . " p"
   lll(A_LineNumber, "keysEveryWhere.ahk",Last_A_This)

   ToolTip1sec(A_LineNumber . " " . A_ScriptName . " " . Last_A_This)
   ;
   SetKeyDelay,80,80
		send,{Blind}
		Sleep,500
		 ;~ if(GetKeyState("ctrl", "P") )
		;~ {
			;~ ToolTip,:( oops 15-06-14_23-49
			;~ return
		;~ }CopyQ ahk_class QWidgetCopyQ ahk_class QWidget
		SetTitleMatchMode,2
		; {ShiftDown}^1{ShiftUp}
	DetectHiddenWindows,on
	Send,{CtrlDown}{ShiftDown}
	Loop,10
	{
   ;~ ControlSend, , - CopyQ{ShiftDown}^1{ShiftUp},ahk_class QWidget- CopyQ
   		;~ Sen- CopyQd,{S- CopyQhiftDown}^1{ShiftUp} 1runCopyQ_Ctrl_Shift_v1runCopyQ_Ctrl_Shift_v
   		Suspend,on
   		send,{Numpad1}1
   		WinActivate,- CopyQ
   		Sleep,100
   		IfWinActive,- CopyQ
   			break
	}
		Send,{ShiftUp}{CtrlUp}
		Suspend,Off
		;~ MsgBox, :) great CopyQ is active
	; CopyQCopyQ CopyQCopyQCopyQCopyQCopyQ{CtrlDown}{ShiftDown}1{ShiftUp}{CtrlUp}{CtrlDown}{- CopyQShiftDown}1{ShiftUp}{CtrlUp}
	WinSet, AlwaysOnTop,On,- CopyQ ; Toggle the always-on-top status of Calculator.
WinWaitActive, - CopyQ ,,2
if !WinExist("- CopyQ")
MsgBox, please install CopyQ and add a global hotkey STRG+SHIFT+1 (v is not possible there - or?)

WinWaitNotActive, - CopyQ
	; - CopyQ- CopyQ
	; cl- CopyQeanUp
	Clipboard = %Clipboard%

return
}

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
convert123To_NumPad123(t)
{
   StringReplace, t, t, 1 , {numpad1}, All
   StringReplace, t, t, 2 , {numpad2}, All
   StringReplace, t, t, 3 , {numpad3}, All
   StringReplace, t, t, 4 , {numpad4}, All
   StringReplace, t, t, 5 , {numpad5}, All
   StringReplace, t, t, 6 , {numpad6}, All
   StringReplace, t, t, 7 , {numpad7}, All
   StringReplace, t, t, 8 , {numpad8}, All
   StringReplace, t, t, 9 , {numpad9}, All
   StringReplace, t, t, 0 , {numpad0}, All
   return t
}
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
drawButtons(str , fontSize){
   ; maximal button size, recomandet:  drawButtons("1234567980" , 260)

   strLen := StrLen(str) + 1 ; some extra letters becouse some buttons are larger strg or so
   if(strLen<1)
      return false
   bx36 := 170
   by36 := 52
   W36 := 51
   H36 := 52
   R36 := 5
   ;    ;~ WinSet, Region, 142-62 W102 H102 R20-20, Shortcut  ; Same as above but with corners rounded to 40x40.
   bx72:= 142
   by72 := 62
   W72 := 105
   H72 := 102
   R72 := 20

   m := (72 - 36) / (W72-W36)
   W0 :=  72 - m * W72
   WFS1  := Round( (fontSize - W0) / m )
   WFS  := WFS1 *  strLen   + Round(  WFS1 * ( strLen - 1 )  * 0.3 )
   ;~ WFS  := Round( (fontSize - W0) / m) ; * StrLen(str+1)
   ; ; 284-62 W105 H102 R20-20
   ; 284-62 W105 H102 R20-20
   ; 284-62 W315 H102 R20-20

   ; 0-0 W774 H363 R98-98

   m := (72 - 36) / (bx72 - bx36)
   bx0 :=  72 - m * bx72
   ;~ bxFS  := Round( (fontSize - bx0) / m  + ( WFS - WFS1) / 2
   bxFStemp  := Round( (fontSize - bx0) / m )
   bxFS  := Round(bxFStemp  - WFS / 2 )
   bxFS  := -100
   bxFS  := 10
   ; -100-0 W774 H363 R98-98

   ;~ bxFS  := Round( WFS / 2 )

   m := (72 - 36) / (by72 - by36)
   by0 :=  72 - m * by72
   byFS  := Round( (fontSize - by0) / m )
   ;~ byFS := 0

   m := (72 - 36) / (H72-H36)
   H0 :=  72 - m * H72
   HFS  := Round(  (fontSize - H0) / m )
   ;~ HFS = 300

   m := (72 - 36) / (R72-R36)
   R0 :=  72 - m * R72
   RFS  := Round(  (fontSize - R0) / m )
   Progress, ZX0 ZH60 m2  fs%fontSize% zh0 CTFFFFFF CW000000, %str% ,, Shortcut , Keycaps Regular
   SetTitleMatchMode,2
   CoordMode, Pixel , Screen
   CoordMode, Caret , Screen
   WinGetPos, x , y , w , h , SciTE4AutoHotkey

   ; top of scite window
   WinMove, Shortcut, , % x , % y - 70 , % WFS + 50, % HFS + 100

   ; bottom of scite window
   ;~ WinMove, Shortcut, , % x , % (y + w - HFS - byFS - 350) , % WFS + 50, % HFS + 100

   ;~ Progress, fs%fontSize% CTFFFFFF CW000000, %str% ,, Shortcut , Keycaps Regular
   ;~ temp=%bx36%-%by36% W%W36% H%H36% R%R36%-%R36%
   temp= %bxFS%-%byFS% W%WFS% H%HFS% R%RFS%-%RFS%

   ;~ Clipboard = `; %temp%
   ;~ WinMove
   ;~ Sleep,2500
   x:=""
   y:=""
   WinSet, Region, %temp%, Shortcut  ; Same as above but with corners rounded to 40x40.

   SetTimer,ButtonsOffLabel,2000
   return
   ;~ Progress, ZX0 ZH60 m2  fs36 zh0 CTFFFFFF CW000000,L,, Shortcut , Keycaps Regular
   ; 170-52 W51 H52 R5-5
   ;                             170-52 W51 H52 R5-5
   ;                             284-62 W0 H102 R20-20
   ;~ WinSet, Region, 170-52 W51 H52 R5-5, Shortcut  ; Same as above but with corners rounded to 40x40.

   ;~ Progress, ZX0 ZH60 m2  fs72 zh0 CTFFFFFF CW000000,L,, Shortcut , Keycaps Regular
   ;~ WinSet, Region, 142-62 W102 H102 R20-20, Shortcut  ; Same as above but with corners rounded to 40x40.
   ;~ return WinSet, Region, 142-62 W102 H102 R20-20, Shortcut  ; Same as above but with corners rounded to 40x40.

   ;~ Progress, ZW-1 ZX0 ZH600 m2 b fs36 zh0 CTFF0000 CW0000FF,   L=l M=m N=n  O=o P=p Q=q R=r S=s T=t U=u V=v W=w  X=x Y=y Z=z   , , , Keycaps Regular
;~ Progress, ZW-1 ZX0 ZH600 m2 b fs24 zh0 CTFF0000 CW0000FF, \u232B x <    <= x /  = ~ ``    _ - : . `; `, ' " $ & ( ) { }     ? \  ( ] [  @  | `%  * +    # * ~  a b c d e f g h  i j k  Q  < > , , , Keycaps Regular

}

ButtonsOffLabel:
SetTimer,ButtonsOffLabel,Off
;~ SplashImage, Off
Progress, Off

return

; 15-07-07_16-22
lll(A_LineNumber, "functions_global.inc.ahk")
#Include ToolTipSec.inc.ahk ; ein kommentar
lll(A_LineNumber, "functions_global.inc.ahk")
#Include UPDATEDSCRIPT_global.inc.ahk
lll(A_LineNumber, "functions_global.inc.ahk")