We then use those to "flick" the window between monitors. The short story of how it differs from the script above is that we also add a PositionToggle variable and some "IF logic". To keep this article streamlined, we've instead included information on how the script works within it in the form of comments. Bonus Trackįor your convenience, we've decided to conjure and include a secondary script that will be useful to those with dual monitor setups. For example, !+c:: would map the function to the Shift + Alt + C key combination. If you don't like that shortcut, tweak the "^y::" line to a different key combination. Then, "run" it, with AutoHotKey installed, to center any window whenever you press CTRL + Y. Note that you can copy the script above, paste it in Notepad or a similar text editor, and save it with an AHK extension. WinMove, %ActiveWindowTitle%, %TargetX%, %TargetY% Move the window to the calculated coordinates. TargetY := (A_ScreenHeight/ 2)-(Height/ 2) Calculate the vertical placement of the window. TargetX := (A_ScreenWidth/2)-(Width/2) Calculate the horizontal target where we 'll move the window. WinGetPos, Width, Height, %ActiveWindowTitle% Get the active window 's position, used for our calculations. WinGetTitle, ActiveWindowTitle, A Get the active window 's title for "targetting" it/acting on it. SetWorkingDir %A_ScriptDir% Ensures a consistent starting directory. SendMode Input Recommended for new scripts due to its superior speed and reliability. #Warn Enable warnings to assist with detecting common errors. The final script file, as opened in a text editor, should look something like this: #NoEnv Recommended for performance and compatibility with future AutoHotkey releases. Combine the monitor's and window's dimensions to calculate the optimal coordinates for presenting said window in the screen center.Also "read" its dimensions (width & height).This time, though, we'll take advantage of AutoHotKey's window manipulation abilities to: We saw in the past how you can use AutoHotKey to pin windows "always on top" using a keyboard shortcut. The Solution to the ProblemĪpart from sending keystrokes and mouse clicks to any window, AutoHotKey can also manipulate them. Especially when dealing with multiple requesters popping on different spots, expecting user input. It's distracting, and it can also be annoying when it happens repeatedly. Windows (as in "the rectangle thingies on our screens", not the OS) tend to pop anywhere on the screen. So, let's make such an action plan in plain English that we'll then "mutate" into a script. Half the battle when creating a script is coming up with how it will work before even typing a single character. How to Set Up a Window-Centering Hotkey With AutoHotKey
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |