![autohotkey crosshair overlay script autohotkey crosshair overlay script](https://i.ytimg.com/vi/z9AVYawdNAE/maxresdefault.jpg)
![autohotkey crosshair overlay script autohotkey crosshair overlay script](https://i.ytimg.com/vi/0A6gFBoGEto/hqdefault.jpg)
YPlacement = % A_ScreenHeight - bgHeight - padding I don’t have syntax highlighting support for AHK on the blog, so pardon for just adding it as text: The SetTimer function in the CreateWindow function calls the RemoveGui function after 5 seconds, and that function just calls destroy on the GUI Whenever I want to display the window I call the CreateWindow function passing in the keysĪnd this is how the text size is calculated: Here is the script which might need some refactoring :) The window is displayed for 5 seconds then destroyed, releasing the memory as I don’t need to keep it around and therefore I prefer to recreate it instead when needed.
#Autohotkey crosshair overlay script update
The placement of the window is calculated based of the monitor resolution (in this script assuming only one monitor- I’ll update it to deal with several monitors next week), and the window size is set to calculated input string (which is the hotkey combo passed into the function as a string). So instead I created a script that would create a window that would overlay my screen but not demand focus for keyboard and mouse input. Pretty much what I use AHK for, to avoid repetitive work. I could always add a layer in the video while editing the video, but that would mean a lot of repetitive work- and tedious. The dictionary is trimmed down and is not using my explicitly declared script folder- you might want to do that.I was working on some AutoHotKey (my favorite desktop automation tool) videos and I asked myself how I best could showcase the keyboard shortcuts that I was using in the scripts. Here is my associative array/ dictionary declaration, and retrieving the value via the key (the key is passed in as a parameter in the function). Docs for objects can be found here, have a read for creating more manageable scripts Support for objects was added in AHK 1.* and with that an associative arrays (i.e. The way I switch between images is by keeping a lookup dictionary in the script, with each key holding the filepath to the actual image for the background. I’ve given the text a slight shadow effect by overlaying the text with a lighter color, that line can certainly be refactored a little bit :) Let’s talk about my %bgPath% variable. Notice the WinSet, TransColor, 000000 and BackgroundTrans on the Text control Gui, Show, x%xPlacement% y%yPlacement% NoActivate Gui, Add, Text, xm y12 x%xPlacementTextShadow% BackgroundTrans,%key% Gui, Add, Picture, x0 y0 w%bgWidth% h%bgHeight%, %bgPath% Gui, +LastFound +AlwaysOnTop +ToolWindow -Caption For simpler images that works fine, for more complex ones you might want to use the GDI library to avoid crispy/pixelated edges. There are a few ways to deal with image transparency, but I simply set a background color on the window, then set the same color as transparent. The text background also has to explicitly be set to transparent, otherwise it will inherit the color from the window, or use the default color. The images I use have rounded corners and therefore I need window transparency (which I removed in the previous script to keep the script terse). The above sets the background to black, but you can of course use any color you would like to use. To set he background color of a GUI you simply use First let’s go back to the question about GUI backgrounds. I’ll get back to the CreateWindow function to explain the second parameter.
#Autohotkey crosshair overlay script software
The hotkey window I created loads up different images depending on the hotkey and the context I use the hotkey in and the script was a scaled down version of my original script.įor example I have several macros that I use with Premiere, a hardcore video editing software I use to edit Pluralsight videos. I was asked why I didn’t simply use a background color instead of the image background and here is why. I got some questions after the last blog post and therefore I decided to show another script, similar to the one I posted last.