AutoIt problem on virtual machine - cannot activate window

3 posts in this topic

I am trying to handle a Windows dialog on a Windows 10 x64 virtual machine (vcloud).

The dialog is opened by a web site to upload files.

Here is the script:

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

$files = ""
For $i = 1 To UBound($CmdLine) - 1
    $files &= '"' & $CmdLine[$i] & '" '

$handler = WinWait("[REGEXPTITLE:(Open|Upload)]","",10)
If $handler Then
  writeToFile("window found " & $handler)
  If WinActive($handler) Then
    writeToFile("window is active " & $handler)
    writeToFile("window is not active " & $handler)
    writeToFile("activate window " & $handler)
    If activateWindow($handler) Then
      writeToFile("activate window succeeded")
      writeToFile("failed to activate ")

  writeToFile("window not found after 10s")

Func activateWindow($h)
   writeToFile("Set state SHOW: " & WinSetState($h,"",@SW_SHOW))
   writeToFile("WinActivate: " & WinActivate($h)
   return WinWaitActive($h,"",10)
Func writeToFile($text)
    Local Const $sFilePath = "C:\test\autoIT\x.out"
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ + $FO_APPEND)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading/writing the file.")
        Return False
    FileWriteLine($hFileOpen, $text)   
    Return True
EndFunc   ;==>Example


If I open a remote desktop connection to that virtual machine the script works fine and the upload window is activated ad I can send text to it.

If I minimize the remote desktop connection window the autoit script can't activate the upload window.

Here is the output I get for both cases:

window found 0x00040576
window is not active 0x00040576
activate window 0x00040576
Set state ENABLE: 1
Set state SHOW: 1
WinActivate: 0x00040576
activate window succeeded

window found 0x000C058C
window is not active 0x000C058C
activate window 0x000C058C
Set state ENABLE: 1
Set state SHOW: 1
WinActivate: 0
failed to activate

Any clues on this?

Is there other way that ? I can send text to that window?



Share this post

Link to post
Share on other sites

Have you tried ControlSend?

1 person likes this

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