applescript

Is there a way to trigger a Hot Key/Keyboard Shortcut via a Shell Script, a AppleScript or a Automator Workflow?

房东的猫 提交于 2019-12-06 20:36:22
I'm an avid Keyboard Maestro user and I need a workaround for triggering a keyboard shortcut like ⌘⇧L (externally, without Keyboard Maestro). So I thought a bash script would be capable of doing such a thing. An AppleScript or an Automator workflow would be sufficient, too. I anybody could help me this would be great. You don't have to read this, but here's why I want to do what I want to do: I have a the same string assigned to various Markdown macros, I use a string instead of Hotkeys because it's much more memorable for me since my brain already is filled with so many application shortcuts.

Check if display is sleeping in Applescript

邮差的信 提交于 2019-12-06 17:33:45
问题 I'm trying to check if the display is sleeping, then execute some code in AppleScript. So far I've tried this- set display_sleep_state to do shell script "ioreg -n IODisplayWrangler |grep -i IOPowerManagement" if display_sleep_state contains sleeping then -- Display is asleep else if display_sleep_state contains awake then -- Display is awake else -- We don't know. end if I found that here- https://superuser.com/questions/182018/determine-macs-screen-state-using-applescript But display_sleep

Automator to Applescript for Editing Code

a 夏天 提交于 2019-12-06 16:34:46
Just wondering if I can convert a "watch me do" event in Automator to applescript and then edit the resulting code? I've got a recording of entering a query (i.e. Apple1) into Google, but I'd like the query to increase ++ for each loop of the recording, so the result is Apple1, then the next loop would be Apple2, Apple3, etc. I know increments are elementary in programming, but I'm just not sure how to do it using Automator and/or applescript. Any help would be greatly appreciated. It may be simpler just doing it all in Applescript. Example: set counter to 0 set theTerm to "apple" repeat 4

Applescript Finder path into POSIX path

允我心安 提交于 2019-12-06 16:12:05
I'm running the following applescript: tell application "Finder" set input to POSIX file "/Users/sam/Desktop/Resized" set theFiles to (every file of folder input whose name does not contain "- Resized") end tell return theFiles It's working as it should, though it's returning: {document file "HighResCat.jpg" of folder "Resized" of folder "Desktop" of folder "sam" of folder "Users" of startup disk of application "Finder", document file "madonna.jpg" of folder "Resized" of folder "Desktop" of folder "sam" of folder "Users" of startup disk of application "Finder"} where I need a POSIX path (

How to access from AppleScript a bundled file within a Cocoa-AppleScript Application?

梦想的初衷 提交于 2019-12-06 16:04:40
问题 In AppleScript I'm used to call: set audio_file to (path to me as string) & "Contents:Resources:Audio:Music.mp3" display dialog "Path: " & (quoted form of POSIX path of audio_file) I have now this code inside a Cocoa-AppleScript project in Xcode. It compiles well, but the script is not running at all. The dialog never shows. Without the (path to me as string) it works, but without the path. 回答1: For resource file I use: set fname to POSIX path of (path to resource "filename") 回答2: "Path to me

How do I attach a file to a new message in Microsoft Outlook via AppleScript?

和自甴很熟 提交于 2019-12-06 15:55:00
The following script worked fine before upgrading to Office 365 and OSX 10.10: tell application "Microsoft Outlook" set newMessage to make new outgoing message tell newMessage make new attachment with properties {file:"/Users/foo/file"} end tell open newMessage end tell But now it gives this error message: execution error: Microsoft Outlook got an error: Error while saving the changed record property. (-2700) Has the procedure changed or is this a bug in either OSX or Outlook? The path must be an alias or a posix file . Convert a posix path like this: set x to "/Users/foo/file" as POSIX file -

AppleScript: Script to switch Caps Lock Key to Control

别来无恙 提交于 2019-12-06 15:44:37
I was trying to find a solution to this because I am using Vim and most of the time I need Caps lock to be assigned to Ctrl. There are times though that I want the Caps Lock working normally. I thought an Apple Script is great as it can be assigned to a LaunchBar action. I will answer with the solution I ended up with (through GUI scripting) but would be interested in a less intrusive solution if someone knows a way... You can use PCKeyboardHack to change caps lock to F19. Then save this as private.xml : <?xml version="1.0"?> <root> <item> <name>caps1</name> <identifier>caps1</identifier>

AppleScript variables passed to JavaScript

一笑奈何 提交于 2019-12-06 15:24:22
问题 I am storing text from TextEdit in an AppleScript variable, and I want to pass it to JavaScript. I thought I was doing it right, but I still can't get the value to be stored. The code is as follows: tell application "TextEdit" activate set docText to the text of the front document --This works. I've checked. end tell tell application "Google Chrome" tell window 1 tell active tab execute javascript "function encryptDocument() { plainText = '" & docText & "'; return plainText; } encryptDocument

Running python from VBA word and returning a value

微笑、不失礼 提交于 2019-12-06 15:15:17
Trying to figure out how to open python from word vba, on mac computers, and return a value using the code below. I need to be able to run this code from word vba without calling a specific python file, this will be run on multiple computers so I can't assume they have my premade python file downloaded. All I've seen is people calling a premade file with the script already in it. Here is my Python Code: import urllib2 web1 = urllib2.urlopen('website.com') #website url print(web1.read()) Any suggestions or links to a place that could help? Edit: Current Working Code myAppleScript = "do shell

Calling applescript from shell script using admin previleges

扶醉桌前 提交于 2019-12-06 15:04:32
问题 I'm running a shell script that runs an installation program (by ViseX) and selects different items in the installer through a list. The installer needs administrator privileges to run properly, but I don't want to use sudo. Currently the installation application does not work properly because it does not run with admin privileges. How do I call the applescript with admin privileges or tell the installation app inside the applescript to run as admin? Here's the applescript I'm using: