Close a Putty window when prompt is detected

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
luupski
Posts: 3
Joined: 20 Jan 2019, 13:39

Close a Putty window when prompt is detected

20 Jan 2019, 14:31

All,

Sorry if this question is asked before, but i could not find this when searching.

I have AHK open a PuTTY session in which it runs a script
When the script is finished, the PuTTY prompt (from the server i logged into) appears again.
I want AHK to see when the prompt is there, and when it is use WinClose to close the PuTTY window
- So something like ; If prompt in PuTTY window (user@server) is true / present, then WinClose PuTTY
Up till now i have not been able to find an answer that fits

If any of you can advise this is much appreciated

Kind regards,

Paul
User avatar
Thoughtfu1Tux
Posts: 125
Joined: 31 May 2018, 23:26

Re: Close a Putty window when prompt is detected

21 Jan 2019, 03:10

Here’s what I do with my RaspberryPi and Putty:

Code: Select all

ToolTip, Press "0" to Exit, 850, 0
KeyWait, 0, D
WinWait, PuTTY Fatal Error, , 3  ; Window title when connection force closes when I reboot my Pi
WinClose, PuTTY Fatal Error, , 1
WinClose, PuTTY (inactive), , 1

luupski
Posts: 3
Joined: 20 Jan 2019, 13:39

Re: Close a Putty window when prompt is detected

21 Jan 2019, 19:43

.

Thanks for the reply

However, this still needs manual action
I want the putty window to close automatically when a certain prompt is detected

I found something like PuttyWait(PPid, WatchText)
But can't seem to get it to work in conjunction with WinClose

Thanks in advance for any ideas

Paul
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Close a Putty window when prompt is detected

22 Jan 2019, 01:01

You may need to run your script that is trying to use WinClose elevated. (run as admin)
HTH
luupski
Posts: 3
Joined: 20 Jan 2019, 13:39

Re: Close a Putty window when prompt is detected

22 Jan 2019, 16:26

Xtra,

That would be not the case
I can use WinClose with WinSetTitle for example

WinSetTitle, Old window Title , New Window Title
WinClose, New Window Title,

This works, the window closes
But i wonder if PuttyWait is supported in all AHK versions as i can hardly find any info on this

Paul
gregster
Posts: 9012
Joined: 30 Sep 2013, 06:48

Re: Close a Putty window when prompt is detected

22 Jan 2019, 22:46

luupski wrote:
22 Jan 2019, 16:26
I found something like PuttyWait(PPid, WatchText)
[...]
But i wonder if PuttyWait is supported in all AHK versions as i can hardly find any info on this
There was never a specific AHK-built-in function called PuttyWait... it has to be some user-defined function and you will have to include its code in your script to be able to use it... if it is supported by the AHK version you are using is not really to tell without seeing its code, but likely yes.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: hedehede81 and 283 guests