Thank you, this works great. I for some reason though it would not accept that as a button but it did.
I just have one more simple question. How do I reference a variable in an applescript. I want to do something like this :
Thank you, this works great. I for some reason though it would not accept that as a button but it did.
I just have one more simple question. How do I reference a variable in an applescript. I want to do something like this :
In the âExecute an AppleScriptâ action, click the âgearâ icon, and select âHelpâ.
About halfway down the Wiki page, thereâs a link that says âSee Scripting for best methodsâ. Click that.
You could have also found this by going to the Wiki, and searching for âAppleScriptâ.
https://wiki.keyboardmaestro.com
The Wiki is your friend.
I am not quite sure why this doesnât work though. You wrap the variable you want to pass in %, no?
With $ sign it does not work.
Also this macro, for some reason does not use my current clipboard, it used my last clipboard item, not current for some reason.
Have you tried this simple solution:
That syntax isnât for AppleScript. Look for the part that talks about AppleScript variables. Itâs very clearly stated at https://wiki.keyboardmaestro.com/manual/Scripting.
This still does not work.
That's what it passes into Dash.
Oops, never mind. I got it working now. Thank you Dan and Michael for your help and bearing with me for my silly questions.
No problem. Please post your solution for the benefit of others. You can then check the âsolvedâ checkbox so it will be clear in the top post.
Yeah, it is a very simple macro I needed to get around vim not behaving nicely with OS X selection. Here it is : search dash for selected text.kmmacros (20.5 KB)
I don't want to start another post as this is quite similar to what I was doing. This macro should take the text and do a query online with google and open the result in a new tab and bring focus to it. Here it is :
This however doesn't work, it doesn't open anything and I am not quite sure why.
How is this similar? Whereâs the AppleScript?
yeah, you are right, I will start a new topic then
This is very strange. I believed it worked but then again it started not working. This doesn't do anything, it doesn't trigger Dash with the clipboard query. If I remove Current Clipboard variable and replace it with let's say 'hello' string, it does work. I really wish I can get this to work.
Here is how the macro looks for me :
then most likely the clipboard is not what you think it is.
Display the clipboard in a "Display Text in Window" Action before the "Open URL" Action.
I've been using this Action for over a year now, and it still works:
Yeah you were right, I set a delay and the clipboard is correct however Dash is still not triggering. This is really strange.
Can you tell me more about your action. What is the %Variable%, do you set it somewhere and what is the other text there for?
Thank you.
Perhaps a better approach is for me to give you a complete example of a Dash search. I just uploaded this macro.
Note that it contains some specific Actions to deal with selecting text in the Script Editor, so you may want to adjust those to your needs.
Hey Nikita,
Nyet.
Expansion of tokens doesnât work in Execute Script actions â you DONâT want unexpected things happening to your code.
--------------------------------------------------------------------------------
set baseGoogleSearch to "http://www.google.com/search?q="
set googleSearch to baseGoogleSearch & (the clipboard)
if class of googleSearch = text then
open location googleSearch
else
beep
end if
--------------------------------------------------------------------------------
If you really need to get a Keyboard Maestro variable in AppleScript then do this:
--------------------------------------------------------------------------------
set baseGoogleSearch to "http://www.google.com/search?q="
tell application "Keyboard Maestro Engine"
set googleSearch to baseGoogleSearch & (getvariable "googleSearchString")
end tell
if class of googleSearch = text then
open location googleSearch
else
beep
end if
--------------------------------------------------------------------------------
-Chris
Thanks Chris, both of those AppleScripts were just what I was looking for to modify something else you had helped me out with in a different post. You seem to be helping me at every turn!