How to shake the Google Chrome app with applescript? - applescript

I have one question.
I found app shake script with applescript.
(in this link: https://gist.github.com/gregferrell/7419080)
And I replace target app name "Terminal" -> "Google Chrome"
But It couldn't work.
I tested "Terminal" and "Finder", Good work!
How do I do?
Thanks.
Best wishes for you.

Related

AppleScript to Launch 1Password mini

I use 1Password to store my passwords, and fluid.app to create a few site-specific apps/browsers
While 1Password integrates well with Chrome, Safari and other browsers, it doesn't play nicely with Fluid apps, which is where my troubles lie.
I have therefore created a shortcut (with Keyboard Maestro) to run an applescript to open the mini, when I am in Fluid apps. However, I can't seem to get the applescript to launch the mini. Here are my attempts:
tell application "1Password mini" to launch does nothing, though AppleScriptEditor doesn't report any errors
tell application "1Password mini" to open nothing, though AppleScriptEditor doesn't report any errors
tell application "1Password mini" to activate is pointless, as 1Password mini is already activated
tell application "1Password" to open opens the main 1Password application, not the mini, which is what I need.
Interestingly, when I run (1), (2), and (3), AppleScriptEditor automatically replaces 1Password mini with 2BUA8C4S2C.com.agilebits.onepassword-osx-helper, which doesn't clarify things for me at all.
Does anybody have any clue how this can be solved?
I'm on OSX 10.10.2 (Yosemite), if it matters
I work for AgileBits, the developer of 1Password.
Looks like you found a solution, but here's another option for you:
open location "x-onepassword-helper://search/"
That AppleScript will open 1Password mini ready to search.
And if you're able to get the current website's domain from Fluid, you could even open 1Password Mini with a search term already filled in:
open location "x-onepassword-helper://search/twitter.com"
I hope that helps!
The solution was quite simple, with a little UI scripting:
tell application "System Events" to tell process "1Password mini"
tell menu bar item 1 of menu bar 1 to click
end tell

Open URL and Activate Google Chrome via Applescript

I have the following AppleScript that I wrote many years ago. I use this code to program buttons on my Harmony One universal remote to access online video services via Google Chrome. The code is not working. Google Chrome doesn't launch. I am running the code via RemoteBuddy. The code complies fine, but does not work.
Anyone have any thoughts on what might be the problem, or how I can improve the script to make it work?
tell application "System Events" to set open_applications to (name of everyprocess)
if (open_applications contains "Google Chrome") is true then
tell application "Google Chrome" to quit
else
tell application "Google Chrome"
activate
open location "http://xfinitytv.comcast.net"
end tell
delay 1
tell application "Google Chrome" to activate
end if
Try it this way:
tell application "Google Chrome"
if it is running then
quit
else
activate
open location "http://xfinitytv.comcast.net"
delay 1
activate
end if
end tell
Note: it's using the newer "Enhanced Application Model" (second line), more info here: How to check in AppleScript if an app is running, without launching it - via osascript utility
tell application "Google Chrome"
open location "http://WEBSITEHERE.com"
end tell
osascript -e 'tell application "Google Chrome" to open location "http://yourlink.com.html"'

Google Chrome doesn't open URL with AppleScript

What I have set up is a AppleScript that asks you what website you want to open with a couple options, to make this simple, I only list one option, Google. This is the current code:
if the_button = "Google" then
site = "http://www.google.com"
tell application "Google Chrome"
launch
tell window 1
make new tab with properties {URL:site}
repeat while loading of active tab
delay 0.1
end repeat
end tell
activate
end tell
It opens a new tab in Google Chrome, but doesn't put anything in the URL bar or reload/load or anything. I've tried this: Script Safari 5.1 to open a tab But, nothing's working. I'm using Mac OS X Lion 10.7.4 and Google Chrome version 21.0.1180.79. Please help!
It works for me, but not when Chrome doesn't have open windows or if all windows are minimized. You could add a reopen command to open a new default window or unminimize a window in those cases.
set site to "http://www.google.com"
tell application "Google Chrome"
reopen
activate
tell window 1
make new tab with properties {URL:site}
end tell
end tell
Another option might be to use something like do shell script "open " & quoted form of "http://google.com" & " -a Google\ Chrome". It's often closer to the default behavior of browsers.
Can't you just do this?
tell application "Google Chrome"
activate
set theSite to "http://www.google.com/"
open location theSite
end tell
The “open location” command is part of Standard Additions and is available to all Mac apps. It’s the default way to open a website in any Mac app. You might notice that Safari’s AppleScript dictionary doesn’t even include a way to open a website — it simply uses the standard “open location” command which you can find in the Standard Additions dictionary.

How can I open the Dropbox preferences window using Applescript?

How can I open the Dropbox preferences window using Applescript?
I'm assuming it would be something along the lines of
tell application "System Events"
tell application "Dropbox"
keystroke "," using command down
end tell
end tell
But this isn't working. Perhaps it's because Dropbox is running in the tray / background? ie: I can't switch to it using command-tab.
Thanks!
Unfortunately there is no way to do this. NSStatusItems (of which Dropbox is one) are not visible via accessibility. This weblog entry and this bug provide more information. Please file a bug and reference that bug number if this is important to you.

Code for minimizing application window in Mac?

I'm wondering whether there is a way to write code for Mac OS 10.5 which will minimize and restore a window. What language would it be in? Could someone please give me an example or direct me to documentation on Apple's developer site I should look at?
Thanks!
Try this applescript:
tell application "Safari"
set miniaturized of window 1 to true
end tell
Apple | AppleScript
AppleScript is Apples native scripting language. The official link above includes very useful information on how you can get started.
I suspect that the following URL is what you may need. It provides information and sample code for scripting and automation in AppleScript:
AppleScript | Scripting and Automation
I had trouble with these working in 2023.
This worked for me to open chrome and then minimize.
tell application "Google Chrome"
activate
delay 1
end tell
tell application "System Events" to set visible of process "Google Chrome" to false

Resources