Sign in to follow this  
Followers 0
APRES

The first script problem

10 posts in this topic

The first script I made ( HelloWorld )

should do the following

Run ( "C:\putty.exe -load AT" )
WinActivate("192.168.10.1 - PuTTY" )
WinWaitActive ( "192.168.10.1 - PuTTY" )
Sleep(10000) ;pause 10 seconds
WinActivate("192.168.10.1 - PuTTY" )
Send ( "login{ENTER}" )
Sleep(10000) ;pause 5 seconds
WinActivate("192.168.10.1 - PuTTY" )

Then few times

Send ( "some keystroke")
Sleep(2000)
WinActivate("192.168.10.1 - PuTTY" )

All of it I compiled and scheduled as wintask to execute nightly.

It works well. :dance:

But not always. :whistle:

Sometimes I come next day and see that it remains on login screen. It looks like some process running on computer takes it over. Therefore I used

WinActivate for every step. But it doesn't help either.

What am I doing wrong?

Share this post


Link to post
Share on other sites



try a WinWait() between the first 2 statements, because you need to pause to give Putty time to launch before activating...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sure.

But it is not the cause of problem I guess. :whistle:

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

and

Send("{some keystroke}")
Sleep(2000)
WinActivate("192.168.10.1 - PuTTY" )

on ur send it should be

send("{keystroke"})

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

and

Send("{some keystroke}")
Sleep(2000)
WinActivate("192.168.10.1 - PuTTY" )

on ur send it should be

send("{keystroke"})

<{POST_SNAPBACK}>

@thatsgreat2345,

this does not look correct

send("{keystroke"})

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Also adding of WinWait() didn't help.

Today again program stopped at log in.

Is there any way to go further? (to debug it somehow)

Share this post


Link to post
Share on other sites

Also adding of WinWait()  didn't help.

Today again program stopped at log in.

Is there any way to go further? (to debug it somehow)

<{POST_SNAPBACK}>

Add Opt("TrayIconDebug", 1) to your script to deterime where it is stopping.....

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Also adding of WinWait()  didn't help.

Today again program stopped at log in.

Is there any way to go further? (to debug it somehow)

<{POST_SNAPBACK}>

I find that the length of time required to get the "login as:" prompt in PuTTY can vary tremendously. Assuming that the first string you are sending is the username you may need to put a substantial Sleep in the code before you send it.

Also, you can avoid the potential problem of another window taking focus by using ControlSend instead of Send (a ControlID is not actually required). Here is what works for me:

Run ( "C:\putty.exe -load your-config" )
$title = "your-IP - PuTTY"
WinWait($title )
$handle = WinGetHandle($title)
Sleep(15000); sleep 15 seconds - just keep shorter than the login timeout
ControlSend ( $handle, "", "", "username{ENTER}" )
ControlSend ( $handle, "", "", "password{ENTER}" )

Edit: Just realized that since the window title won't change, there should be no need for the complexity of using the handle. This will work just as well:

Run ( "C:\putty.exe -load your-config" )
$title = "your-IP - PuTTY"
WinWait($title )
Sleep(15000); sleep 15 seconds - just keep shorter than the login timeout
ControlSend ( $title, "", "", "username{ENTER}" )
ControlSend ( $title, "", "", "password{ENTER}" )

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thank you.

Almost sure that just the difference between

Send and ControlSend

will makes a trick. "ControlSend" would act also if a control lost focus and "Send" won't , isnt'it?

Edited by APRES

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0