Welcome to the MP3Car.com forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact us.
|
12-04-2007, 03:11 PM
|
#1
|
|
Newbie
Join Date: Nov 2006
Posts: 14
|
phidget programming?
I have a 4 servomotor controller and need help writing code so that I can use it to left my monitor. Can anyone here help me here.
Thanks
Paul
|
|
|
12-04-2007, 10:43 PM
|
#2
|
|
Admin. Don't bug or I'll byte.
Join Date: Sep 2004
Location: Corning, NY
Vehicle: 2001 VW Beetle
Posts: 4,461
|
Can't you use applescript with phidgets?
|
|
|
12-05-2007, 04:54 AM
|
#3
|
|
Newbie
Join Date: Nov 2006
Posts: 14
|
I have not been able to get it to work.
Used the following code
tell application "Phidget Servo Controller"
activate
delay 2
end tell
tell application "System Events"
tell process "Phidget Servo Controller"
set value of slider 1 of window "Phidget Servo Controller" to 65
end tell
end tell
it will start the phidget servo controller but then I get this error message
System Events got an error: Can’t get slider 1 of window "Phidget Servo Controller" of process "Phidget Servo Controller". Invalid index.
Last edited by tang : 12-05-2007 at 04:58 AM.
|
|
|
12-05-2007, 07:22 AM
|
#4
|
|
QCar Creator
Join Date: Jul 2005
Location: Netherlands
Vehicle: 1993 Tatra 613-4Mi Long
Posts: 541
|
Quote: Originally Posted by tang 
I have a 4 servomotor controller and need help writing code so that I can use it to left my monitor. Can anyone here help me here.
What environment and language are you using for the development? Controlling Phidgets from C or ObjC/Cocoa is trivial (except for few issues if you go for multithreading). There are quite a few sample on the disk image the Phidgets driver is distributed on.
|
|
|
12-05-2007, 01:33 PM
|
#5
|
|
Newbie
Join Date: Nov 2006
Posts: 14
|
I looked at there examples. I have xcode install and was going to use that and thought I might be able to play around with it and understand what they are doing. I have limited programming skills. I did some visual basic about 5 years ago and just in a school enviorment then I switch to Macs and don't know the languge here.
Thanks
Paul
|
|
|
12-05-2007, 10:18 PM
|
#6
|
|
Admin. Don't bug or I'll byte.
Join Date: Sep 2004
Location: Corning, NY
Vehicle: 2001 VW Beetle
Posts: 4,461
|
You are trying to script the user interface, which is different than phidgets support applescript. The likely problem is that you either have the name of that slider incorrect, or the application isn't active/the slider is greyed out when you call it.
Did you know that automator in Leopard has a function called 'watch me do' that will record what you do and allow you to examine the script? That might be the easiest way to figure it out for you.
Otherwise, try using Xcode and the examples. It may not be as hard to modify an example as you think.
|
|
|
12-06-2007, 01:19 PM
|
#7
|
|
Newbie
Join Date: Nov 2006
Posts: 14
|
Well then I don't thing phidget is applescritable then or least it is not listed on there website. I will look at your other options as well.
Thanks for your sugestions
|
|
|
12-07-2007, 08:15 AM
|
#8
|
|
Admin. Don't bug or I'll byte.
Join Date: Sep 2004
Location: Corning, NY
Vehicle: 2001 VW Beetle
Posts: 4,461
|
I haven't done too much GUI scripting, but just looking at your code, it looks like you have too many tells in there. Try something simpler like this:
tell application "Phidget Servo Controller"
activate
delay 2
set value of slider 1 of window "Phidget Servo Controller" to 65
end tell
I think the reason it was bombing was that you were telling System events something. Since it didn't bomb when you first told the Phidget Servo controller application to activate, that means you were able to contact the program. I think you can simply continue that and set the value of the slider directly.
Not sure why you need to use the term 'process' rather than application. If the code above bombs, maybe you need to use that instead.
Perhaps you'll have to go back to your original code and write it like this:
tell application "System Events"
tell process "Phidget Servo Controller"
set value of slider 1 of window "Phidget Servo Controller" to 65
end tell
end tell
...but I have a feeling that what is going on is that AS is talking to the System Events app and NOT to Phidget Servo Controller app. I don't think you need to use that tell for System Events.
AS is notoriously finicky about the exact syntax and it isn't always clear how you write the code. It takes some messing around with.
|
|
|
12-07-2007, 03:41 PM
|
#9
|
|
Newbie
Join Date: Nov 2006
Posts: 14
|
Thanks I will keep playing around with as i would like to learn applescript. I will be looking for a good book on the matter. Non of the suggestions worked (appreciated anyway). Yes I tried the record with automater but when came to the slide it did not actually move them, It selected the one and stopped short of moving.
I will keep working with my options
Thanks
Paul
|
|
|
12-07-2007, 06:27 PM
|
#10
|
|
Admin. Don't bug or I'll byte.
Join Date: Sep 2004
Location: Corning, NY
Vehicle: 2001 VW Beetle
Posts: 4,461
|
Well....if it selected the right one, then use that code and then insert the AS code that actually sets the slider to the value you want.
This is THE book for applescript. You can go a really long ways with it.
Here's a good start on how to GUI script.
Also, you need UI Element inspector to allow you to tell what the name of the control is. It's here.
Last edited by Bugbyte : 12-07-2007 at 06:30 PM.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:12 AM.
|
|