Jump to content


Photo

Auto login double typing username and password


  • Please log in to reply
9 replies to this topic

#1 krightlane

krightlane
  • Members
  • 7 posts

Posted 11 April 2012 - 03:23 PM

I have a very simple script used for auto login. The script works ok some of the time but frequently the username and password text seems to replicate itself within the login window.

Eg instead of the username reading "user" it will end up "uusseerr" and fail to login.

This is the code I'm using

#NoTrayIcon
Run, C:\Program Files\Internet Explorer\iexplore.exe http://192.168.1.?:?
Sleep, 100
WinWait, Enter Network Password,
IfWinNotActive, Enter Network Password, , WinActivate, Enter Network Password,
WinWaitActive, Enter Network Password,
Sleep, 100
Send, user{TAB}password{ENTER}
sleep, 100
WinWait,Bosch
WinMaximize
[color=#00BF00]; exitapp[/color]

Please note that the ? in the URL are set in each script to which ever IP and port instance I an using. I have several saved scripts with just these details differing.

Can someone please advise how I can prevent this double (sometimes triple) typing.

Thanks in advance.

K

#2 Carcophan

Carcophan
  • Members
  • 1568 posts

Posted 11 April 2012 - 07:47 PM

try making the uid and pw, variables. You would send the variable string instead of letter characters.

Like this working example:
uid := "UserName"
pw := "Password"

!1::
Send, %uid%{Tab}%pw%{Enter}
return


#3 4lex

4lex
  • Members
  • 14 posts

Posted 11 April 2012 - 08:31 PM

Have you got more than one instance of the script running by any chance?

#4 Carcophan

Carcophan
  • Members
  • 1568 posts

Posted 12 April 2012 - 01:51 PM

Have you got more than one instance of the script running by any chance?


Good thought!

Add the line #SingleInstance Force to the top of your script, to avoid multiple instances of the same script being run at once.

#5 krightlane

krightlane
  • Members
  • 7 posts

Posted 19 April 2012 - 02:59 PM

I have added the #SingleInstance line and so far so good, It was rather random when it did it previously but it would appear that even when the window was closed the script was still active so when the explorer window was re-opened it saw it as a second instance.

I think I can call this one fixed but will update if the problem re-occurs.

Thankyou to everyone who responded.

#6 krightlane

krightlane
  • Members
  • 7 posts

Posted 27 April 2012 - 04:30 AM

Seems I was a bit premature in thinking it was fixed. Here's what is happening now.

I have two scripts

ScriptA.exe has the code as above with an ip address of 192.168.1.1 (example)

ScriptB.exe has the same code but has an ip address of 192.168.1.2

If ScriptA is running and I try to run B then the doubling of the username and password text occurs.

Is there any way around this so that I can have both instances running at any time without interference wth each other.

Cheers.

#7 JSLover

JSLover
  • Members
  • 920 posts

Posted 27 April 2012 - 04:47 AM

Is there any way around this so that I can have both instances running at any time without interference wth each other.

...are they supposed to run & exit?

The original script has no hotkeys, but it has a typo'd ":exitapp"...that will likely not run the ExitApp command, since it has a colon in front of it.

If they are supposed to run, do their thing, then Exit, then yes, you should be able to run one, let it finish, then run the other, without any problems. However, if you are using any Hotkeys, like the example Carcophan gave (!1::), then No, 2 scripts cannot use the same Hotkeys, without causing problems. If your current code is any different from the code in your 1st post, then you may need to repost the code, so it can be re-examined.

With the #NoTrayIcon & the WinWait's (with no timeout), old attempts are probably "sticking around" too long & you can't tell...add a timeout to the WinWait's, so it can fail, if it needs to...& perhaps remove #NoTrayIcon, while you are diagnosing the issue.

#8 krightlane

krightlane
  • Members
  • 7 posts

Posted 29 April 2012 - 05:55 PM

This is the code as it currently stands. I convert it to an exe before running.

#SingleInstance Force
[color=#00BF00];#NoTrayIcon[/color]
Run, C:\Program Files\Internet Explorer\iexplore.exe http://192.168.1.1:80
Sleep, 100
WinWait, Enter Network Password,
IfWinNotActive, Enter Network Password, , WinActivate, Enter Network Password,
WinWaitActive, Enter Network Password,
Sleep, 100
Send, username{TAB}password{ENTER}
sleep, 100
WinWait,Bosch
WinMaximize
exitapp

The exe appears to run, send the username and password and then close. I have taken the "notrayicon" command out so I can see if it remains open or not.

I can not see it still running in task manager at all, but even if I close the explorer window that was just opened and then run the exe again the problem shows up. This occurs even if only using a single script.

How would I go about adding a timeout to the winwait and is this likely to resolve the problem as time doesn't appear to be an issue?

Any advice very welcome as this is quite annoying for something that should be so simple.

Thanks again for your assistance everyone.

K

#9 JSLover

JSLover
  • Members
  • 920 posts

Posted 29 April 2012 - 11:19 PM

...but even if I close the explorer window that was just opened and then run the exe again the problem shows up.

...can you provide concrete steps-to-reproduce?...something that's repeatable everytime...& when it's failing like that, what do you do to "reset" it, for another successful test?

I wrote this program, to simulate the "Enter Network Password" dialog/sequence...please save this file as Enter Network Password.ahk...

Gui, New, , Enter Network Password
Gui, Margin, 19, 19
Gui, Add, Text, xm section w75, Username
Gui, Add, Edit, ys
Gui, Add, Text, xm section w75, Password
Gui, Add, Edit, ys
Gui, Add, Button, Default x0 y0 w0 h0 Hidden gSubmit, Submit
Gui, Show
return

GuiEscape:
GuiClose:
ExitApp

Submit:
Gui, Destroy
msgbox, , , Login Submitted, 1

Gui, New, , Bosch
Gui, Margin, 19, 19
Gui, Add, Text, , Bosch window
Gui, Show
return
...now, I did run your code, exactly as in the last post -- & it worked -- no matter how many times I tried...however, I have also re-written it, to clean it up, more like I would have written it...

#SingleInstance force
;//#NoTrayIcon

Username:="username"
Password:="password"

Run, Enter Network Password.ahk http://192.168.1.1:80

Sleep, 100

WinWait, Enter Network Password

if (!WinActive()) {
	WinActivate
	WinWaitActive
}

Sleep, 100

Send, {Raw}%Username%
Send, {Tab}
Send, {Raw}%Password%
Send, {Enter}

Sleep, 100

WinWait, Bosch
WinMaximize

ExitApp
...so I don't really know what's causing your double typing...unless you still have old copies of the script running...have you rebooted?...or actually, test my above scripts before you reboot, then reboot & test them again.

#10 krightlane

krightlane
  • Members
  • 7 posts

Posted 30 April 2012 - 12:31 PM

Thankyou JSLover for your reply. I was just having a play around with it when I noticed an interesting thing happen.

The script failed initially and I clicked ok on the error then opened the ahk file in notepad to look at it again.

When the script opened in notepad somehow the username and password that I was actually using (not geneneric "username" password" and which I haven't used in the test scripts from your previous post) pasted themselves into the text file.

I tried process explorer and found that the exe or ahk (which ever I run it from) does not exit. Is there something I'm missing with the ExitApp command? In process explorer It shows the process as Script1.exe with child objects of IE and Java.

Nothing I try is forcing the Script1.exe to close (exit) even after the IE window has been closed. I have to manually kill the process.

If I manually kill the process and then run the script it works great, if I then close IE and try and run the script again it has the double text problem.

Thanks again for your help.