applescript

Cocoa Scripting: Returning “null” vs. “missing value”

时间秒杀一切 提交于 2019-12-08 00:21:40
问题 It appears that AppleScript knows the special value null . How do I return such a value from my Cocoa Scripting based app for a scriptable property? If I return nil ( NULL ) or NSNull for a scriptable property getter from my Cocoa Scripting-based app, the script editor interprets that as missing value . And if I return [NSAppleEventDescriptor nullDescriptor] , AppleScript even shows an error. 回答1: AppleScript uses a typeNull descriptor to indicate unassigned/no value, whereas missing value is

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

家住魔仙堡 提交于 2019-12-08 00:18:49
问题 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? 回答1: The path

Search Outlook contacts by category

可紊 提交于 2019-12-08 00:05:47
问题 Is there a way to search for Contacts in Outlook 2011 for the Mac by Categories? tell application "Microsoft Outlook" -- get the category by name set theCategory to item 1 of (every category whose name = "Recruiter") -- correctly displays 'Recruiter [25]' display dialog (name of theCategory) & " [" & (id of theCategory) & "]" -- perform the search (incorrectly, it seems) set theContacts to (every contact whose (every category contains theCategory)) -- should display ~100; actually displays 0

Get modifier keys, which have been pressed while starting an app / applescript

元气小坏坏 提交于 2019-12-07 22:50:00
问题 I need to get a list of keys (e.g. the shift key, alt, command ...) which have been pressed when i started an app, especially an ApplesScript on Mac OS X. 回答1: A shorter form of Mike Woodfill's answer: set {shiftDown, ctrlDown, altDown, cmdDown} to words of (do shell script "python -c 'import Cocoa;m=Cocoa.NSEvent.modifierFlags();print m&Cocoa.NSShiftKeyMask>0,m&Cocoa.NSControlKeyMask>0,m&Cocoa.NSAlternateKeyMask>0,m&Cocoa.NSCommandKeyMask>0'") Note, that you get the modifiers as strings, so

Redirect microphone input to headphone output (soft playthru)

对着背影说爱祢 提交于 2019-12-07 22:48:18
问题 If I use my in-ear headphones with my macbook pro it takes me a few minutes until they are fitting perfectly (due to the foam bits on the headphones) :) My idea is to use internal macbook pro microphone to be able talk to somebody coming to my desk without having to remove the headphones every time. So kind of an 'intercom' thing which can be enabled by hitting a hotkey. First thought was to use applescript which could be easily used for pausing iTunes, but I could not find information about

How do I remove a build configuration from an Xcode project from a script?

左心房为你撑大大i 提交于 2019-12-07 20:42:25
I'm currently using AppleScript to clean up an Xcode project. I'd like my script to remove some build configurations that won't be relevant to other developers on my team. For example, if I have "Debug", "DebugTest", and "Release", I would like the script to remove "DebugTest". I'm currently using the following script: tell application "Xcode" open myXcodeProject set targetProject to project of active project document set targetConfigurations to build configurations of targetProject repeat with c in targetConfigurations if (name of c is equal to "DebugTest") then delete c end if end repeat end

How & where to best retrieve sudo password via a native GUI on a macOS Python-based app - (while maintaining an interactive output stream (stdout))

狂风中的少年 提交于 2019-12-07 20:18:35
问题 Ok, so the situation is this: I am building a macOS GUI App using Python and wx (wxphoenix). The user can use the GUI (say: script1 ) to launch a file-deletion process (contained in script2 ). In order to run successfully script2 needs to run with sudo rights. script2 will itterate over a long list of files and delete them. But I need it to communicate with the GUI contained in script1 after each round so that script1 can update the progressbar. In it's absolute most basic form my current

AppleScript - JavaScript execution on Firefox

£可爱£侵袭症+ 提交于 2019-12-07 19:58:31
问题 Safari and Chrome can execute JavaScript via AppleScript Safari: tell application "Safari" open location "http://example.com" activate do JavaScript "alert('example');" in current tab of first window end tell Chrome: tell application "Google Chrome" open location "http://example.com" activate execute front window's active tab javascript "alert('example');" end tell Is there a way to do this in Firefox? Note: Same question for Opera is here: AppleScript - JavaScript execution on Opera I

AppleScript : find open tab in safari by name and open it

与世无争的帅哥 提交于 2019-12-07 19:46:15
问题 I'm looking for a way to find if a webpage its open from all the opened tab, and if so, focus this tab. I tried this code but obviously this is not working at all. set closeURLs to {"http://www.yahoo.com"} repeat with theURL in closeURLs tell application "Safari" to open (every tab of every window whose URL contains (contents of theURL)) end repeat UPDATE : I find it : http://protips.maxmasnick.com/applescript-to-find-fastmail-tabs-in-safari 回答1: Found an excellent script at Find Safari Tabs

Applescript | Javascript - Click on Link using Javascript?

徘徊边缘 提交于 2019-12-07 18:31:25
I am trying to get applescript to click on the (link), I have posted the code below, i have tried many ways but i am unable to get it work. Also the link is different every time so i cant just copy that link into it. Thanks in advanced! Also This is all the code to do with it (I think) i want it to click on the date of last upload: (Link) <div class="span4 offset1"> <ul class="unstyled"> <li>Monthly Views: <strong class="pull-right"><a href="#" class="data-na" data-original-title="" title="">NA</a></strong></li> <li>Daily New Views: <strong class="pull-right">18,830</strong></li> <li>Daily New