osascript

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

What are error -10004 and error -10000 in Applescript

徘徊边缘 提交于 2019-12-06 08:11:24
问题 I have an Applescript that is working on my computer, but not on my colleague's. I get two errors when manipulating paths: -10004 and -10000 . I have an idea on how to solve this, but first I'd like to understand those error codes. Here is the script (I removed useless part, the full version is on github): -- export all layers to image files -- Settings property exportFileExtension : "png" property ADD_CANVAS_NUMBER : true -- End of Settings on file_exists(FileOrFolderToCheckString) try alias

AppleScript that reads active application name, title and URL

北城余情 提交于 2019-12-06 06:04:04
I need AppleScript that, when lunched from command line, will return three things: current active application name; ex. "Google Chrome", "Safari", "Steam", "iTunes", "Atom" ect. current active application title, if there is one if current active application is a browser, I want the current active tab URL examples: Google Chrome; AppleScript: How to get URL of Safari tab which failed to load? - Stack Overflow; https://stackoverflow.com/ iTunes; iTunes iTerm2; 1. node test.js (sleep) Safari, GitHub - rails/rails: Ruby on Rails; https://github.com/rails/rails I know there are some similar

How to display modal window using osascript or AppleScript in OS X

二次信任 提交于 2019-12-04 14:49:21
How to display modal(over all apps, windows) window using osascript or AppleScript in OS X 10.6.8 and later. Here a script I do: #!/bin/bash osascript -e 'tell app "System Events" to display dialog "My Dialog" buttons {"OK"} default button 1 with title "My Dialog" with icon caution' The problem is that it's not modal. How to fix the following issue? I wrote a script recently to monitor my macbook battery when it got low. To make sure I didn't miss the alert I did the following... repeat while true me activate set userResp to display dialog ¬ "Yes or No?" as text buttons {"No", "Yes"} ¬ default

What are error -10004 and error -10000 in Applescript

家住魔仙堡 提交于 2019-12-04 13:01:39
I have an Applescript that is working on my computer, but not on my colleague's. I get two errors when manipulating paths: -10004 and -10000 . I have an idea on how to solve this, but first I'd like to understand those error codes. Here is the script (I removed useless part, the full version is on github ): -- export all layers to image files -- Settings property exportFileExtension : "png" property ADD_CANVAS_NUMBER : true -- End of Settings on file_exists(FileOrFolderToCheckString) try alias FileOrFolderToCheckString return true on error return false end try end file_exists tell application

Applescript (osascript): opening split panes in iTerm 2 and performing commands

回眸只為那壹抹淺笑 提交于 2019-12-04 03:03:31
The following works to open two tabs in iTerm 2 . I can't seem to figure out how to get this to using split panes instead. I've tried applying what I see on several forums, but it never works. Could someone point me in the right direction? osascript <<-eof tell application "iterm" set myterm to (make new terminal) tell myterm launch session "Default session" tell the last session set name to "Server" write text "cd $projectsFolder" end tell launch session "Default session" tell the last session set name to "Console" write text "cd $projectsFolder" end tell end tell end tell eof With the new

Pass in variable from shell script to applescript

若如初见. 提交于 2019-12-01 03:10:44
I've got a shell script that I call that uses osascript , and that osascript calls a shell script and passes in a variable that I've set in the original shell script. I don't know how to pass that variable in from the applescript to shell script. How can I pass in a variable from shell script to applescript to shell script...? Let me know if I don't make sense. i=0 for line in $(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'); do UDID=${line} echo $UDID #i=$(($i+1)) sleep 1 osascript -e 'tell application

How do you run inline Applescript from a JXA/JavaScript for Automation script on macOS?

泄露秘密 提交于 2019-12-01 01:45:03
I have a script written in JavaScript which needs to run one small piece of AppleScript (to achieve some functionality I've been unable to implement due to a number of factors natively in JS). It should be able to take a single string argument, and is pretty much a tell-endtell one liner. Is it possible to assemble this nanoprogramme as a string in JavaScript then pass the string to the AppleScript environment for execution, and how would that be done? There's plenty of explanations online about how to run JavaScript from Applescript, but not as much coming the other way. Would this - in all

Can't do shell script with a repeat with i from 1 to n loop

三世轮回 提交于 2019-11-30 23:46:47
This works (prints, for example, “3 arguments”): to run argv do shell script "echo " & (count argv) & " arguments" end run This doesn't (prints only “Argument 3: three”, and not the previous two arguments): to run argv do shell script "echo " & (count argv) & " arguments" repeat with i from 1 to (count argv) do shell script "echo 'Argument " & i & ": " & (item i of argv) & "'" end repeat end run In both cases, I'm running the script using osascript on Mac OS X 10.5.5. Example invocation: osascript 'Script that takes arguments.applescript' Test argument three I'm not redirecting the output, so

Pass in variable from shell script to applescript

喜欢而已 提交于 2019-11-30 23:17:49
问题 I've got a shell script that I call that uses osascript , and that osascript calls a shell script and passes in a variable that I've set in the original shell script. I don't know how to pass that variable in from the applescript to shell script. How can I pass in a variable from shell script to applescript to shell script...? Let me know if I don't make sense. i=0 for line in $(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk