The title says it all. I'm trying to script keyboard clicks in the browser (preferably Chrome). It's simple, from the current page I want to tab through 5 elements, then click enter, then repeat.
Right now I'm using a trial of the mac App "Fake" but it seems overly complicated for what I'm trying to do. I'm new to Macs and having trouble figuring out the simplest way to accomplish this. Any suggestions?
I'd take a look at Sikuli. It has a lot of things in its favor:
Comes with a nice starter IDE (or, you can write scripts in your own editor)
You can write Sikuli scripts in Jython, which is nice if you already know (or want to learn) Python
There's a Java API too, should you want to use pure Java
Sikuli's ability to do fuzzy matching of screenshots can be surprisingly robust
Scripts can be run from the command line once you grow out of the IDE (or want to plug the scripts into a continuous integration system)
Related
I am very new to making applications, and using Xcode, so I don't know much about it... I'm using Xcode 5.0.2 to attempt to create a basic osx application which will allow the user to search through a list of built in scripts, select the ones they would like to run, and push a button to run the scripts. I have several scripts already, all of which have the extension .scpt. i wrote the scripts using applescript editor.
From searching this website, and the rest of the internet, i haven't found a clear, step by step answer of what to do. I know that in order to run the shell script, there must be an interface button linked to an action in the implementation file, which is what will execute the script.
What is the action i have to put in the implementation file?
How do i link the button to the action?
where do i put my .scpt files?
I have absolutely no code written in Xcode, it is nothing but a blank new project.
I don't have much experience with Cocoa apps, if you have experience with Visual Studio this is nothing like it, I started by looking some videos from the link below, they're really helpful, he also provide a full course for Objective-C.
http://www.youtube.com/playlist?list=PLE83F832121568D36
I hope this helps!
There is a huge amount of aspects to the problem you are trying to solve. Honestly, connecting the NSButton to an Action is just taking the first (small) step! Just a few of the aspects you may encounter:
How are the files executed? (your main question)
How is the selection interface set up?
How to read from the files? How to process the data you read?
What kind of actions will your scripts perform? What is in fact allowed from within a Cocoa app? (I have no idea myself to be honest)
Each one of these suggests potential SO questions in itself.
I would suggest that you familiarise yourself with the environment and the language a bit before taking big leaps. Take some time (a few days at least) and follow some tutorials, program some simple apps. The link provided in the other answer is in fact a good one, AppleProgramming tutorials are easy to follow. You may also find Apple's Objective-C intro useful.
I'm a newbie to Mac and trying to use AppleScript to ease my daily job. One of the things I want to achieve is to automatically create Smart Mailbox based on the groups in my Address Book. While I have no problem automate Address Book, there's no much article about how to automatically create Smart Mailbox. After some searches on the web I realized it can only be done through GUI scripting. But most of the answers are about how to bring up the new Smart Mailbox dialog but no further information about e.g. how to select different rules. I tried to use AppleScript Editor to record my activity so that I can learn from that but found out after recording, there's nothing get recorded! I tried with other apps like Finder the recording does work! If anyone knows how to record it, or how to get more information on this type of GUI scripting would be very appreciated!
Unfortunately Mail's Applescript support is more than a little maddening at times due to being so limited. Control of smart mailboxes is but one example. I'd hoped SL would have fixed this but Apple's thinking about Applescript can be pretty schizophrenic at times. I'm not sure they have decided what to do with it.
I'd got a Smart Mailbox creation script working but it never worked reliably so I never deployed it. If you really want it I can give you the code - although it's written in Python + Appscript rather than pure Applescript.
Were I you I'd submit this as a bug to Apple and hopefully it'll be fixed with Lion.
The problem with GUI scripting as I'm sure you discovered is that figuring out how to get the name of each particular element can be maddening. There are a few utilities out there that will help, but unless you are doing a lot of GUI scripting they probably aren't worth the cost.
Regarding Applescript recording this was a really nice feature often supported under the old MacOS. However with the switch to OSX almost no application supports it so it's basically a dead feature for all practical intents.
In AutoHotkey and AutoIt the script is able to recognize images on webpages. Can AppleScript do that? How?
Short answer... no. Applescript is a tool for controlling other applications. It doesn't have a lot of capabilities itself. It's power is that you can combine the power of other applications into one script. As such you'd have to find a separate application that does the image stuff, then you can use applescript to automate that application.
You might want to look at this program. I watched the demo, it looks really interesting, and it may do what you want. I've never used it personally.
The easiest way to do this is unfortunately to use Applescript to get the source for the current browser page. You can then scan the text to recognize the image. As a language though Applescript isn't ideal for this. I'd suggest using Appscript + Python or Appscript + Ruby. Ruby and Python simply have far superior text mining libraries. Combining them with Appscript makes this sort of work pretty easy.
A quick question. Is there any method to control or automate any Windows application, using the command line. I've tried AutoIt. Any other methods? I'm targetting to control WinCE Test Kit (CETK) to perform the test without having to go to the GUI,or click the menu, connect etc, manually.
Thanks in advance!
We use Rational Robot for this but keep in mind it's not cheap. It's also probably been renamed 27 times since we started using it so you may want to just search for Rational testing products in general.
It's fully script-able, allowing you to monitor the screen and send key presses and whatnot.
Look at SCAR, it is great for all sorts of automation and screen reading: http://freddy1990.com/index.php?page=product&name=scar
I've always used a hybrid approach. First purchase SOTI Pocket Controller Pro then just use the normal AutoIt automation tools. It's a little different because you can't actually capture popup windows like you may be used to, but it can automate clicks, and then loop and wait for things using the GetPixel methods to check it the screen is what you expect.
Being able to connect to multiple CE devices at the same time visually is also a nice touch.
I need to write some scripts that access some websites. A script from the command line would get some pages, post some forms, screen-scrape some information, etc.
It cannot really be a library "browser" like libwww-perl, because some steps might require user interactions (CAPTCHAs, Ajax-only forms, any interaction surprises, etc.).
The most practical way I can think of would be remotely opening a tab in Firefox, and injecting JavaScript code into it, something a bit like what Greasemonkey and Selenium do. It doesn't necessarily have to be for Firefox and can be a different browser if that's easier.
So what would be the best way to do that?
Have you considered Selenium Remote Control? I've automated browser interaction using the tool before and it works very well, providing a lot of flexibility
Depending on your exact needs, you might be able to leverage the Selenium IDE which is an easy to use Firefox plugin that allows easy scripting.
You can use XPCOM to extend Firefox in every way imaginable. You could write some kind of interface that connects with another process maybe.
I'm not sure what the "best" way to do it would be, but one possibility would be to use AppleScript for the job. Firefox, however, doesn't have extensive scripting capabilities—if you are willing to use Safari, there is an AppleScript command available to inject JavaScript code into a document (the do JavaScript command—look it up in Safari's scripting dictionary, available from within Script Editor).
Also, in order to run AppleScripts from the command line, use osascript:
osascript path/to/script.scpt
To write srcripts on OS X there are two ways I would recommend, and both of them are in ruby. The first is Watir which is an automated testing framework that will control both firefox and safari on Mac os x.
Another, prehaps better way for screen scraping would be to use hpricot which is a html parser that is really easy to use.
In the background Watir uses JSSh - a TCP/IP JavaScript Shell Server for Firefox to do this is. JSSH allows you you control the browser from a telnet session.
Whichever way you go, if ther eare catchpa's they will stop you though. It's sort of the whole point of them :-)