Jump to content

AutoIt problem on virtual machine - cannot activate window


 Share

Recommended Posts

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] & '" '
Next


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

Else
  writeToFile("window not found after 10s")
EndIf


Func activateWindow($h)
   writeToFile("Set state SHOW: " & WinSetState($h,"",@SW_SHOW))
   writeToFile("WinActivate: " & WinActivate($h)
   return WinWaitActive($h,"",10)
EndFunc  
 
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
    EndIf
    FileWriteLine($hFileOpen, $text)   
    FileClose($hFileOpen)
    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?

 

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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