Ideas on how to send/add selected text to a text file

Help with writing and playing macros

Ideas on how to send/add selected text to a text file

Postby jbl02 » Tue Aug 21, 2007 10:41 pm

I am building a list of words for a custom dictionary and it would be handy to be able to simply select a word and add it to a list in a file.
User avatar
jbl02
Newbie
 
Posts: 2
Joined: Mon Aug 20, 2007 11:00 pm

Re: Ideas on how to send/add selected text to a text file

Postby Mofi » Wed Aug 22, 2007 6:28 am

How would you do that manually? Maybe with following steps:

  1. Select the word.
  2. Copy it to clipboard.
  3. Open the file with the list of words.
  4. Go to bottom of the file.
  5. Paste the word.
  6. Insert a line break.
  7. Close the list file with save.
Exactly this can be done also with a macro:

IfSel
Clipboard 9
Copy
Open "name of list file with full path"
Bottom
IfColNum 1
Else
"
"
EndIf
Paste
"
"
CloseFile Save
ClearClipboard
Clipboard 0
EndIf


What you want to do could be also done faster without a macro by using a user tool.

Open Advanced - Tool Configuration and create a new tool with following settings:

Tab Command
Menu Item Name: Add selection to list file
Command Line: echo %sel% >>"name of list file with full path"
Working Directory: select with the Browse button the direcotry of the list file - please really use the Browse button
Toolbar bitmap/icon (file path): whatever you like and have

Tab Options
Program Type: Dos Program
Save Active File: unchecked
Save all files first: unchecked

Tab Output
Command Output: Append to Existing
Show DOS Box: unchecked
Capture Output: unchecked
Replace selected text with: No Replace

Okay, now you have a tool which you can run whenever you want to append to your list file a line with the current selection.

You can assign a hotkey for the user tool and you can customize the toolbar and add the user tool to the toolbar.

Note: I have both methods not tested.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4062
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Ideas on how to send/add selected text to a text file

Postby jbl02 » Wed Aug 22, 2007 1:48 pm

Thanks a lot MOFI.
I tried the Tools method and it worked perfectly.
I just added the tool to the tool bar.
Now I select a word, click the tool and it is added, no pop ups, warnings, dialogs or anything.

Thanks
jbl
User avatar
jbl02
Newbie
 
Posts: 2
Joined: Mon Aug 20, 2007 11:00 pm


Return to Macros