| | |
Bit of help with an AppleScript
![]() |
•
•
Join Date: Apr 2005
Posts: 66
Reputation:
Solved Threads: 0
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
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
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.
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.
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
[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
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.
•
•
•
•
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.
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
![]() |
Similar Threads
- Identify a 16-bit Program (Windows tips 'n' tweaks)
- Bit Torrent Forum/Site, help? (Website Reviews)
- what is the difference between regular and 64 bit edition (Windows NT / 2000 / XP)
- 128 bit encryption (Viruses, Spyware and other Nasties)
- Learn How to Spot a 16-Bit Application (Windows tips 'n' tweaks)
Other Threads in the OS X Forum
- Previous Thread: File Transfer
- Next Thread: please help
| Thread Tools | Search this Thread |





