Okay, I was XnViewing my archives of jpegs and decided that I wanted to make a text file where I could write notes about when and where I took all those pictures. Problem was that there was no way for me to access my Explorer Context Menu wherein lies the ever-needful command of
"Create New Text File." So I made an XnViewNoteMaker script.
The way it works is it scans the XnView window for "seeable" text and then sorts through that for the string containing the folder path used in the Small Toolbar. Then it opens Notepad in that directory and saves it automatically with a pre-defined name so you don't have to use the save
dialog. Just type some text, ctrl+s, ctrl+x and you are done.
That way I have only to write my note, name it, and save it. I don't have to hunt down a notepad link and then do the painful browse to the directory opened in XnView. All I have to do to get this into XnView's Browser Toolbar is to place the script location in the "Command" box for the Brower Toolbar. (Go to options/toolbar/browser toolbar. Now click "append" and in that new white box, paste in the path to your XnViewNoteMaker.au3 script. Then, paste the same path into the "icon" box. Voila!) You MUST have AutoIt installed however or it won't work on your computer (but you don't need to compile the script with AutoIt.)
Clever? Well, it works! (Now, I have replaced Notepad with Metapad, but it is still called Notepad. So if you use my script, you will have to read the script where I have mentioned what needs to be changed). I have only used it in Windows XP Pro. Lord knows what Vista will do.
Below is my Autoit code. Do whatever you like with it, it is YOURWARE.
-God bless!
-Brother Gabriel-Marie
Save this code into a text file and change the extension to .au3
Code: Select all
;------------------AUTO IT SCRIPT-----------------------
;Opens Notepad, types in some text and then quits.
;By Brother Gabriel-Marie
;Do whatever you like with this script, it is YOURWARE
;For this to work in XnView, you must have showing both the Toolbar and the Small Toolbar (with the address box)
#include <String>
#include <array>
$TextRetrieved = WinGetText("[Class:XmainClass]", "")
;Now sort throught the text till we find the right string
;It won't work on the title bar because XnView truncates long paths with an ellipses!
$NextText = _StringBetween($TextRetrieved, 'TBView\R', '\\\R', -1,1)
$XnViewDirectory = $NextText[0] & "\"
;Run Metapad (Notepad) in the found directory
Run("Notepad.exe", $XnViewDirectory)
;Wait for the Notepad become active - it is titled "new file - metapad" on English systems
;If you have not replaced Notepad with Metapad, switch these two following commands
;WinWaitActive("Untitled - Notepad")
WinWaitActive("new file - metapad")
;Now, if you want to automatically save the Text File, we will have to automatically name it
Sleep(200)
Send("!f") ;Alt+F opens the file menu
Sleep(100)
Send("a") ;since the file menu is open, pushing A will "Save As"
Sleep(100)
Send($XnViewDirectory & "{!}Information.txt")
;I put the exclamation point there so it will sort to the front the directory
;If you don't put the exclamation in curlies, it won't work
Send("!s") ;now save it