Sign in to follow this  
Followers 0
sunzen

It seems that ControlClick-like functions do not work for all controls.

15 posts in this topic

Hi all,

I try using controlclick to click button control - after all controlclick seems more reliable and flexible than mouseclick, which require coords of the target contorl.

Unfortunately, i find out that controlclick does not work for some button controls. Is there anyone who encounter the same problem with me?

How to tackle with it? Thank you for your any information.

Sunzen

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Yes, I've run into that same problem and the work around I had to used were Send Keys tab and enter but first you will need to use WinActivate and WinWaitActive. Some really good examples are in the help file.

jfcby

Edited by jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Share this post


Link to post
Share on other sites

"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()."

... or try something like ControlSend("TargetWin", "", "Button1", "{ENTER}").

Share this post


Link to post
Share on other sites

Hi Jfcby & Kafu

Thank you for your attention and replies.

There was something wrong with the window title, The window title is a little special. Later i used WinTitleMatchMode 2 to just match part of it, and actually it does work when I copy all the characters of windows title from Windows Info tool.

However, I still find that there is some limitation when trying to operate control by using ControlClick-like functions. Concretely, It seems that we can not get (correct) ControlID for each program by using Windows Info tool. For example, for Windows Live Messenger, when i use Windows info to recognize ControlID of those essential controls, like ID inputbox, password inputBox, Logon Button, Window Info tool shows all the control have the same ControlID: [CLASS:DirectUIHWND;INSTANCE:2].

Could someone give any opinion?

Thanks in advance.

Sunzen

Share this post


Link to post
Share on other sites

Might have different reasons.

- Some controls are OS-Architecture sensitive (TreeView, ListView), meaning that the script has to be compiled in line with the OSArch (only x64 au3 scripts can access an 64bit ListView).

- The program might use none winapi standard controls, those can only be catched by custom code.

Try to apply Ascend4nts excellent UDF _EnumChildWindows on the target window and study the result.

Share this post


Link to post
Share on other sites

Others have had the same problem


GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Hi KaFu,

Thank you for your information.

I'd like to try Ascend4nt's UDF _EnumChildWindows, but found it is currently not available on his website. Do you have a copy of it ?

Thanks.

Sunzen

Might have different reasons.

...

Try to apply Ascend4nts excellent UDF _EnumChildWindows on the target window and study the result.

Share this post


Link to post
Share on other sites

sunzen,

I just checked, it's still there. Are you clicking on the download link? (its a ZIP file)

Share this post


Link to post
Share on other sites

Hi Ascend4nt,

Thanks for your attention.

This makes me get aware of that the access network is restricted.

Yeah, it's there.

Thanks for your work. I will give it a try.

Sunzen

Share this post


Link to post
Share on other sites

Hi KaFu & Ascend4nt,

I run the Ascend4nt's UDF to detect controls of Windows Live Messenger. The following is the results.

~~~~~~~~~~~

[0]|Handle|Classname|Control ID|Iteration|Title/Text

[1]|0x000407AA|Main Window Native WindowBar Class|0|1|

[2]|0x000607BA|DirectUIHWND|0|1|

[3]|0x000607A2|Main Window Class|0|1|

[4]|0x0014079A|DirectUIHWND|0|2|

[5]|0x0004078C|SizableRebar|0|1|

[6]|0x0013078A|ReBarWindow32|1999|1|

[7]|0x00120786|ToolbarWindow32|0|1|

~~~~~~~~~~~~~

It seems there is not enough information to recognize ControlID for the primary Controls Like ID Entry, Password Entry and Logon Button.

Could you give any idea?

FYI,

The version of Windows Live Messenger is 2009.

And Detected by Windows Info tool, ControlID of Password Entry is "[CLASS:DirectUIHWND;INSTANCE:2]". It can be used by ControlSend-like functions to operate this control.

Thanks

Sunzen

Share this post


Link to post
Share on other sites

sunzen, Just checked this out myself, and apparently Windows Live Messenger isn't using any standard controls. I don't know how you would interact with something like that. 'DirectUIHWND' sounds like it's using some type of DirectX/3D related interface. Bleh.. I personally like to use the 'aMSN' (Windows Live-compatible) messenger myself.

Share this post


Link to post
Share on other sites

Hi Ascend4nt,

Thank you for your comment and suggestion of aMSN.

My code snippet is as following. Password can be entered when using the ControlSend way.

Func Password_Input()
    $pswd="XXXXX"
    $way=0
    Switch $way
    Case 0
        $PswdCtrlID="[CLASS:DirectUIHWND;INSTANCE:2]"
        ControlClick($Mtitle,"",$PswdCtrlID)
        Sleep(1000)
        ControlSend($Mtitle,"",$PswdCtrlID,$pswd)
        Sleep(2000) 
    Case 1
        Send("{TAB}")
        Send($pswd)
        Sleep(2000)
    EndSwitch 
    
EndFunc 

Func Logon_Click()
    $way = 2
    Switch $way
    ; navigate to logon button control via Tab key
    Case 0
        TabKey_PressN(7)
        Send("{ENTER}")
    ;
    Case 1
           ; Is not able to get the correct ControlID for the logon button. 
        $OkID="[CLASS:DirectUIHWND;INSTANCE:2]"
        ControlClick($Mtitle,"",$OkID)
    ; Type {Enter} just after password is entered
    Case 2
        Send("{ENTER}")
    EndSwitch   
EndFunc

I tried to draw a conclusion about the limitations, but found the very note in the manual.

AutoIt only works with standard Microsoft controls - some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!

Thank all of you for making me finally pay attention to the critical note.

Sunzen

Share this post


Link to post
Share on other sites

Hi

Thank you for your kindness and information.

This is a broader and interesting topic, learning ...

Thanks

Sunzen

Others have had the same problem

Share this post


Link to post
Share on other sites

Sounds like a really none-trivial task which nobody on this forum has really mastered yet :mellow:...

http://www.autoitscript.com/forum/index.php?showtopic=93315&view=findpost&p=671487

http://www.codeproject.com/KB/macros/wlmplugin.aspx

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

oy Kafu,, now my head hurts :mellow:. DirectUI directly 'draws controls and widgets on the screen', that's just wonderful... for skinning, I guess. lol. I read somewhere that Windows 7 apps are starting to use this more.. I really hope not - or that someone comes up with a workable solution. Happily, I'm not working with any DirectUI apps regularly, so I'm putting it out of mind for the time being :P

sunzen, I'm glad you found that ControlSend works for you... I would just be concerned about the wrong control being active when you use it.

*edit: to clarify, the "[CLASS:DirectUIHWND;INSTANCE:2]" refers to the whole inner client area of Windows Live messenger, including all the 'DirectUI' controls inside of it. You can see this clearly by using the AutoIT Window Info tool and running it across the whole inner area.

Edited by Ascend4nt

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
Sign in to follow this  
Followers 0