8 ms·
Wow, the one time in history I may be able to contribute something useful to a code-related discussion. I set up this script so I could quickly and easily open
by devindotcom 3y ago
Wow, the one time in history I may be able to contribute something useful to a code-related discussion. I set up this script so I could quickly and easily open a blank plaintext notepad.exe instance at any time, which is super useful as a writer. When I hit tilde it opens, when I hit tilde again, it closes, with a save dialog if anything was written. It's the only thing my AHK does!
`::
IfWinActive Untitled - Notepad
WinClose
else
IfWinActive *Untitled - Notepad
WinClose
else
IfWinExist Untitled - Notepad
WinActivate
else
IfWinExist *Untitled - Notepad
WinActivate
else
Run Notepad
return
- LelouBil 3y agoWouldn't notepad++ be better because of the auto save ? I think auto saving of unsaved documents is one of it's best features
- TuringTest 3y agoNotepad++ may be extremely slow to open if you have a previous tab with a huge file, like a log or a xml data dump. That would defeat the point of having the notetaking window open instantly.
- mackrevinack 3y agothat's a good one fyi, if you use the WinActive() or WinExist() functions you can combine different titles If WinActive("Untitled - Notepad ahk_class Notepad") or WinActive("*Untitled - Notepad ahk_class Notepad") maybe you don't have to put in the "ahk_class Notepad" bit, its been a while since i used ahk!
- myfonj 3y agoI like the detail how the very same key (just mostly in combination with meta/windows key) is kinda idiomatic toggle for terminal, what most programmers "live in". I wonder if digital graphic artists happen to launch their scratchpads or paint programs in a similar manner. Btw, for use-cases when you need to keep the "toggled" window opened and do not want to close, minimize or hide it or something and just need the fastest flip to, flip back to previous window "toggle", super useful but (for me) long time forgotten native Windows hotkey is *`Alt + Escape`* - it simply switches to previous focused window without even showing window overview (like Alt+Tab). So AutoHotkey *v1* boilerplate for such switcher/launcher then could be something like: ; Toggle <...> window using Ctrl + Shift + Win + <key> ^+#<key>:: _bckTMM := A_TitleMatchMode _bckDHW := A_DetectHiddenWindows SetTitleMatchMode, 2 DetectHiddenWindows, On ifWinExist, <... window title fragment> { ifWinActive { send, !{escape} } else { WinActivate } } else { run, <... launcher> } DetectHiddenWindows, %_bckDHW% SetTitleMatchMode, %_bckTMM% return Or if you do not want that window to clobber the taskbar, you can use `WinHide` instead of that Alt+Win `send, !{escape}` and add WinShow to WinActivate, but it does not work well with some kinds of windows. Also for window detection it may sometimes be more suitable to use `ahk_exe` or `ahk_class`.
- sisve 3y agoDid not know about `Alt + Escape` - thank you!
- larschdk 3y agoMy similar solution that I use for Outlook/Teams/TotalCommander/more: https://github.com/larsch/AutoHotkeyScripts/blob/main/Launcher.ahk https://github.com/larsch/AutoHotkeyScripts/blob/main/Launch... I do include Minimize-if-already-active though. I like to be able to temporary flip an application into focus (e.g. Outlook) and then return to what I was previously working on. Plus a tweak: When launching, programs may open in the background because Windows attempts to prevent applications stealing focus when you are working in another program. I overcome this by focusing the tray before launching.
- diogotito 3y agoI also wrote my AHK functions to have hotkeys to cycle through (or toggle) windows from an application! Here: https://github.com/diogotito/autohotkey-scripts/blob/desktop/Lib/CycleOrLaunch.ahk https://github.com/diogotito/autohotkey-scripts/blob/desktop... and here's where I declare most of my hotkeys: https://github.com/diogotito/autohotkey-scripts/blob/desktop/desktops.ahk https://github.com/diogotito/autohotkey-scripts/blob/desktop... It uses AHK's window groups. I only regret having written this in AHK v1, which was a bit of a pain in the neck. I intend rewrite them in AHK v2, which looks like a halfway step to ES6 with lambdas, closures and all. So many quirks gone! I tried it a bit and it felt more fun and productive. As a simpler alternative (which I use for work), one can pin the 10 most used applications on the taskbar and do: - Win+<N> to launch, toggle, or choose a window from the Nth application - Ctrl+Win+<N> to launch, toggle or cycle through the windows from the Nth application - Shift+Win+<N> to launch a new window - Alt+Win+<N> to bring up the Jump List Then you can use a simpler hotkey manager (like PowerToys' Keyboard Manager) to bind to the Ctrl+Win+<N> shortcuts. > Plus a tweak: When launching, programs may open in the background because Windows attempts to prevent applications stealing focus when you are working in another program. I overcome this by focusing the tray before launching. Aaah! That explains some things. That does happen to me sometimes and it's a bit annoying. I got used to pressing my hotkey again when I noticed the taskbar icon blinking green to bring up the new window, or just spamming WinActivate and hope for the best. Thanks!
- sh4rks 3y agoThis is only slightly faster than hitting the Windows key, typing "Notepad", and hitting Enter. Would be cool if it opened a single "notes.txt" document instead. That way you could bring up your notes, append what you want, and save/close it with a single hotkey.
- Oranguru 3y agoIt's about minimising friction in our tasks and reducing any unnecessary obstacles. Even seemingly minor actions that only take a few seconds can build up over time and generate a sense of frustration, especially when they become frequent. Personally, I have found that dealing with this kind of friction can erode my overall productivity, as I unconsciously shy away from these tedious tasks that involve manual repetition, no matter how small. That's why many of us choose to invest a little time in coming up with these small automations that free us from the clutches of monotonous and repetitive tasks, allowing us to focus on the core of our work.
- basiskarten 3y agoVery well said. It also feels really good to get rid of small things that annoy you every day by creating your own solutions, cf.: https://www.joelonsoftware.com/2000/04/10/controlling-your-environment-makes-you-happy/ https://www.joelonsoftware.com/2000/04/10/controlling-your-e...
- hwayne 3y agoThat's one of the things I do in the codebase, though more configurable (so you can have multiple note categories). The change is something like Run (A_WorkingDir . "\Config\Notes\" . this.NoteType . ".txt")
- deleted 3y ago[deleted]
- Willwhatley 3y ago; I call this "Tilde opens Notepad" after yours, devindotcom. ; It is made in Autohotkey2. `:: ; Tilde key { If WinActive("Untitled - Notepad") or WinActive("*Untitled - Notepad") WinClose else If WinExist("Untitled - Notepad") or WinExist("*Untitled - Notepad") WinActivate else Run "Notepad" }