PDA

View Full Version : unix command problems




nojohnny101
Mar 22, 2012, 06:03 AM
hey
i could really use some help here! i just can't figure this out and full disclosure i'm a newbie when it comes to these things.

here is the unix command that i am issuing through ARD


osascript <<EndOfMyScript
tell application "System Events"
tell application process "loginwindow"
key code 125
delay .5
key code 125
delay 1
keystroke return
delay 2
keystroke "2634"
keystroke return
end tell
end tell
delay 2
tell application "Gaming Introduction 30m"
activate
end tell
EndOfMyScript


two problems:

1) the application "Gaming Introduction 30m" launches fine but it doesn't come to the front and the icon bounces in the dock instead of bringing the dialogue box that is supposed to pop up to the forefront. is this a "focus issue" or something of that nature?

2) the command never seems to finish in ARD, it never completes. it is like it is stuck on something. why doesn't the unix command finish in ARD when once the "Gaming Introduction 30m" has finished launching?

here is the script code for the "Gaming Introduction 30m"


delay 2
on box()
set done to false
set question to display dialog "Have you been to Vantage before?" buttons {"Yes", "No"}
set answer to button returned of question
if answer is equal to "No" then
tell application "QuickTime Player"
activate
open "/Gaming Introduction.mp4"
present document 1
delay 2
tell application "System Events"
keystroke " "
end tell
end tell
delay 178
tell application "QuickTime Player"
quit
end tell
delay 1
tell application "Gaming Introduction" to activate
set question to display dialog "Do you want to watch the video again?" buttons {"Yes", "No"}
set answer to button returned of question
if answer is equal to "Yes" then
tell application "QuickTime Player"
activate
open "/Gaming Introduction.mp4"
present document 1
delay 2
tell application "System Events"
keystroke " "
end tell
delay 178
tell application "QuickTime Player"
quit
end tell
end tell
end if
end if
tell application "Menubar Countdown"
activate
delay 0.5
tell application "System Events"
keystroke tab
end tell
delay 0.2
tell application "System Events"
keystroke "30"
end tell
delay 0.2
tell application "System Events"
keystroke tab
end tell
delay 0.2
tell application "System Events"
keystroke "00"
end tell
delay 0.2
tell application "System Events"
keystroke return
end tell
end tell
end box

box()


i would really appreicate any help, advice or hints!
thanks so much!

peace will



kryten2
Mar 31, 2012, 05:15 PM
Your problems :

1) Try putting this bloc of code between tell application "System Events" like so :
tell application "System Events"
activate
set question to display dialog "Have you been to Vantage before?" buttons {"Yes", "No"}
set answer to button returned of question
if answer is equal to "No" then
tell application "QuickTime Player"
activate
open "/Gaming Introduction.mp4"
present document 1
delay 2
tell application "System Events"
keystroke " "
end tell
end tell
delay 178
tell application "QuickTime Player"
quit
end tell
delay 1
tell application "Gaming Introduction" to activate
set question to display dialog "Do you want to watch the video again?" buttons {"Yes", "No"}
set answer to button returned of question
if answer is equal to "Yes" then
tell application "QuickTime Player"
activate
open "/Gaming Introduction.mp4"
present document 1
delay 2
tell application "System Events"
keystroke " "
end tell
delay 178
tell application "QuickTime Player"
quit
end tell
end tell
end if
end if
end tell


2) Try to run your code locally in scripteditor and look at the events it generates in the event pane. That might give you a clue why it never finishes in ARD.

3) Probably not related to your problem but what's the purpose of this line :
set done to false
Setting done to false and doing nothing with it in the script serves no purpose.

Disclaimer : I'm not an expert in Applescript or anything else for that matter.
Just my humble opinion.

nojohnny101
Apr 19, 2012, 12:42 AM
hey
thanks for taking the time to respond. sorry for the delay in posting back on here.

I have since radically changed my approach. I had a different member help me rewrite that menubar application so that i don't have to enter the time through the GUI and instead i change the plist file before it launches and then we changed the app so it automatically starts to count when it is opened (didn't do this before and it wasn't even an option)....

i have also since suspended the use or need to launch that quicktime video....it turned out people here in uganda either don't want to or don't have the patience to sit through a 2-3 instructional video about how to surf the internet and instead would rather click around and figure out for themselves....so now i just have the script launch safari....

thanks i appreciate the help! if anyone wants me to post the code i am using to accomplish what i'm doing now just reply to this thread!

thanks again!

peace will