Skip to content

Instantly share code, notes, and snippets.

Last active October 12, 2015 17:48
Show Gist options
  • Save noahcoad/4064637 to your computer and use it in GitHub Desktop.
Save noahcoad/4064637 to your computer and use it in GitHub Desktop.
Opens Notepad with hotkeys
; Hotkey to opens text editor with clipboard contents
; Win+W Open text editor with empty temp file
; Win+Shift+W Open text editor with clipboard contents in an temp file
; See blog post for more info:
; Get this little app and update the path to where you put it
; Download from here:
cliputil := "c:\noah\tools\coad\EditClipboardText.exe"
; Automate dialogs
SetTitleMatchMode, 2
SetTimer, AppDialogAutomation, 350
; Open favorite text editor w Win+W
_file := MakeTempFile("txt")
Run %_file%
; Save the clipboard contents to a temp file and open the text file w Win+Shift+W
#+w:: Run %cliputil%
; Some common text editors
; You can comment out the editors not used
; Window's notepad.exe and SlickEdit are supported as they
; do not provide the filename in the save dialog to automation
; Notepad2 or Notepad2-mod, always save temp files
SendIfWinActiveExtended("Notepad2 ahk_class #32770", ".*Save changes to .*\\tmp.{2,6}\.txt.\?", "!y", true, 0, 0, true)
; UltraEdit, always save temp files
SendIfWinActiveExtended("UltraEdit ahk_class #32770", ".*\\tmp.{2,6}\.txt", "!y", true, 0, 0, true)
; Notepad++, always save temp files
SendIfWinActiveExtended("Save ahk_class #32770", "Save file .*\\tmp.{2,6}\.txt. \?", "!y", true, 0, 0, true)
; Sublime Text 2, always save temp files
; Alternatively you could set the setting save_on_focus_lost = true
; See here for info:
SendIfWinActiveExtended("Save Changes? ahk_class #32770", "tmp.{2,6}\.txt has been modified, save changes\?", "!y", true, 0, 0, true)
; Sends a keystroke to a dialog
SendIfWinActiveExtended(title, text, keys, regex, targetWidth, targetHeight, force)
if (regex)
SetTitleMatchMode RegEx
if (force)
WinActivate %title%, %text%
IfWinActive %title%, %text%
if (width > 0 and height > 0)
WinGetActiveStats, Title, Width, Height, X, Y
if (targetWidth = Width and targetHeight = Height)
Send %keys%
} else {
Send %keys%
SetTitleMatchMode %savedA_TitleMatchMode%
; Creates a temporary file with the given extension
_count = 0;
Loop {
_count = 000000%_count%
_file = tmp%_count%.%_ext%
_file = %temp%\%_file%
IfNotExist %_file%
return %_file%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment