Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 2, 2007, 05:17 PM   #1
konifer
macrumors newbie
 
Join Date: Jan 2007
very basic applescript just won't work

I'm a total newbie with applescript, and have looked around to try and find an answer to this, as well as tried to find ways around it but am a bit stuck...

I am trying to use an incredibly basic task with applescript, but I can't get it to work...

what I'm trying to do is:
  • go to a specific URL
  • tab down to my username
  • press enter to login (the user and password are saved and are already there, using firefox)

so my code looks like this (I hope I'm doing this right..):

set CR to ASCII character of 13
open location "http://www.myurl.com"
keystroke tab
keystroke CR

However I get an applescript error telling me

Can't make keystroke " " into type reference.

with the "keystroke tab" element highlighted..

what am I doing wrong?
konifer is offline   0 Reply With Quote
Old Jan 2, 2007, 06:06 PM   #2
HexMonkey
Administrator
 
HexMonkey's Avatar
 
Join Date: Feb 2004
Location: New Zealand
keystroke is a command in the System Events dictionary so you need to embed it in a tell application "System Events" block.

The other problem you might run into is that the commands in the script following the open location line are run before the page has finished loading. As a workaround I've put in a delay of a few seconds before the keystrokes are sent, but you might want to adjust the number depending on the time it takes the page to load for you, and how consistent it is.

Code:
tell application "Firefox" to activate
set CR to ASCII character of 13
open location "http://forums.macrumors.com"
delay 3
tell application "System Events"
	keystroke tab
	keystroke CR
end tell
HexMonkey is offline   0 Reply With Quote
Old Jan 2, 2007, 06:12 PM   #3
konifer
Thread Starter
macrumors newbie
 
Join Date: Jan 2007
absolutely perfect, that's exactly what was needed..

I tried delaying it before but it didn't change anything, it was obviously just the system events part that was wrong.. I wonder why I couldn't find that anywhere?

anyway thanks ever so much!!
konifer is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Sil3231 eSATA card just won't work. [Solution found] Loa Mac Pro 14 Mar 18, 2013 10:48 PM
SSD just won't work andothfc MacBook Pro 6 Aug 13, 2009 09:59 AM
New MBP - Snow Leopard order just won't work. ss957916 MacBook Pro 8 Jun 20, 2009 04:32 AM
Screen sharing, it just won't work! Arkanok OS X 2 Mar 6, 2009 11:31 AM
CS3 beta just won't work Machead III Mac Basics and Help 4 Dec 20, 2006 04:46 PM


All times are GMT -5. The time now is 03:39 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC