applescript

Mounting an SMB drive via AppleScript

做~自己de王妃 提交于 2019-12-06 11:42:08
问题 I've written and AppleScript App that runs a "mount -t smbfs " command to mount a Windows Shared drive that our Staff use. The App has been used successfully for a number of months until today. If a user has an @ symbol in their password the application fails. The path is rejected. Here's the script: -- Teaching Drive Access --Get The Shortname and PC Password of current user --set PCusername to (short user name of (system info)) set PCusername to "benstaff" --set PCPassword to text returned

AppleScript - JavaScript execution on Firefox

[亡魂溺海] 提交于 2019-12-06 11:30:43
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 thought about asking them together, but I decided to ask two separate questions to be able to accept answers

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

六月ゝ 毕业季﹏ 提交于 2019-12-06 11:22:24
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. AppleScript uses a typeNull descriptor to indicate unassigned/no value, whereas missing value is represented by a typeType descriptor of cMissingValue . (It's analogous to the undefined vs null mess in

How to check is Chrome is running in incognito mode using Applescript?

[亡魂溺海] 提交于 2019-12-06 10:48:58
问题 Is it possible to find out if the Chrome is running in incognito mode? if application "Google Chrome" is running then tell application "Finder" to display dialog "Chrome is running" // --> some condition here to check if it is in incognito ? tell application "Finder" to display dialog "Chrome is running in INCOGNITO mode" end if Also, I want this script to keep running. That means as soon as user opens Chrome in incognito mode I will show alert. Like this: set chromeRunning to false repeat

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-06 10:40:00
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 working setup looks like this: Script1: import io from threading import Thread import subprocess import wx

Change Applescript into single line NSApplescript source

℡╲_俬逩灬. 提交于 2019-12-06 10:36:27
Im building an app for learning purposes of using applescript to send multiple commands during an action. Below is the code I'm messing with but I have stripped out the actions in between the "" and replaced them with numbers. Everything works fine in applescript but making this into an NSApplescript initwithsource: line has been a bother. tell application "Terminal" activate set currentTab to do script "1" do script "2" in currentTab do script "3" in currentTab do script "4" in currentTab delay 0.5 tell application "Finder" to set visible of process "Terminal" to false end tell What is the

Looking for a terminal command to parse MacOSX dictionary data file

廉价感情. 提交于 2019-12-06 09:40:29
问题 Problem MacOSX comes with dictionaries stored in /Library/Dictionaries . I would like to parse them to obtain dictionary results programmatically (via Terminal, AppleScript, or Automator). The dictionaries are MacOSX packages and all have a Contents folder that contains a file called Body.data . I would like to parse that file for a UTF-8 string (maybe Chinese character double bytes) and return the lines where the string is found. I've tried the following, which is not returning any results:

Execute Applescript from Cocoa App with params

帅比萌擦擦* 提交于 2019-12-06 09:22:04
问题 I would like to know how to execute an applescript from a cocoa application passing parameters. I have seen how easy is to execute applescripts with no parameters in other questions here at stackoverflow, however the use NSAppleScript class, in which, i haven't seen no method that solve my problem. Does anyone have any idea. I would like a Cocoa code with the same effect o this shell: osascript teste.applescript "snow:Users:MyUser:Desktop:MyFolder" "snow:Users:MyUser:Desktop:Example:" So it

Delete files with AppleScript to recycle bin or permanently

白昼怎懂夜的黑 提交于 2019-12-06 08:35:24
问题 I'm writing an AppleScript in which I want to insert a subroutine to delete specified files. With a flag I wish to control whether the given file is moved to the recycle bin or deleted permanently. Actually my script looks like this: on MyDeleteProc(theFile, allowUndo) if allowUndo then tell application "Finder" to delete POSIX file theFile else do shell script "rm " & theFile end if end MyDeleteProc Now I want to know if this case is correct so far or is there maybe another Finder command or

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

喜夏-厌秋 提交于 2019-12-06 08:28:54
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 Found an excellent script at Find Safari Tabs with AppleScript . If multiple tabs match the user input text, it shows a list of matching tabs and allows