Jump to content

Recommended Posts

Posted

Dear all,

 

I'm struggling with an AutoIt script, Win Activate doesn't automatically work. I have a script that  loads a program on the login page and then sends automatically the credentials. When the focus is not on the program, the autologin won't work. The user must click on the window so that the rest of the script works. It's kinda of random, sometimes it works and some other times it won't.

 

Here's how it looks like:

 

$Exe = $CmdLine[1]
$User = $CmdLine[2]

$aUser = StringSplit($User, '@')
if $aUser[0] > 1 Then
    $User = $aUser[1]
EndIf

$Pwd = $CmdLine[3]

$Delay = 30
;~
$Name = "xxxxx"

$WorkingDir = ""
$Title = "xxxxxxxxxxx"
$Content = ""

ShellExecute( $Exe )
WinActivate($Title, "")

WinWaitActive($Title, $Content, $Delay)
;~ Sleep(3000)
;~  if program is not active after timeout, quit
If Not WinActive($Title) Then
    MsgBox(1, "Error", "Can't launch " & $Name )
    Exit(1)
EndIf
Sleep(500)

Send($User,1)
Send("{TAB}")
Send($Pwd,1)
Send("{TAB}")
Send("{ENTER}")

 

Did I miss something?

 

Best regards,

Posted
30 minutes ago, Nine said:

What is the actual $Exe and the actual $Title ? 

$Name = "IBM"
$Title = "Connexion à IBM"

The exe is .hod extension that is automatically opened by a software.

Thing is, there is a loading page just before the second screen that says (Exécution en cours).

I've tried to add

WinActivate("Exécution en cours", "")

Whenever the loading page is focused, the main page will be focused. That didn't work either. 

Should I activate both windows with a sleep() in between?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...