Jump to content
Sign in to follow this  
crisu

ControlClick help!

Recommended Posts

crisu

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

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites
crisu

[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

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites
ileandros

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.

Share this post


Link to post
Share on other sites
crisu

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

Share this post


Link to post
Share on other sites
SmOke_N

Didn't work? What message box popped up?


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.

Share this post


Link to post
Share on other sites
crisu

Didn't work? What message box popped up?

No message at all.

Edited by crisu

Share this post


Link to post
Share on other sites
Xandy

Can you use TAB to navigate buttons, then ENTER or SPACE to strike the button?

UP, DOWN, LEFT, RIGHT, nothing?

Edited by Xandy

Share this post


Link to post
Share on other sites
SmOke_N

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
  • Like 1

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.

Share this post


Link to post
Share on other sites
crisu

Thanks for trying.

Btw. Send, ControlSend didn't work either. Windows Remote Assistance seems to be secured from any kind of automatic functions. I guess I can imagine why.

  • Like 1

Share this post


Link to post
Share on other sites
SadBunny

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!

  • Like 1

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

Share this post


Link to post
Share on other sites
crisu

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!

Share this post


Link to post
Share on other sites
SadBunny

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

As we say in Dutch, small effort, large delight. Or something like that. Have a good one ^_^


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

Share this post


Link to post
Share on other sites
danrche

2cents added:

I've found that UAC will jack with conrtolclicks as well, may want to put somthing in front that disables UAC then when finished re-enables it.

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  

×