Applescript timer increasing

Discussion in 'Mac Programming' started by traisjames, Sep 19, 2013.

  1. traisjames macrumors newbie

    Joined:
    Jul 19, 2012
    #1
    I am running an applescript which uses "Delay" for certain pauses between clicking links on a website. The script works fine, however with each time in a repeat loop, "delay 5" takes longer and longer...becoming 10 seconds then 20 seconds (estimations). Anyone experiencing this? One unique thing is I am using 10.9.
     
  2. Big Dave macrumors 6502

    Joined:
    Nov 27, 2007
    Location:
    Crestview, Fl
    #2
    If you are scripting a web page then there is a better tool than automator. Look into imacros for firefox. Automater has a tendancy to slow down when you loop.
     
  3. traisjames thread starter macrumors newbie

    Joined:
    Jul 19, 2012
    #3
    Will iMacros allow for tabbing thru to find a link, click on it, then paste text, and finally click a button you can't tab to?

    Below is my code. Any suggestions would help.

    Code:
    set strokecount to 10
    set namecount to 0
    tell application "TextEdit" to activate
    tell application "System Events"
    	keystroke "a" using command down
    	delay 0.2
    	keystroke "c" using command down
    	delay 0.2
    end tell
    
    tell application "Safari" to activate
    delay 0.2
    tell application "System Events"
    	(*setup*)
    	repeat 10 times
    		beep
    		tell application "Safari" to activate
    		repeat strokecount times
    			keystroke tab
    			delay 0.1
    		end repeat
    		
    		tell application "Safari" to activate
    		log namecount
    		repeat (namecount * 2 + 1) times
    			keystroke tab using option down
    			delay 0.1
    		end repeat
    		
    		delay 1
    		tell application "Safari" to activate
    		keystroke return
    		delay 5
    		keystroke "v" using command down
    		delay 1
    		keystroke tab
    		delay 1
    		key code 125 (*down key*)
    		delay 2
    		do shell script "/usr/local/bin/cliclick c:483,760"
    		delay 6
    		key code 53
    		delay 3
    		set namecount to namecount + 1
    		
    	end repeat
    	display dialog "Done" buttons {"OK"} default button 1
    end tell
     
  4. ajm200500 macrumors newbie

    Joined:
    Oct 31, 2013
    #4
    its ****ing up for me too!

    so im trying to code an auto typer for an mmorpg i play, and i put a delay of 3 after each entering of the text i am saying. well after about a dozen or so messages being said, it (dramatically) increases the delay, to around 9 seconds or so. my question is simply: why in ****ing hell does it take 9 seconds to do something that has a delay of only 3??? it works fine for the first while, but then it acts as though i had changed the delay to around 9 or so... any help would be appreciated. post here or email me at alex.marciniak70@gmail.com
     
  5. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #5
    I've noticed this annoying behaviour too on OS X Mavericks. The only thing to do is make Apple aware of this issue by filling a bug report.

    Info : https://bugreport.apple.com/
     
  6. DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #6
    For making bots an applescript aint so good.
    If you really want to stay on the applescript, you should consider using your task scheduler to perform your script every amount of time instead.

    Because your applescript will be in an endless repeat? With all the delays its making an huge memory dump after a while because applescript leaks memory in delays. Thats why your delays are taking longer and longer. At first sight you wont notice (depending on your ram) but as you notice after a longer time it will :)
     
  7. StudentRotterda macrumors newbie

    Joined:
    Feb 18, 2014
    #7
    Interim Solution

    Have had the same issue since I updated to Mavericks. It occurred after only a few loops and on menial tasks, so it does not seem memory related.

    For the time being I'm using the following workaround (just copy and paste the into your AppleScript and adjust the time as you would within Applescript Editor):

    do shell script "sleep 0.1s"

    See the following page for other options (e.g., instead of "s" for seconds you can use "h" for hours, "d" for days):
    http://en.wikipedia.org/wiki/Sleep_(Unix)
     

Share This Page