applescript

Applescript Check Whether Password is Correct

末鹿安然 提交于 2019-12-11 06:30:00
问题 I am making an app that requires root privileges. I am new to applscript and apologize if this is a dumb question but what I am trying to do is check whether a password is correct. I get the password string from a prompt like this: set thePass to the text returned of (display dialog "I need you to enter your password" default answer "" buttons {"Okay"} default button 1 with icon file ((path to resource "Icon.icns") as text) with hidden answer) I need to check whether thePass is actually their

Compile AppleScript into application with parameters

与世无争的帅哥 提交于 2019-12-11 05:47:58
问题 There is an AppleScript method: on displayError(theErrorMessage) display dialog theErrorMessage return "done" end displayError I wanna compile this script with passing parameter into (not run it with osascript!) My_Application.app something like osacompile - o My_Application.app My_Script.applescript "This is error message as parameter" In this case, I will have compiled app which I can run. Looking for a command on how exactly to compile the script with passing parameters. As compilation

Applescript 10.7:Can’t get anchor “FileVault” of pane id “com.apple.preference.security”

不羁岁月 提交于 2019-12-11 05:47:43
问题 I am trying to access the "FileVault" Tab using Applescript. Can someone help me out? This is where I am getting the error: reveal anchor "FileVault" of pane id "com.apple.preference.security" 回答1: For some reason, the anchor has a different name internally: tell application "System Preferences" get every anchor of pane id "com.apple.preference.security" --> {anchor "Firewall" of pane id "com.apple.preference.security", anchor "FDE" of pane id "com.apple.preference.security", anchor "General"

Save Excel sheets as HTML

亡梦爱人 提交于 2019-12-11 05:20:04
问题 I'm attempting to save each sheet in a workbook ( foo , bar , baz ) as a separate HTML document ( foo.html , bar.html , baz.html ): set theDirectory to (path to desktop as text) & "Output:" set theSource to choose file with prompt "Choose file:" default location "/Users/<user>/Desktop/" of type {"XLS", "XLSX"} tell application "Microsoft Excel" activate set theWorkbook to open theSource set theSheets to every sheet of active workbook repeat with theSheet in theSheets set theDestination to

AppleScript: “use framework” errors out in “Expected end of line, etc. but found identifier.”

≯℡__Kan透↙ 提交于 2019-12-11 05:16:54
问题 I have the following piece of AppleScript. use framework "Foundation" display dialog "foo" Note: the Foundation framework is not actually used in this example, because that part of the code is irrelevant for this example. This code alone already produces the error. In real life, we obviously only import a framework to use it, duh :-) When I run this I get the unhelpful error: Expected end of line, etc. but found identifier. The identifier on which the macOS Script Editor stops is "dialog".

Delete multiple files with applescript

断了今生、忘了曾经 提交于 2019-12-11 05:06:07
问题 Let’s say I have multiple files I want to delete, and they’re stored one per line in a files.txt file. I can delete them with set deleteThis to paragraphs of (read "files.txt") repeat with lineFromFile in deleteThis set fileName to POSIX file lineFromFile tell application "Finder" to delete file fileName end repeat This is the logic you usually find online — deleting them one by one, but not only does this screw your “Put Back” option (you have to ⌘ z multiple times), it also plays the trash

Is Applescript processing new folders that are created in the moment the script runs?

泪湿孤枕 提交于 2019-12-11 04:41:29
问题 I am working on a script that duplicates folders from an afp share to a local folder and does all kind of things with those folders afterwards. (it deletes the original folders after duplicating) This code is working fine: tell application "Finder" duplicate every folder of folder afpFolder to localFolder with replacing delete every folder of folder afpFolder end tell My problem is that our employees will be adding new folders to afpFolder regulary and quite often. My script is running every

How to open Firefox in Full Screen mode?

白昼怎懂夜的黑 提交于 2019-12-11 04:39:43
问题 I need to open Firefox on a Mac running Lion in Full Screen mode to act as a kiosk. I was using the R-Kiosk 0.9.0 Firefox Add-on; but, it conflicts with a print javascript I am also running, so I can't use it. Anyone know a way to accomplish this? either with an add-on or, perhaps, with AppleScript? Could an AppleScript be triggered to run when Firefox is opened? 回答1: This should do it: activate application "Firefox" delay 2 tell application "System Events" tell process "Firefox" click menu

Applescript use google chrome to extract text

倖福魔咒の 提交于 2019-12-11 04:27:53
问题 I'm extracting text from a page on safari, everything work fine, However I can't adapt this script to Google Chrome Here is the Safari code to getInputByClass2(theClass, num) tell application "Safari" set input to do JavaScript " document.getElementsByClassName('" & theClass & "')[" & num & "].innerHTML;" in document 1 end tell return input end getInputByClass2 Here is the Chrome code to getInputByClass2(theClass, num) tell application "Google Chrome" set input to do JavaScript " document

applescript click menu bar option

夙愿已清 提交于 2019-12-11 04:21:09
问题 I want to create an AppleScript to click a menu but I can't what ever the script I using, here is the menu I want : ELEMENT : Role : menu item Title: "sign in As..." Description : Help: Application: SytemUIServer ELEMENT PATCH (starting at leaf element): menu Item "Sign in As..." (menu item 12) menu (menu 1) menu extra (menu bar item 2) menu bar (menu bar 1) application "SystemUIServer" So I did a few script, the last one was ignoring application responses tell application "System Events" to