nmontec

[python] controlclick not working when window is minimized

2 posts in this topic

Dear All,

I am having some trouble in automating a window. Everything is fine is I may use the couple WinActivate/WinWaitActive but it is not working if the window is minimized.

I need to click a button and I tried the following:

I declared in an object a reference like this:

self.autoit=win32com.client.Dispatch('AutoItX3.Control')
self.autoit.AutoItSetOption('WinTitleMatchMode',2)
self.autoit.AutoItSetOption("WinDetectHiddenText", 1)

And a t a certain point I press the Exit button

self.autoit.ControlClick('Dome','','[CLASSNN:WindowsForms10.BUTTON.app.0.378734a15]')
self.autoit.ControlClick('Dome','','[NAME:ButtonExit]')
self.autoit.ControlClick('Dome','','[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:15]')

Now, If the window is active and screen is not locked all is ok.But if window is minimized and/or screen is locked the command does not have any effect on the window. As far as I know controlclick should work also on these situations. Am I wrong?

Thanks a lot for your help

Nicola

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello Nicola,

Seeing as there has been no reply since Friday, I thought I'd chime in (hope you don't mind!):

Now, I'm by no means an expert in AutoIt, nor in Python (just an enthusiast in both), but going from my own experiences (and the ControlClick function page in the help file):

Quote

Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick().

A minimized window is usually not an active window, so that's likely why it's not working. ...Restoring, then activating the window won't work?

==========

Have you had much other trouble using an 'AutoIt class' in Python? That's a great idea, and one I haven't thought of! :thumbsup:

bloopie

Edited by bloopie
fixed typo

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

  • Similar Content

    • JohnOne
      Python total noob
      By JohnOne
      I fancy having a go at python.
      Looking for advice for what environment I need, good web resources etc...
      Ultimate goal is to create a kodi video addon.
    • leegold
      Run Python from Autoit Help
      By leegold
      Hi,
      I run the file:
      #include <Constants.au3> RunWait('python f:\walk2.py > c:\zz.txt') But nothing happens, no content inside zz.txt. It works OK from the XP command line.  Wondered what I'm doing wrong(?) I eventually want to send a .py script values/parameters and get output/"return".
      Thank You.
    • Decipher
      Array Slice UDF
      By Decipher
      _ArraySlice() its similar to list[n:n] in Python. I was converting a python script to autoit and was bored afterwords so I decided to create this UDF.


      #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArraySlice ; Description ...: Returns the specified elements as a zero based array. ; Syntax.........: _ArraySlice(Const ByRef $avArray[, $iStart = 0[, $iEnd = 0[, $iStep = 1]]]) ; Parameters ....: $avArray - Array to Slice ; $iStart - [optional] Index of array to start slicing ; $iEnd - [optional] Index of array to stop slicing ; $iStep - [optional] Increment can be negative ; Return values .: Success - Array containing the specified portion or slices of the original. ; Failure - "", sets @error: ; |1 - $avArray is not an array ; |2 - $iStart is greater than $iEnd when increment is positive ; |3 - $avArray is not an 1 dimensional array ; |4 - $iStep is greater than the array ; Author ........: Decipher ; Modified.......: ; Remarks .......: ; Related .......: StringSplit, _ArrayToClip, _ArrayToString ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== #include <Array.au3> ; Needed for _ArrayDisplay only. Example() Func Example() Local $MyArray[10] $MyArray[0] = 9 $MyArray[1] = "One" $MyArray[2] = "Two" $MyArray[3] = "Three" $MyArray[4] = "Four" $MyArray[5] = "Five" $MyArray[6] = "Six" $MyArray[7] = "Seven" $MyArray[8] = "Eight" $MyArray[9] = "Nine" Local $MyNewArray = _ArraySlice($MyArray, 9, 0, -2) _ArrayDisplay($MyNewArray) $MyNewArray = _ArraySlice($MyArray, 1) _ArrayDisplay($MyNewArray) $MyNewArray = _ArraySlice($MyArray, 1, 5) _ArrayDisplay($MyNewArray) $MyNewArray = _ArraySlice($MyArray, 5) _ArrayDisplay($MyNewArray) $MyNewArray = _ArraySlice($MyArray, 1, 3, 1) _ArrayDisplay($MyNewArray) EndFunc ;==>Example Func _ArraySlice(Const ByRef $avArray, $iStart = 0, $iEnd = 0, $iStep = 1) If Not IsArray($avArray) Then Return SetError(1, 0, 0) If UBound($avArray, 0) <> 1 Then Return SetError(3, 0, "") Local $iNew = 0, $iUBound = UBound($avArray) - 1 ; Bounds checking If $iStep > $iUBound Then Return SetError(4, 0, "") If $iEnd < 0 Or $iEnd > $iUBound Or $iEnd <= 0 And $iStep > 0 Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd And $iStep >= 1 Then Return SetError(2, 0, "") Local $aNewArray[$iUBound] For $i = $iStart To $iEnd Step $iStep ; Create a new zero based array $aNewArray[$iNew] = $avArray[$i] $iNew +=1 Next ReDim $aNewArray[$iNew] Return $aNewArray EndFunc ;==>_ArraySlice _ArraySlice.au3
    • ryushi5
      AutoIt and Python - Limited Functions
      By ryushi5
      I'm using Python to call AutoIt functions, but some functions don't work. Is there a reason for this? If so, can I fix it?


      from win32com.client import Dispatch Auto = Dispatch("AutoItX3.Control") def autoTest(): print Auto.MsgBox('')
      When I run it I get this error:


      line 516, in __getattr__ raise AttributeError("%s.%s" % (self._username_, attr)) AttributeError: AutoItX3.Control.MsgBox
      It seems like it's reading 'MsgBox' as an attribute and not a function. Any thoughts?