Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

aaricwon

macrumors newbie
Original poster
Nov 17, 2015
7
0
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?
 
Is something liike this possible? Can someone point me towards some tutorials or in the right direction?

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!
 
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
 
  • Like
Reactions: V.K. and superscape
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

I am going to try it out now. Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.