Jump to content

ControlClick help!


crisu
 Share

Recommended Posts

I have tried at least dozen of solutions I have found on this forum but nothing seems to be working. I used AU3 Info to get window/button info but I must be putting it together in wrong way.

WinActivate ("Windows Remote Assistance", "")

ControlClick("Windows Remote Assistance", "", "[CLASS:Button; INSTANCE:4]") <- this doesn't work.

I think just about everybody have seen Windows Remote Assistance window. I want this script to click Invite someone you trust to help you. Image bellow represent that button.

Posted Image

Link to comment
Share on other sites

  • Moderators

Run just this (Make sure I have the title right):

#include <Array.au3>
Global $ga_hWnds = WinList("Windows Remote Assistant")
_ArrayDisplay($ga_hWnds)

And provide us with how many window handles it returns ( or provide a screen shot ).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

[0]|1|

[1]|Windows Remote Assistance|0x00840232

This is what returned.

Also,

WinActivate("Windows Remote Assistance", "")

$Check = ControlClick("Windows Remote Assistance", "", "[CLASS:Button; INSTANCE:4]")

If $Check = 1 Then

MsgBox(0, "", "Success")

Else

MsgBox(0, "", "Error")

EndIf

Returns: Success box.

Edited by crisu
Link to comment
Share on other sites

  • Moderators

Well, it's true that some windows resist automation.

Before we get into that, let me know if this works:

Global $gs_WinTitle = "Windows Remote Assistant"
Global $gh_Win = WinGetHandle($gs_WinTitle)
If Not IsHWnd($gh_Win) Then
    MsgBox(16 + 262144, "Error", "Window title doesn't exist")
    Exit 1
EndIf
Global $gh_CtrlHandle = ControlGetHandle($gh_Win, "", "Button4")
If Not IsHWnd($gh_CtrlHandle) Then
    MsgBox(16 + 262144, "Error", "Could not get handle for ""Button4""")
    $gh_CtrlHandle = ControlGetHandle($gh_Win, "", "[CLASS:BUTTON;INSTANCE:4]")
    If Not IsHWnd($gh_CtrlHandle) Then
        MsgBox(16 + 262144, "Error", "Could not get handle for ""[CLASS:BUTTON;INSTANCE:4]""")
        Exit 2
    EndIf
EndIf
WinActivate($gh_Win)
ControlFocus($gh_Win, "", $gh_CtrlHandle); Some controls require focus
ControlClick($gh_Win, "", $gh_CtrlHandle, "PRIMARY")
Exit 0 ; should be success
Or what you get from the debug info.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I have a ControlClick function i posted once in example scripts.

It is called MsClick i think.

What i do when i face windows that resists automatation is this:

I get position of the window, i get windows h/w, get the desktop h/w get the position of the button, calculate the maths for 100% accurate click and then i use MsClick witch is something similar to controllclick.

Edit: and btw try it like this...

WinActivate ("Windows Remote Assistance", "")
ControlClick("Windows Remote Assistance", "", "248")
Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

Well, it's true that some windows resist automation.

Before we get into that, let me know if this works:

Global $gs_WinTitle = "Windows Remote Assistant"
Global $gh_Win = WinGetHandle($gs_WinTitle)
If Not IsHWnd($gh_Win) Then
MsgBox(16 + 262144, "Error", "Window title doesn't exist")
Exit 1
EndIf
Global $gh_CtrlHandle = ControlGetHandle($gh_Win, "", "Button4")
If Not IsHWnd($gh_CtrlHandle) Then
MsgBox(16 + 262144, "Error", "Could not get handle for ""Button4""")
$gh_CtrlHandle = ControlGetHandle($gh_Win, "", "[CLASS:BUTTON;INSTANCE:4]")
If Not IsHWnd($gh_CtrlHandle) Then
MsgBox(16 + 262144, "Error", "Could not get handle for ""[CLASS:BUTTON;INSTANCE:4]""")
Exit 2
EndIf
EndIf
WinActivate($gh_Win)
ControlFocus($gh_Win, "", $gh_CtrlHandle); Some controls require focus
ControlClick($gh_Win, "", $gh_CtrlHandle, "PRIMARY")
Exit 0 ; should be success
Or what you get from the debug info.

Didn't work. Sadly I don't know nothing about debugging. :( However, another info: MouseClick("left", X, Y, 1, 10), where x,y is center of the button doesn't work as well. Cursor moves to the location but nothing else happens. Edited by crisu
Link to comment
Share on other sites

  • Moderators

Sounds like you need something like _MouseClickPlus() or something.

Which uses Client Coords I believe.

You'll have to find the udf or maybe ileandros's udf up there he mentions does it.

You'll need to make sure you set infotool -> Options -> Coord Mode to client

Then you'll need to make sure you're using Opt("MouseCoordMode", 2) in your script ( you can actually set that then try your mouseclick again if you think you already got client coords.

An xpos of 1 and a ypos of 10 kind of sounds like you're using the x and y of the control though, you need the client x and y of the control when using Opt("MouseCoordMode", 2).

Sorry I'm not much help here, I don't have that app that I'm aware of ( remote desktop didn't pop it up ), and I'm actually working on something for myself at the moment.

Edit:

If all else fails, Xandy has a decent suggestion ( using maybe ControlSend() to the window, or just Send() if you're sure it's active ). I'm not a fan of magic tabs/enter myself though.

Hope it works out.

Edited by SmOke_N
wrong ypos originally

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Intrigued... Tried it for myself (I'm running W7 x64 Pro English, by the way) and I think I got it.

The assistance thingy indeed denies automation because your user doesn't have enough elevation. Put #RequireAdmin on top of your script (and allow it to elevate when asked at the start obviously) and it works just fine.

Good luck!

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Intrigued... Tried it for myself (I'm running W7 x64 Pro English, by the way) and I think I got it.

The assistance thingy indeed denies automation because your user doesn't have enough elevation. Put #RequireAdmin on top of your script (and allow it to elevate when asked at the start obviously) and it works just fine.

Good luck!

Excellent! I can work with that. Thank you so much!

Link to comment
Share on other sites

  • 2 weeks later...

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...