intellectual
V2EX  ›  macOS

AppleScript 问题需要帮助。三个程序中 ps , ai , sketch 如果一个启动,则程序 breaktime 启动计时器。否则停止计时器。

  •  
  •   intellectual · Mar 29, 2017 · 1667 views
    This topic created in 3348 days ago, the information mentioned may be changed or developed.

    breaktime 是一个强制休息的 app 。 里面的计时器启动后,时间够了,进入锁屏状态,强行休息。 可以在计时器启动和结束的时候运行 AppleScript 。 网站是http://breaktimeapp.com/

    我不是程序,也不懂 AppleScript 我猜里面的代码实现起来应该是 if esle 就能搞定,问题就是起码中文社区找不到文档。

    我写成这样了,然后卡住了,当然里面的 running 参数是不对的。

        tell application "BreakTime"
        	
        	if application "Sketch" running or application "Adobe Photoshop CC 2017" running or application "Adobe Illustrator" running then
        	else
        		enabled
        	end if
        
        end tell
    

    下面这个是 breaktime 的一个 AppleScript ,循环启动停止计时器

    tell application "BreakTime"
    	
    	if true then
    		
    	end if
    	
    	
    	set enabled to not enabled
    	
    end tell
    

    满好用的,大家可以试试看

    3 replies    2017-03-30 16:42:14 +08:00
    intellectual
        1
    intellectual  
    OP
       Mar 29, 2017
    哎呀错了,第二个 as 没有 if then
    minamike
        2
    minamike  
       Mar 29, 2017   ❤️ 1
    repeat
    if application "Sketch" is running or application "Adobe Photoshop CC 2017" is running or application "Adobe Illustrator" is running then
    tell application "BreakTime" to set enabled to true
    else
    tell application "BreakTime" to set enabled to false
    end if
    end repeat

    保存为 application 然后一直开着就可以了
    intellectual
        3
    intellectual  
    OP
       Mar 30, 2017
    @minamike 好厉害,编写代码改变世界啊,赞一个
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   924 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 19:27 · PVG 03:27 · LAX 12:27 · JFK 15:27
    ♥ Do have faith in what you're doing.