Can anyone help me to create a script that put both parenthesis () or quotation mark in selected text. I will like to put with one keyboard those pare marks. example:
(text selected) " text selected" ¿text selected? ¡selected text!
Can anyone help me to create a script that put both parenthesis () or quotation mark in selected text. I will like to put with one keyboard those pare marks. example:
(text selected) " text selected" ¿text selected? ¡selected text!
Where is the text; what application?
well … if you want to do it thru all/most progamms on your system there should be only one way: system events
you’ve got to use an app like spark to give the script an hotkey … otherwise the scriptEditor will be frontmost
testing from ScriptEditor is also possible by changing “tell application MyProg” to (for example …) tell application “TextEdit”
set MyList to {"(", ")", "\"", "\""}
set MyProg to (path to frontmost application as text)
tell application MyProg
activate
tell application "System Events"
keystroke "c" using command down
end tell
set MyString to the clipboard
set MyToChooseList to {"(", "\""}
set parenthesis to choose from list MyToChooseList with prompt "Please select one item?"
if parenthesis = {"("} then set counter to 1
if parenthesis = {"\""} then set counter to 3
set MyStart to item (counter) of MyList
set Myend to item (counter + 1) of MyList
set MyString to (MyStart & MyString & Myend)
activate
tell application "System Events"
keystroke MyString
end tell
end tell