yassesn Posted August 9, 2019 Posted August 9, 2019 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,
Developers Jos Posted August 9, 2019 Developers Posted August 9, 2019 Put a short sleep() after ShellExecute() to give the programm time to start. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
yassesn Posted August 9, 2019 Author Posted August 9, 2019 4 hours ago, Jos said: Put a short sleep() after ShellExecute() to give the programm time to start. Jos I'va added a 3 seconds sleep. ShellExecute( $Exe ) Sleep(3000) WinActivate($Title, "") WinWaitActive($Title, $Content, $Delay) Still randomly focuses on the screen....
Nine Posted August 9, 2019 Posted August 9, 2019 What is the actual $Exe and the actual $Title ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
yassesn Posted August 9, 2019 Author Posted August 9, 2019 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?
Nine Posted August 9, 2019 Posted August 9, 2019 Maybe you could do something like this : ShellExcute ("Something.hod") Sleep (1000) While WinExists ("Exécution en cours") Sleep (100) Wend Sleep (1000) Local $hWnd = WinActivate ("Connexion à IBM") if not $hWnd then Exit MsgBox (0,"","error") WinWaitActive ($hWnd) Untested... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now