Is this possible with Applescript?

Discussion in 'Mac Programming' started by aaricwon, Nov 17, 2015.

  1. aaricwon macrumors newbie

    Joined:
    Nov 17, 2015
    #1
    I work at a small shop and one of the things we do is buy used Apple iPhones and iPads. When we buy phones we HAVE to check the imei the make sure it is clear. That can be done at www.swappa.com/esn. You just go there and enter the imei

    I am just learning Applescript. Is it possible to use it to build an application that prompts a simple popup where you type in the imei number and it searches it on https://swappa.com/esn/ giving you the results page as if you had opened your browser, gone to https://swappa.com/esn/, typed in the imei and hit submit?

    Basically, someone brings in a phone, I click the icon on my desktop for my application and a popup comes up asking for a imei. I enter 354897068216747 and click submit and then it opens the web browser showing me the results (if that is a clean imei).

    Is something liike this possible? Can someone point me towards some tutorials or in the right direction?
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    It's possible, but it'd be a clunky, rather nasty solution.

    Directly automating the web page would probably need you to use GUI Scripting (http://www.macosxautomation.com/applescript/uiscripting/). In effect, it simulates the clicks and mouse movements of a real user. It's being a bit of a pain to work with, and assuming you get it working then the tiniest change to the web page can cause it to fail. Personally I avoid GUI scripting like the plague for that reason. NB. Depending on your OS you may need to enable GUI scripting this way instead: http://www.tekrevue.com/how-to-enable-access-for-assistive-devices-in-os-x-mavericks/

    A better idea would be to have a hunt around and see if you can find a different site that offers the same kind of service but with some kind of api/web service. That would let your AppleScript get at the info you need and display it in a manner that you get to dictate.



    Hope that's of some help!
     
  3. 0d085d macrumors regular

    Joined:
    Apr 23, 2015
    #4
    If all you want is basically a shortcut to that swappa.com webpage then you just need to get Applescript to open
    https://swappa.com/esn/results?esn=... having asked you for the IMEI.

    A script for that would be something like:

    Code:
    display dialog "Enter IMEI number" default answer "000000000000000"
    set imei_num to text returned of result
    set url_to_open to "https://swappa.com/esn/results?esn=" & imei_num
    tell application "Safari"
        activate
        open location url_to_open
    end tell
     
  4. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #5
    Nice! I didn't spot that you could do that on their site.
     
  5. aaricwon thread starter macrumors newbie

    Joined:
    Nov 17, 2015
    #6
    I am going to try it out now. Thanks!
     
  6. aaricwon thread starter macrumors newbie

    Joined:
    Nov 17, 2015
    #7
    That worked perfectly!
    I wish I could do that with the page that checks if a phone has iCloud lock but that page has captcha on it
     

Share This Page