Shinitenshi Posted November 21, 2014 Posted November 21, 2014 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.
junkew Posted November 21, 2014 Posted November 21, 2014 I do not think controlclick is then the right command as its relative to the control position and your imagesearch is screen relative Any reason why you do not want to use mouseclick FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Shinitenshi Posted November 21, 2014 Author Posted November 21, 2014 I would like to use the computer while the script is running.
Danp2 Posted November 21, 2014 Posted November 21, 2014 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? Latest Webdriver UDF Release Webdriver Wiki FAQs
Moderators SmOke_N Posted November 21, 2014 Moderators Posted November 21, 2014 (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 November 21, 2014 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now