Bit of help with an AppleScript

Reply

Join Date: Apr 2005
Posts: 66
Reputation: gn0m3 is an unknown quantity at this point 
Solved Threads: 0
gn0m3 gn0m3 is offline Offline
Junior Poster in Training

Bit of help with an AppleScript

 
0
  #1
Jan 10th, 2007
Morning Folks,

think this is my first post of the new year, so Happy New Year.... i have got a small applescript i have written (see below), it is connecting to a telnet session, but opens two terminal windows - one is just a terminal window and the other is the telnet session...any ideas on how i can remove the first winow opening to just leave the actual telnet session??

set telnet to "telnet -K 0.0.0.0
tell application "Terminal"
run
do script telnet
delay 1
end tell


Thanks a lot

gn0m3
Attached Thumbnails
screendump.jpg  
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 17
Reputation: cryptyq is an unknown quantity at this point 
Solved Threads: 0
cryptyq's Avatar
cryptyq cryptyq is offline Offline
Newbie Poster

Re: Bit of help with an AppleScript

 
0
  #2
Jan 12th, 2007
try adding this after the 'run' statement:

tell application "System Events"
tell process "Terminal"
keystroke "w" using {command down}
end tell
end tell

when the run statement is given, it opens Terminal, which by default opens a new sessions window. The above code sends the command-w keystroke to the terminal app via a system event (same as a live keystroke) and will close the open window. Good luck.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 89
Reputation: Lomoco is an unknown quantity at this point 
Solved Threads: 0
Lomoco's Avatar
Lomoco Lomoco is offline Offline
Junior Poster in Training

Re: Bit of help with an AppleScript

 
0
  #3
Jan 19th, 2007
Just change the script to read

[tell application "Terminal"
activate
end tell
delay 5
tell application "System Events"
if UI elements enabled then
tell process "Terminal"
set frontmost to true
end tell

keystroke "telnet -K 0.0.0.0"

key down return
key up return

end if
end tell]

Type the text in the [] in script editor and it will tell terminal to try to connect to 0.0.0.0. You can change it to whatever you want. This script basically just presses the keys on the keyboard for you. (And you only have one window open on the run)

Hope that works
Lomoco
Mac_Hack
Lomoco.MacHack@gmail.com
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 66
Reputation: gn0m3 is an unknown quantity at this point 
Solved Threads: 0
gn0m3 gn0m3 is offline Offline
Junior Poster in Training

Re: Bit of help with an AppleScript

 
0
  #4
Jan 22nd, 2007
thanks for that guys, will try it out later, have been off ill for the last week so sorry for not responding...

gn0m3
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 66
Reputation: gn0m3 is an unknown quantity at this point 
Solved Threads: 0
gn0m3 gn0m3 is offline Offline
Junior Poster in Training

Re: Bit of help with an AppleScript

 
0
  #5
Jan 22nd, 2007
thanks Lomoco, that worked great. Thanks also for your suggestion cryptq, but when run the front window got closed down which was the window i needed, i tried playing around with the code but could not get to function..

Thank you both.

gn0m3
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 89
Reputation: Lomoco is an unknown quantity at this point 
Solved Threads: 0
Lomoco's Avatar
Lomoco Lomoco is offline Offline
Junior Poster in Training

Re: Bit of help with an AppleScript

 
0
  #6
Jan 22nd, 2007
Oh, and be sure not to do anything while the script is running. It may cause your computer to start acting funny. If this occurs, save whatever you were working on by using the MENUS and log-out. What happened is that a key that applescript pressed didn't get let up and is still being held down virtually. Experiment with the script I gave you to get the best result for you.
Lomoco
Mac_Hack
Lomoco.MacHack@gmail.com
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 89
Reputation: Lomoco is an unknown quantity at this point 
Solved Threads: 0
Lomoco's Avatar
Lomoco Lomoco is offline Offline
Junior Poster in Training

Re: Bit of help with an AppleScript

 
0
  #7
Jan 22nd, 2007
Originally Posted by cryptyq View Post
try adding this after the 'run' statement:

tell application "System Events"
tell process "Terminal"
keystroke "w" using {command down}
end tell
end tell

when the run statement is given, it opens Terminal, which by default opens a new sessions window. The above code sends the command-w keystroke to the terminal app via a system event (same as a live keystroke) and will close the open window. Good luck.
Modify your command-w script to read the following:

tell application "System Events"
tell process "Terminal"
keystroke "`" using {command down}
keystroke "w" using {command down}
end tell
end tell

That should work for you
Lomoco
Mac_Hack
Lomoco.MacHack@gmail.com
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 66
Reputation: gn0m3 is an unknown quantity at this point 
Solved Threads: 0
gn0m3 gn0m3 is offline Offline
Junior Poster in Training

Re: Bit of help with an AppleScript

 
0
  #8
Jan 25th, 2007
thanks once again for your help on this one guys, another problem solved.

gn0m3
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the OS X Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC