Set any Window to Always on Top
Set any Window to Always on Top

Set any Window to Always on Top

At first, the active window will come to the front. After using the shortcut, the right window stays pinned on Top.

1. Intro

This is a short one. I found this neat trick the other day while browsing the internet, and decided to implement it. I then started using it a lot more than I thought I would! “Always On Top” is a very small utility based on the AutoHotkey script (huge article on that coming someday) which basically enables you to pin any window to the “top” of your screen. Meaning any other windows will always move and be behind it. If you’re familiar with Pureref, you’ve probably used this setting before. The thing is, only some apps come with this setting. For the rest of your windows, here’s this tool!

a. How I made this tool

As I said before, this tool is based on an AutoHotkey script. It’s barely one line of code:

^SPACE::  Winset, Alwaysontop, , A
“^” stands for the CTRL key → CTRL+SPACE will activate this setting for your current, active window.

Without going into too much detail, AutoHotKey is a scripting language that lets you create lots of useful shortcuts, actions and macros to do things fast with your computer. I will get a lot more into detail in the future, and I think everyone is going to love it as much as I do.

After writing the code, I just compiled the above line of code into a .exe file so that you can easily run it and then added a cute pin icon to it. That’s literally it.

⚠️
As with anything else you download from the internet, make sure you’re carrying out your due diligence. I made this particular app so I fully trust it, but as a general rule always be wary of downloading .exe files from the internet. I feel like I have to say that. However, if you’re still kind of iffy about it, go to Part 3 where I will very quickly teach you how to make this app from scratch yourself in 2 minutes. As a bonus, you can also choose your own keyboard shortcut for it!

2. Downloading and “installing” AOT

a. Download and install

If you don’t want to create this tool yourself, you can simply download it from here. Just unzip the downloaded file and save the tool wherever you want.

You can double click to run it, and this same pin icon with appear in your menu bar. You can now just hit CTRL+SPACE to pin a window to top. Press CTRL+SPACE again while having the same window active to unpin.

image

b. Some extra bit of configuration

So here’s another cool tip inside this tip (tipcetion!). There is a way you can pick certain programs and apps to run automatically when you turn on your PC, so you don’t have to worry about running them time and time again when you need them.

To do this, you need to press the Windows key and R at the same time. (WIN+R). The Run window dialog will pop up. Then type shell:startup and hit OK.

image

This will open a folder where you can copy any links and shortcuts to the apps you want your PC to run when it starts up. Just drag a shortcut (or the entire, small app itself) to this folder, and you’re done! The app will run when you turn on your PC.

image

If you downloaded the already-made tool, that should be it! If you haven’t and want to learn how to write this app yourself, move onto section 3!

3. Writing the tool by yourself.

So this is where it gets fun! I wanted to write this optional section for those of you who are a bit wary of just downloading any random guys’ (hey!) executable file. I understand your hesitation and I accept it. I won’t dig into much detail, but you can always reach out to me in social media if you have any questions or something isn’t working.

a. Installing AutoHotKey

To write this app, you will need to install AutoHotKey. It’s a super cool app and I will one day explain why, but for now you just need it to code and compile this tool. You’re free to uninstall it once you’re done.

Download and install AHK.

b. Writing the code.

Now you need to create a new text document (any text editor will work) just to write our code. On the blank document, just copy paste this:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

^SPACE::  Winset, Alwaysontop, , A
Return

The first few lines are just default instructions for AutoHotkey to work properly, and the bottom two are the tool and a “Return” command so that it stops reading code when it gets there. I’m not even sure that last line is needed but I’m a self-taught pseudo-coder so I tend to overdo these things.

💡
Bonus! See that “^SPACE” bit on the second to last line? That’s the shortcut that will trigger the tool to pin windows. AutoHotKey works with a couple of abbreviations for common modifiers: ^ = CTRL ! = ALT + = SHIFT If you wanted the shortcut to be, for example, CTRL + ALT + H, you would replace ^SPACE:: with ^!H::

That’s literally it! Now save this text file as anything you want, with the extension “.ahk” This is important so that AutoHotKey recognises the file. Since you have AutoHotKey installed, you can now double-click this .ahk file to open the tool, and you’re good to go! Before making the .exe, you can right click and Edit the .ahk file to change the shortcut or test new things.

3. Compiling the .exe

With AutoHotKey still installed, you can right click on the .ahk file you just made, and you will see a list of options. Pick “Compile Executable (GUI)”. A dialogue will open up and will ask you where to save the .exe, and if you want any custom icons on it. Once you’ve saved the .exe and tested that it works, you’re free to uninstall AutoHotKey if you please. You can now follow the instructions on part 2.b of this article.

Congratulations! You’ve coded your own application like an absolute hacker. I hope you find this tool as useful as I do, and as always, feel free to share this tip and reach out with any questions or comments. Cheers!