Jump to content

Control Click understanding


blazyng
 Share

Recommended Posts

Hello its me again,

i want to start a Adware-remover (adw-cleaner) and do a scan with the command Command click.

#RequireAdmin
adw ()
Func adw ()
Run("C:\adwcleaner_7.0.5.0.exe","" ,@SW_MAXIMIZE )
;Activate Window
 WinActivate ( "Malwarebytes AdwCleaner 7" , "" )

 ; Wait 5 seconds for the  window to appear.
    Local $hWnd = WinWait("CLASS:wxWindowNR", "", 5)
ControlClick("Malwarebytes AdwCleaner 7","","CLASS:Button; TEXT:Scan; INSTANCE:4","","","","")


EndFunc

This is my code right now.

ADW-Cleaner is starting, but it is not clicking anywhere, where is my mistake? :) (or mistakes as i believe :D)

 

adwcleaner.PNG

´windowinfo.PNG

Link to comment
Share on other sites

Sorry, this isn't really something I know much about, but I'll keep stabbing in the dark until someone more knowledgeable turns up...

I see in your inspector window Text: Actions, but you have TEXT: Scan....

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

I dunno if this will help but here's an example I used to help someone last year with clicking a btn ^^

 

Posted December 21, 2016 (edited) · Report post

Here you go buddy. Works on win7

Edit: The ID changes when the application is opened.. does someone know why the ID changes?

#RequireAdmin ; must include when installing

Example()

Func Example()

    Local $hWnd = WinWait("[CLASS:TWizardForm]", "", 10) ; use AutoIt v3 Window Info tool
    ; located in the AutoIt folder.

    WinActivate($hWnd) ; WinActivate sets Setup - FreeOCR as an active screen

    ;Notes:
    ;ControlClick("title", "text", controlID[, button = "left"[, clicks = 1[, x[, y]]]])
            ;  title =>> $hWnd = WinWait("[CLASS:TWizardForm]
            ; "text" =>> "&Next >"
            ; controlID =>> 329210

    ControlClick($hWnd, "&Next >", 329210) ;

EndFunc   ;==>Example

 

Process.png

Edited December 21, 2016 by aa2zz6 
One last final thought :|

 

Link to comment
Share on other sites

17 minutes ago, SlackerAl said:

Sorry, this isn't really something I know much about, but I'll keep stabbing in the dark until someone more knowledgeable turns up...

I see in your inspector window Text: Actions, but you have TEXT: Scan....

Sadly changing it into Actions or deleting it did not change anything.. :)

Link to comment
Share on other sites

10 minutes ago, aa2zz6 said:

I dunno if this will help but here's an example I used to help someone last year with clicking a btn ^^

 

Posted December 21, 2016 (edited) · Report post

Here you go buddy. Works on win7

Edit: The ID changes when the application is opened.. does someone know why the ID changes?

#RequireAdmin ; must include when installing

Example()

Func Example()

    Local $hWnd = WinWait("[CLASS:TWizardForm]", "", 10) ; use AutoIt v3 Window Info tool
    ; located in the AutoIt folder.

    WinActivate($hWnd) ; WinActivate sets Setup - FreeOCR as an active screen

    ;Notes:
    ;ControlClick("title", "text", controlID[, button = "left"[, clicks = 1[, x[, y]]]])
            ;  title =>> $hWnd = WinWait("[CLASS:TWizardForm]
            ; "text" =>> "&Next >"
            ; controlID =>> 329210

    ControlClick($hWnd, "&Next >", 329210) ;

EndFunc   ;==>Example

 

Process.png

Edited December 21, 2016 by aa2zz6 
One last final thought :|

 

Hi,

thank you for your reply :)

My problem is that i do not have any id to use like in your example :)

Link to comment
Share on other sites

I just tried this on the file open dialogue from Notepad++ to cancel the dialogue, and it worked

test()

Func test()
  ControlClick("Open","","[CLASS:Button; INSTANCE:2]")
EndFunc

So it seems if you have the window name correct, you just need the class and instance.

Have you tried swapping your code around to read:

#RequireAdmin
adw ()

Func adw ()
  Run("C:\adwcleaner_7.0.5.0.exe","" ,@SW_MAXIMIZE )

  ; Wait 5 seconds for the  window to appear.
  Local $hWnd = WinWait("CLASS:wxWindowNR", "", 5)

  ;Activate Window
  WinActivate ($hWnd)

  ControlClick($hWnd,"","CLASS:Button; TEXT:Scan; INSTANCE:4","","","","")
EndFunc

 

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

7 minutes ago, SlackerAl said:

I just tried this on the file open dialogue from Notepad++ to cancel the dialogue, and it worked

test()

Func test()
  ControlClick("Open","","[CLASS:Button; INSTANCE:2]")
EndFunc

So it seems if you have the window name correct, you just need the class and instance.

Have you tried swapping your code around to read:

#RequireAdmin
adw ()

Func adw ()
  Run("C:\adwcleaner_7.0.5.0.exe","" ,@SW_MAXIMIZE )

  ; Wait 5 seconds for the  window to appear.
  Local $hWnd = WinWait("CLASS:wxWindowNR", "", 5)

  ;Activate Window
  WinActivate ($hWnd)

  ControlClick($hWnd,"","CLASS:Button; TEXT:Scan; INSTANCE:4","","","","")
EndFunc

 

Hi,

its a pity its not working either..

thank you four your effort :)

Link to comment
Share on other sites

7 minutes ago, aa2zz6 said:

I'm wondering if the winactivate is activating that application. Can u place a folder on top of the application, run the script and see if it's pushing the folder behind it?

  Local $hWnd = WinWait("CLASS:wxWindowNR", "", 5)

  ;Activate Window
  WinActivate ($hWnd)

Hi,

its not pushing the folder behind.

Does that mean WinActivate is not working? :)

Link to comment
Share on other sites

11 minutes ago, SlackerAl said:

Have you put in some error checking to confirm $hWnd is getting to set and is the window you think it is? e.g. msgbox yourself the title of that window from the handle.

I did not work with msgbox before, how can i link it to the handle? :) 

MsgBox ( 0, "error", "?" , timeout = 0 , CLASS:wxWindowNR )

should it be like that? :)

Link to comment
Share on other sites

Bingo! I would possibly look at troubleshooting with the winactivate function and once it works I would imagine the control click should be a walk in the park ;).

 

1) Winactivate - Set the Application Window above the folder.

ActiveWindow()


Func ActiveWindow()
    $hWnd1 = WinGetHandle("[CLASS: PUT CLASS ID HERE ]")
    If IsHWnd($hWnd1) Then
        WinActivate($hWnd1)
    EndIf
EndFunc   ;==>ActiveWindow

2) Once the application is activated and it's above every window a controlclick to press the btn should work.

ControlClick

Sends a mouse click command to a given control.

ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] )

Parameters

title The title/hWnd/class of the window to access. See Title special definition.
text The text of the window to access. See Text special definition.
controlID The control to interact with. See Controls.
button [optional] The button to click, "left", "right", "middle", "main", "menu", "primary", "secondary". Default is the left button.
clicks [optional] The number of times to click the mouse. Default is 1.
x [optional] The x position to click within the control. Default is center.
y [optional] The y position to click within the control. Default is center.
Link to comment
Share on other sites

I can only suggest you build that into your script, sending msgbox's to yourself as you go, using the same handle for your control sends, so you know the target is there and correct.... and active. Sorry out of ideas after that.

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

how about use the command line instead

https://toolslib.net/forum/viewthread/2611-command-line-adwcleaner/

malwarebytes really cheeses me off now. it used to be good, now it sucks all the life out of even the fastest computers... sigh

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

15 hours ago, Earthshine said:

how about use the command line instead

https://toolslib.net/forum/viewthread/2611-command-line-adwcleaner/

malwarebytes really cheeses me off now. it used to be good, now it sucks all the life out of even the fastest computers... sigh

Hi,

there is no more command line for the newest adwcleaner version :S

Thank you all for your ideas! :)

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