Sign in to follow this  
Followers 0
Shinitenshi

ControlClick / MouseClick Issue.

5 posts in this topic

Here is the image search function i use.

Func mySearch($location, $text)
    $fileA = @ScriptDir & $location

    _GDIPlus_Startup()

    $hImageA =_GDIPlus_ImageLoadFromFile($fileA) ;this is the firefox icon use something else if you don't have it.
    $hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)

    $x = 0
    $y = 0

    ;Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance,$HBMP=0
    $result = _ImageSearch($hBitmapA, 1, $x, $y, 100, 0) ;Zero will search against your active screen
    If $result > 0 Then
        ;MouseMove($x, $y)
        ;MsgBox(0,"",$x & " " & $y)
        ;TrayTip ( $trayTipTitle, $text, $trayTipTimeout)

        ControlClick($myHWnd,"","","left",1, $x, $y)

        ;MouseClick("left", $x, $y, 1)
    ElseIf $result == 0 Then
        TrayTip ( $trayTipTitle, "NOT FOUND!", $trayTipTimeout)
    EndIf

    _GDIPlus_ImageDispose($hImageA)
    _GDIPlus_Shutdown()
EndFunc

if i do a function call mySearch($fireFoxIcon, $text) and un-comment mouseMove($x, $y) it finds the image and moves to it to the correct location. Now if i use the ControlClick($myHWnd,"","","left",1, $x, $y) it finds the image but  clicks near the coordinates but not exactly where i want them to click.

Any idea why this is happening?

Things ive tried.

1. getting a new image

2. mouseclick instead of controlclick and that works but not what i want.

3. mousecoormod 1 no difference.

I know there are other ways to activate a browser but im just using Firefox icon to test the imagesearch and controlclick.

Share this post


Link to post
Share on other sites



I would like to use the computer while the script is running. 

Share this post


Link to post
Share on other sites

You haven't given us much information to go on. What process are you attempting to automate? Does it involve a web browser? If so, what's the website?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

MouseClick uses screen coords

ControlClick uses client coords

Might look at:

_WinAPI_ClientToScreen

Edit:

I guess I it would actually be:

_WinAPI_ScreenToClient

You're translating your "screen" coordinates to "client" coordinates, so your "controlclick()" has the proper place to click.

Edited by SmOke_N

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

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