View Single Post
Old 12-29-2014, 06:24 PM   #22
mrevent
Zealot
mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.mrevent knows better than to ask about the Gravitic Imploder Lance.
 
Posts: 105
Karma: 87300
Join Date: Feb 2011
Device: kindle 3w, dxg, 5, Kv
Hi again,

I tried using Robert Collins English<->French Dictionary for Mac for definitions.

[After seeing belatedly knc1's message above: both Robert-Collins and Ultalingua are closed source programs. Please delete this post if inappropriate, then. I tried to make the script work in Dictionary.app --where one can use Stardict dictionaries -- yet to no avail.]

The following script will get each word from an Excel list (Column A) and append the first two lines of the definitions from the Robert Collins Dictionary to Column B. (TextEdit.app is used as an intermediary). Before running the script, in Excel: the first cell has to be selected; in the Dictionary: the text field has to be selected.


(Currently, the repeat times is set to 2. Change it to the number of the words in the Excel list.
Also: One can duplicate the line '"keystroke (ASCII character 31) using shift down"' in the script to increase the number of lines to be copied from the Robert-Collins Dictionary.)


I don't know how useful it may be to some of us. Since I am still at the newbie level in scripting, I prefer to believe that I "accomplished" something


Code:
tell application "Microsoft Excel"
	repeat 2 times
		activate
		tell application "System Events"
			tell process "Microsoft Excel"
				keystroke "c" using {command down}
			end tell
			tell application "Le Grand Robert & Collins"
				activate
				tell application "System Events"
					tell process "The Collins-Robert French Dictionary"
						delay 0.5
						keystroke "v" using {command down}
						delay 0.1
						keystroke return
						delay 0.5
						keystroke "a" using {command down}
						delay 0.2
						keystroke "c" using {command down}
						keystroke tab
						delay 0.1
						keystroke tab
						delay 0.1
						keystroke tab
					end tell
				end tell
			end tell
			tell application "TextEdit"
				activate
				tell application "System Events"
					tell process "TextEdit"
						keystroke "v" using {command down}
						keystroke (ASCII character 30) using command down
						delay 0.2
						keystroke (ASCII character 31)
						keystroke (ASCII character 31) using shift down
						keystroke (ASCII character 31) using shift down
						keystroke "x" using {command down}
						keystroke "a" using {command down}
						keystroke (ASCII character 8)
					end tell
				end tell
			end tell
			delay 0.2
			
			tell application "Microsoft Excel"
				activate
				tell application "System Events"
					tell process "Microsoft Excel"
						keystroke tab
						delay 0.1
						keystroke (ASCII character 32)
						delay 0.1
						keystroke "v" using {command down}
						delay 0.2
						keystroke return
					end tell
				end tell
			end tell
			delay 0.2
			
		end tell
	end repeat
end tell


And for the Ultralingua dictionary:


Code:
tell application "Microsoft Excel"
	repeat 2 times
		activate
		tell application "System Events"
			tell process "Microsoft Excel"
				keystroke "c" using {command down}
			end tell
			tell application "Ultralingua"
				activate
				tell application "System Events"
					tell process "Ultralingua"
						delay 0.5
						keystroke "v" using {command down}
						delay 0.3
						keystroke tab
						delay 0.1
						keystroke tab
						keystroke "a" using {command down}
						delay 0.3
						keystroke "c" using {command down}
						delay 0.2
						keystroke tab
						
					end tell
				end tell
			end tell
			tell application "TextEdit"
				activate
				tell application "System Events"
					tell process "TextEdit"
						keystroke "v" using {command down}
						delay 0.5
						keystroke (ASCII character 30) using command down
						delay 0.5
						keystroke (ASCII character 31)
						delay 0.5
						keystroke (ASCII character 31) using shift down
						delay 0.5
						keystroke (ASCII character 31) using shift down
						delay 0.5
						keystroke "x" using {command down}
						delay 0.3
						keystroke "a" using {command down}
						keystroke (ASCII character 8)
					end tell
				end tell
			end tell
			delay 0.2
			
			tell application "Microsoft Excel"
				activate
				tell application "System Events"
					tell process "Microsoft Excel"
						keystroke tab
						delay 0.1
						keystroke (ASCII character 32)
						delay 0.1
						keystroke "v" using {command down}
						delay 0.2
						keystroke return
					end tell
				end tell
			end tell
			delay 0.2
			
		end tell
	end repeat
end tell

Last edited by mrevent; 12-29-2014 at 07:48 PM.
mrevent is offline   Reply With Quote