Simple Window Center is a script for AutoHotKey that simply centers the active window on the current monitor. Plenty of times I have windows open, which I do not want to make fullscreen, that I would like to center in my monitor. I did not want any fancy functionality for snapping or anything else, but the only scripts I had previously found also resized the window.
Hotkey used in this script is Win + Alt + Up.
The three commented lines at the bottom are for investigating the values stored in the monitorInfo
variable, and left in for reference. Removing them will in no way alter the function of the script and is recommended. If you know what all the other values in the array represent please leave a comment informing me, because I have not been able to find it out.
I was only able to do this by inspecting and appropriating pieces from these gists by AWMooreCO, Cerothen, and park-brian; which offer neat functionality for window control. they gave me the insight and inspiration to finally fix the window-centering script I was previously using.
In addition they provide very good information on how to use Sublime Text to edit and run AutoHotKey scripts, which I recommend implementing with a few tweaks. I also wanted to set Sublime Text as my default text editor, and previously manually edited each filetype registry entry to replace notepad. A better way of doing it is to redirect calls to notepad in the registry with a single Key. (sublime as default editor source) The simplest method I have found for this that does not cause errors when dealing with spaces in the filepath is to use sublime launcher.
- v1.0 | 2020.10.29
- initial version and subsequent figuring out of how gists work (like adding a read-me)
- v1.1 | 2020.12.01
- added specific information for making sublime text the default program to edit, without changing default program to open, using the windows registry
- v1.2 | 2021-05-17
- removed:
They also give great information on making Sublime Text 3 the default editor of ahk scripts. I did have to additionally do some registry modifications to make the filetype associations. I highly suggest that you use Sublime Text to edit your scripts by following the information provided in those gists. And then—if you are comfortable editing your registry—additionally setting the
(Default)
value for{filetype}\shell\edit\command
to"[your\correct\filepath]\sublime_text.exe" "%1"
- updated the method for associating file types.
- old method: set
(Default)
value for each{filetype}\shell\edit\command
to"{your\filepath\sublime_text.exe" "1%"
- old method: set
- v1.3 | 2021.09.04
- updated method of replacing notepad as default text editor to use sublime launcher