PDA

View Full Version : Applescript




andy8686
Jun 7, 2011, 03:50 AM
I just started learning Applescript programming. I need to write an Applescript program to enable the drop-down of the menu and clicking one of the item in the drop-down.

Example of the drop-down menu: http://javascript-array.com/scripts/simple_drop_down_menu/#
For example, I need to click the DHTML menu in Home. (Applescript to let Home auto drop-down and Auto click on DHTML)

Please guide me on how should i write this program and if possible do give me a sample Applescript coding so that i am able to reference to.



numero
Jun 14, 2011, 10:19 PM
If you are looking for a way for AppleScript to interact with a web page, that can't be done (in a practical sense). AppleScript does its magic by sending AppleEvents between applications. You can control Safari by telling it to open a new tab, what address to load, make a PDF of the page, etc. But you can't interact with Javascript on that page.

Now, I don't give up easily. If I was bound and determined to get something to work I would have AppleScript tell Safari to load the page, then tell Safari to give me the page source and then parse through that looking for the event that happens when I click a certain item. That may cause another page to load, which I would tell Safari to load for me. Etc.

It's the long way around and isn't exactly suited for AppleScript's strengths, but it could be done.