Jump to content

Recommended Posts

Posted

Ok..so most of my autoit experience comes from scripting for testing...and ty autoit community for the help there!! But now I want to learn something new and I have no clue where to even start so I turn to ya'll again!

Basically I want to write a script that when I click on a spot on the monitor, I want it to check if the spot is red or green, then move to the right and repeat till it runs out of "blocks"...The image is of Renko blocks...I want to be able to choose a block and have it start counting red blocks and green blocks...-1 for red/+1 for green....

As usual I dont want anyone to write the script...just a pointer in the right direction. Im assuming it will have to have something to do with pixels...

Also sorry if the image isnt embeded...no clue how to do that!

Thanks all!

 

Untitled.png

Posted (edited)

Hi @Fractured :)

I've never used PixelSearch(), but, I think that you could imagine your image as a matrix, composed by rows and columns.

If you have to "scan" just a "row", of your image, then you'll move your "pointer" on the X axis only.

If you have to scan pixel by pixel your image, then you have to move both on the X axis and Y axis.

Just get the current MousePosition(), and, with PixelSearch(), move from MousePosition[0] to the end of the image, and you should be done :)

Try this, and let us know ;)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted

ok..so using FrancescoDiMuro's suggestion, I searched, found and used some partial lines from other "helps", and this is what I have so far....

#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

$hGUI = GUICreate("Test", 300, 300)
    GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"CanvasClicked")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Local $idButton = GUICtrlCreateButton("hello",0,0,100,25)

GUISetState(@SW_SHOW)

 While 1
     Sleep(10)
 WEnd

Func CanvasClicked()
    If (GUIGetCursorInfo($hGUI))[4] = $idButton Then
        MsgBox($MB_SYSTEMMODAL, "Clicked", "Button")
    Else
        WinActivate("[CLASS:Intermediate D3D Window; INSTANCE:1]")
        $aPos = MouseGetPos()
        MsgBox($MB_SYSTEMMODAL, "Mouse x, y:", $aPos[0] & ", " & $aPos[1])
        $iColor = PixelGetColor(10, 100)
        MsgBox($MB_SYSTEMMODAL, "", "The decimal color is: " & $iColor)
        MsgBox($MB_SYSTEMMODAL, "", "The hex color is: " & Hex($iColor, 6))
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc

But now the problem is that the area I need to click is in chrome, and listed as [CLASS:Intermediate D3D Window; INSTANCE:1]..... added pic of info...

So now the question is how do I get the script to recognize the chrome window, and specifically the D3D Window...I know its Direct3d but im at a lose....As you can see I tried to use WinActivate (which is probly the wrong approach!!) but I also tried WinWaitActive...should I use WinExists to "debug" and try the different Class's that show up to see if the script see's my window? Use Focus?(trying to figure that out now.....) and why is my text highlighted all of a sudden while im typing this?!?!?!?! 

 

Thanks again all!

Untitled.png

Posted

p.s. also wondering if I need to use the chrome webdriver for this little endeavor.....trying to read up on it now but at work...shhh dont tell the boss this is for personnel use!

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
×
×
  • Create New...