Tuesday, July 27, 2010

Debugbar, Autohotkey, Javascript

Great discoveries this past week. First of all, Debugbar is a great plugin for Internet Explorer for examining the DOM of websites, especially those that have complex dynamically created DOM with javascript. Also you can run javascript in the Debugbar console on the website without resorting to "navigating" out of the URL (you don't have to type the script into the URL input field, or navigate out of the native URL using links or favorites), which makes running these scripts possible when you have Web Controls/Agents on your source URL.

You can access the data within a frame in the DOM using the following javascript syntax:

str = top.myframename.document.GetElementById('myelementid').innerHTML;

and then use javascript REGULAR EXPRESSIONS (Regex) functions to parse the data into usable formats

Autohotkey is capable of launching javascript, but it is trickey. You have to either use the URL input field or Debugbar Javascript Console to do it, neither of which is elegant, or you have to use the COM library which is documented on the Autohotkey forum, again, which will require a learning curve. A better solution is to use Autohotkey to reliably click the correct objects in the browser, and the two tricks I have learned are:

CoordMode, Mouse, Screen

That line allows you to accurately base Mouse Movements and Click Coordinates to be relative to the screen instead of to the window, which helps when the script is popping up windows all over the place. The other trick is

Sleep, 100

Between each Click, it's good to pause the program for 1/10th of a second to let the computer catch up with itself. Prevents errors.

No comments:

Post a Comment