Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
Global Config_File := "S:\server\Stauch\AHK_Configs\" . A_UserName . ".ini" ;.ini config file path
;The only way I could get these to work, was to declare them here, and globally. Would not work defining in the function
Global zone_x := 0
Global zone_y := 0
Global zone_w := (A_ScreenWidth/2)
Global zone_h := (A_ScreenHeight/2)
Global zone_key := 0 ;Used to determine which Function Key was used, declaring a spefic zone {F1} through {F12}
;;Moving Screens to Zones;;;;;;;;;;;;;;;;;;;
#F1::
zone_key := 1
mZone()
Return
#F2::
zone_key := 2
mZone()
Return
#F3::
zone_key := 3
mZone()
Return
#F4::
zone_key := 4
mZone()
Return
#F5::
zone_key := 5
mZone()
Return
#F6::
zone_key := 6
mZone()
Return
#F7::
zone_key := 7
mZone()
Return
#F8::
zone_key := 8
mZone()
Return
#F9::
zone_key := 9
mZone()
Return
#F10::
zone_key := 10
mZone()
Return
#F11::
zone_key := 11
mZone()
Return
#F12::
zone_key := 12
mZone()
Return
+#F1::
zone_key := 111
mZone()
Return
+#F2::
zone_key := 222
mZone()
Return
+#F3::
zone_key := 333
mZone()
Return
+#F4::
zone_key := 444
mZone()
Return
+#F5::
zone_key := 555
mZone()
Return
+#F6::
zone_key := 666
mZone()
Return
+#F7::
zone_key := 777
mZone()
Return
+#F8::
zone_key := 888
mZone()
Return
+#F9::
zone_key := 999
mZone()
Return
+#F10::
zone_key := 101010
mZone()
Return
+#F11::
zone_key := 111111
mZone()
Return
+#F12::
zone_key := 121212
mZone()
Return
;;Setting Zones;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#IfWinActive ahk_class ThunderRT6MDIForm
MsgBox, "Oops"
Return
#IfWinNotActive ahk_class ThunderRT6MDIForm
^!F1::
zone_key := 1
wZone()
Return
^!F2::
zone_key := 2
wZone()
Return
^!F3::
zone_key := 3
wZone()
Return
^!F4::
zone_key := 4
wZone()
Return
^!F5::
zone_key := 5
wZone()
Return
^!F6::
zone_key := 6
wZone()
Return
^!F7::
zone_key := 7
wZone()
Return
^!F8::
zone_key := 8
wZone()
Return
^!F9::
zone_key := 9
wZone()
Return
^!F10::
zone_key := 10
wZone()
Return
^!F11::
zone_key := 11
wZone()
Return
^!F12::
zone_key := 12
wZone()
Return
#^!F1::
zone_key := 111
wZone()
Return
#^!F2::
zone_key := 222
wZone()
Return
#^!F3::
zone_key := 333
wZone()
Return
#^!F4::
zone_key := 444
wZone()
Return
#^!F5::
zone_key := 555
wZone()
Return
#^!F6::
zone_key := 666
wZone()
Return
#^!F7::
zone_key := 777
wZone()
Return
#^!F8::
zone_key := 888
wZone()
Return
#^!F9::
zone_key := 999
wZone()
Return
#^!F10::
zone_key := 101010
wZone()
Return
#^!F11::
zone_key := 111111
wZone()
Return
#^!F12::
zone_key := 121212
wZone()
Return
Return
;;;;;Functions;;;;;
fread()
{
if FileExist(Config_File) ;check to see if the config file exists
{
Try ;Try to read the configurations from the .ini file
{
;IniRead, OutputVar, Filename, Section, Key
IniRead, zone_x, %Config_File%, Area1%zone_key%, %zone_key%
IniRead, zone_y, %Config_File%, Area2%zone_key%, %zone_key%
IniRead, zone_w, %Config_File%, Area3%zone_key%, %zone_key%
IniRead, zone_h, %Config_File%, Area4%zone_key%, %zone_key%
}
Catch e ;catch all errors
{
Msgbox,48, Error, There was an ERROR reading the saved config file. ;msg thown on read/access error
}
}
}
fwrite()
{
;ProgramExit:
;on program exit, try to write whatever you want to save to the .ini config file. Can do other stuff in the sub as well, if needed
Try
{
;IniWrite, Value, Filename, Section, Key
IniWrite, %zone_x%, %Config_File%, Area1%zone_key%, %zone_key% ;write to the .ini config file
IniWrite, %zone_y%, %Config_File%, Area2%zone_key%, %zone_key%
IniWrite, %zone_w%, %Config_File%, Area3%zone_key%, %zone_key%
IniWrite, %zone_h%, %Config_File%, Area4%zone_key%, %zone_key%
;.....
;note: look for notes at the top about using loops
}
Catch e
{
Msgbox,48, Error, There was an ERROR writing to/creating the config file, on exit. ;msg thown on read/access error
}
;ExitApp
}
wZone()
{
WinGetActiveStats, Title, Width, Height, X, Y
zone_x := X
zone_w := Width
zone_y := Y
zone_h := Height
fwrite()
;MsgBox, wrote to file x = %zone_x% and y = %zone_y% and width = %zone_w% and finally height = %zone_h%
Return
}
mZone()
{
fread()
;MsgBox, Passed the fread function.
WinMove,A,,zone_x,zone_y,zone_w,zone_h
;MsgBox, x = %zone_x% and y = %zone_y% and width = %zone_w% and finally height = %zone_h%
fwrite()
Return
}
Return