Cedeq Community Forum
Keyboard Shortcut - Quick WordPad for Notes - Printable Version

+- Cedeq Community Forum (https://cedeq.com/forums)
+-- Forum: General (https://cedeq.com/forums/forumdisplay.php?fid=1)
+--- Forum: Keyboard shortcuts with AutoHotkey code (https://cedeq.com/forums/forumdisplay.php?fid=4)
+--- Thread: Keyboard Shortcut - Quick WordPad for Notes (/showthread.php?tid=12)



Keyboard Shortcut - Quick WordPad for Notes - denilama - 02-25-2018

This AutoHotkey script quickly brings an existing WordPad file to the forefront of the desktop, allowing the user to type or read whatever they need and continue working where they left off with minimum disruption. Workflow does not suffer and concentration can be maintained.

A bonus feature of this script is that you do not need to think about whether the WordPad file is open or not. If the file is open, it will bring it to the forefront. The script will not open another copy of the same file (which could result in the loss of some information, if two concurrent versions of the file were edited at the same time).

Need help creating a keyboard shortcut with ShortKeeper using the following AutoHotkey code? This 5-minute tutorial will help!
FileName := "Path+FileName.rtf"
wmi := ComObjGet("winmgmts:")
queryEnum := wmi.ExecQuery("Select * from Win32_Process where Name = 'wordpad.exe'") ._NewEnum()
while queryEnum[process]
{
 LenCL := StrLen(process.CommandLine)
 LenFL := StrLen(FileName)
 if (LenCL >= LenFL)
   if (FileName = SubStr(process.CommandLine, -(LenFL-1)))
   {
     WinActivate % "ahk_pid" . process.ProcessId
     return
   }
}
Run % "wordpad.exe " . FileName

At line #1, “Path+FileName.rtf” must be replaced with the actual path and name of the WordPad file (do not remove quotation marks).

This script is optimized to be used with ShortKeeper. As such, there is no “Return” at the end and variable(s) don’t need to be cleared. ShortKeeper will do this automatically. Just copy/paste the code in the PARAM field in ShortKeeper, set your hotkey, save, and you’re ready to use your new keyboard shortcut.