苹果脚本- Send SMS to Messages and run commands with AppleScript

通过AppleScript设置iMessages接收特定命令,实现远程控制Mac使用Photo Booth静默拍照,并通过Dropbox查看照片。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

It is possible to send an SMS command to your Mac using an AppleScript. I've made one which takes a picture when I send the command /photo to iMessages on my Mac. 

The script is very simple; it must be set up Messages' Alerts preferences. Choose Event > Message Received, then check Run an Apple Script. This will check each message you get for the command; in this case, /photo. 

The script will turn the volume all the way down (and up again) before taking a picture with PhotoBooth so it does not make any noise. 

Then you can make a symbolic link from the PhotoBooth folder to your Dropbox so you can check the photos from your mobile device. 

Here's the script:
using terms from application "Messages"
	on message received theMessage from theBuddy for theChat
		
		if (theMessage begins with "/") then
			
			if theMessage begins with "Photo" then
				beep 3
			else
				set volume 0
				
				tell application "Photo Booth"
					
					activate
					
				end tell
				
				tell application "System Events"
					
					tell process "Photo Booth"
						
						delay 3
						tell application "Finder"
							set visible of process "Photo Booth" to false
						end tell
						tell menu bar 1
							
							tell menu bar item "File"
								
								tell menu "File"
									
									click menu item "Take Photo"
									
								end tell
								
							end tell
							
						end tell
						
					end tell
				end tell
				delay 5
				tell application "Photo Booth"
					quit
				end tell
				set volume 3
			end if
			
		end if
		
	end message received
	
end using terms from

[kirkmc adds: Note that this only works with iMessages (I tried for a while to get it to work with regular chats, and it wouldn't). It's worth noting that the ability to send a text message and set off a script is something very useful, and I can imagine plenty of scripters figuring out other types of remote commands they can send to their Macs. Feel free to submit them as hints.]
    •     
### 回答1: 错误:未知选项“--inline”[webpack-cli]运行“webpack --help”以查看可用的命令和选项。 这个错误提示是因为在运行webpack命令时使用了未知的选项“--inline”,建议运行“webpack --help”命令查看可用的命令和选项。 ### 回答2: 这段报错信息说明在执行webpack命令时,出现了未知的选项"--inline"。在执行webpack命令时,需要遵循一定的语法格式和选项设置,如果出现了未知的选项,就会出现这种报错。 为了解决这个问题,需要先了解webpack命令的语法格式和常见的选项设置。在执行webpack命令时,通常的语法格式为: webpack [entry] [output] 其中,[entry]表示入口文件路径,[output]表示输出文件路径。在这个基本的语法格式上,可以添加一些选项,用于对webpack进行更加精细的配置。常见的选项包括: --config:指定webpack配置文件路径 --mode:指定webpack的工作模式,有"development"、"production"和"none"三种可选 --watch:实时监测文件变化,自动打包 --devtool:指定source map的生成方法 --module-bind:指定模块解析规则 --output-path:指定输出文件夹路径 如果在执行webpack命令时,添加了一个未知的选项,就会出现这种报错。在这种情况下,可以通过执行"webpack --help"命令,查看可用的命令和选项。在正确使用命令和选项后,就可以成功执行webpack命令,完成文件打包工作。 总之,通过了解webpack命令的语法格式和常见选项,可以避免出现这种报错。在出现这种报错时,需要检查命令是否正确,是否添加了未知的选项,以及是否遵循了语法格式的要求。 ### 回答3: 这个提示意味着在执行Webpack命令时,出现了不能识别的选项"--inline"。Webpack是一个流行的前端构建工具,它为开发人员提供了许多命令和选项来构建和打包他们的应用程序。 错误消息建议您运行Webpack --help以查看可用的命令和选项。通过运行Webpack --help命令,您将看到Webpack支持的所有命令和选项的列表。您可以通过查看该列表,定位并排除引起错误的选项,并使用正确的选项和参数重新运行Webpack命令。 在这个特定的错误中,--inline不是Webpack支持的选项。这可能是由于版本不匹配或错字造成的拼写错误等,因此需要重新检查您的Webpack脚本,并确保正确设置了选项。 在Webpack中,--inline选项用于启用webpack-dev-server的“inline mode”,该模式会自动将客户端脚本注入到最终生成的JavaScript文件中。如果您需要在开发过程中使用这个选项,需要将Webpack及其所有依赖项升级到最新版本并针对您的应用程序进行必要的配置。 总之,当您在使用Webpack时遇到类似的错误消息时,需要仔细检查您的Webpack脚本并根据错误消息重新设置选项和参数来避免这些错误。同时,查看Webpack官方文档和社区资源,了解如何正确配置Webpack。这将有助于您轻松构建和打包前端应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值