Page 1 of 2 12 LastLast
Results 1 to 15 of 26

Thread: Auto Clickers

  1. #1
    Auto Clickers
    I have a little Apple-Script Auto Clicker:

    on idle
    tell application "System Events"
    key code 87
    end tell
    return 20
    end idle

    It works, but I would like to make the interval more random, say, a number between 20-25

    Can anyone help me with this? Or am I in the wrong area?

  2. #2
    Auto Clickers
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    12,329
    Rep Power
    24
    Modify your AppleScript to something like this
    Code:
    on idle
      delay (random number from 20 to 25)
      tell application "System Events"
        key code 87
      end tell
      return 20
    end idle
    --
    Regards
    ...Ashwin


  3. #3
    That seems to have done it. Thank you very much.

  4. #4
    Auto Clickers
    Slydude's Avatar
    Member Since
    Nov 16, 2009
    Location
    North Louisiana, USA
    Posts
    14,754
    Your Mac's Specs
    2.8 GHz 2008 MacBook Pro 10.11, 8 GB mem, iPhone XS, 2015 iMac 16 GB 10.14.4 beta
    Rep Power
    25
    @Raz0rEdge I understand about 99% of the script but for my own edification what does the line return 20 do?

    Notice the $50.00 word in that sentence just to prove I'm not an idiot? lol
    “Hard work beats talent when talent fails to work hard.”
    Kevin Durant

  5. #5
    Auto Clickers
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    12,329
    Rep Power
    24
    Sly, in this the script is just returning 20 at the end. Traditionally, scripts return 0 to indicate success and non-zero to indicate failure.
    --
    Regards
    ...Ashwin


  6. #6
    Auto Clickers
    Slydude's Avatar
    Member Since
    Nov 16, 2009
    Location
    North Louisiana, USA
    Posts
    14,754
    Your Mac's Specs
    2.8 GHz 2008 MacBook Pro 10.11, 8 GB mem, iPhone XS, 2015 iMac 16 GB 10.14.4 beta
    Rep Power
    25
    I get that the script is just returning 20 at the end. So, in this case, its being used as an indicator for whether the script finished successfully?

    I really need to find that AppleScript book I bought ages ago. Probably should just buy a new one. That was ages ago.
    “Hard work beats talent when talent fails to work hard.”
    Kevin Durant

  7. #7
    Auto Clickers
    pm-r's Avatar
    Member Since
    Oct 16, 2010
    Location
    Brentwood Bay, BC, Canada
    Posts
    12,564
    Rep Power
    20
    I really need to find that AppleScript book I bought ages ago. Probably should just buy a new one. That was ages ago.

    Maybe it's in with the books on HyperStacks and hyper script…




    Patrick
    =====

  8. #8
    Auto Clickers
    Slydude's Avatar
    Member Since
    Nov 16, 2009
    Location
    North Louisiana, USA
    Posts
    14,754
    Your Mac's Specs
    2.8 GHz 2008 MacBook Pro 10.11, 8 GB mem, iPhone XS, 2015 iMac 16 GB 10.14.4 beta
    Rep Power
    25
    Used to have a few of those. I think they now reside with that collection of Microsoft Office manual that took up half a storage shelf. That included an entire book on the Excel macro language. Of course that was in the day when you actually got a paper manuals.
    “Hard work beats talent when talent fails to work hard.”
    Kevin Durant

  9. #9
    Auto Clickers
    chscag's Avatar
    Member Since
    Jan 23, 2008
    Location
    Keller, Texas
    Posts
    59,549
    Your Mac's Specs
    2017 27" iMac, 10.5" iPad Pro, iPhone 7+, iPhone 8, Numerous iPods, Catalina
    Rep Power
    55
    Of course that was in the day when you actually got a paper manuals.
    LOL, what are those? I still have my original MS-DOS 6 manual sitting on the shelf along with my Powerpoint manual.

  10. #10
    Auto Clickers
    Slydude's Avatar
    Member Since
    Nov 16, 2009
    Location
    North Louisiana, USA
    Posts
    14,754
    Your Mac's Specs
    2.8 GHz 2008 MacBook Pro 10.11, 8 GB mem, iPhone XS, 2015 iMac 16 GB 10.14.4 beta
    Rep Power
    25
    After that version of Office with the half shelf of manuals the next version had all the documentation on CD. I hated that. The CD severely damaged the "stumble upon the answer" factor when it came to the macro language. Oftentimes I'd start with one function in mind as the solution to a problem and after searching the manual found that a related function solved the problem.

    PDF-based manuals have almost brought back the stumble upon it factor for me but not quite.
    “Hard work beats talent when talent fails to work hard.”
    Kevin Durant

  11. #11
    Auto Clickers
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    200
    Rep Power
    9
    Sorry to correct you RazOrEdge, but the return number in an AppleScript on idle handler, is the number of seconds before the on idle handler runs again.
    In the case of the posted code, the on idle handler runs every 20 seconds.

    Regards Mark

  12. #12
    Auto Clickers
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    12,329
    Rep Power
    24
    Thanks for the clarification Mark, I did't research the entire script, just figured out the random number part.. Being more familiar with BASH programming, I just assumed it was that, but you are indeed correct with the purpose of the return there.
    --
    Regards
    ...Ashwin


  13. #13
    Auto Clickers
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    200
    Rep Power
    9
    I'm glad you took it gracefully, I never liked to correct such a knowledgable contributor on developer forums.

    Yeah the Applescript on idle handler is a very unique method.
    It's effectively a repeat loop, but allows the user to interact with the rest of the applet, unlike a endless repeat loop which would not.
    For the record, the on idle handler has to be in a saved AppleScript application in order to function, and won't run in a plain text AppleScript.

    Regards Mark

  14. #14
    Auto Clickers
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    12,329
    Rep Power
    24
    No worries Mark, we all have something to learn and can't be experts in everything. Your posts in this sub-forum are very useful, thus the reason I moved this post here to begin with..
    --
    Regards
    ...Ashwin


  15. #15
    Auto Clickers
    Slydude's Avatar
    Member Since
    Nov 16, 2009
    Location
    North Louisiana, USA
    Posts
    14,754
    Your Mac's Specs
    2.8 GHz 2008 MacBook Pro 10.11, 8 GB mem, iPhone XS, 2015 iMac 16 GB 10.14.4 beta
    Rep Power
    25
    Thanks Mark FX. Makes perfect sense to me. Thanks for the clarification guys.
    “Hard work beats talent when talent fails to work hard.”
    Kevin Durant

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. auto correct
    By decoman in forum macOS - Operating System
    Replies: 1
    Last Post: 02-08-2011, 08:08 PM
  2. Replies: 0
    Last Post: 07-11-2010, 01:16 PM
  3. Auto Typer
    By Jack8784 in forum macOS - Apps and Games
    Replies: 3
    Last Post: 05-07-2010, 08:46 AM
  4. Auto Update
    By Dalek8325 in forum macOS - Operating System
    Replies: 4
    Last Post: 08-30-2009, 08:21 AM
  5. Auto-audio
    By K4ndere in forum Switcher Hangout
    Replies: 7
    Last Post: 06-02-2008, 03:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •