Jump to content

Problem with mouse click


Recommended Posts

I posted an hour or so with a problem with a nested function and I now realize what the problem is/was. The issue is not passing variable (which is what I originally though) but the problem is the mouse click. Basically my code automatically right clicks and finds out where the menu is (upper right, lower right etc...) and also finds out how tall the menu is (how many items are in it). I guess when I call the function the right click menu goes away and I get 0 as a return on my variable (the function is looking for colors). I know it works fine when I manually right click and activate the function. Any suggestions?

Thanks in advance

Func FunTest()
mouseclick("Right")
FunMenu1()

EndFunc

Func FunMenu1()    ;Calculates quadrant and length of menu in the 1st section
$barcount = 0
$1stLinePos = 0
$pos = MouseGetPos()
$MenuLocation = 0
$InitY = $pos[1]
$LastPos = 0
$LastPosInit = 0
$Top = 0

        ;sample pixels in a square looking for menu
$Quadrant1x = PixelGetColor ($pos[0]+10, $pos[1]-5)
$Quadrant1y = PixelGetColor ($pos[0]+5, $pos[1]-10)

$Quadrant2x = PixelGetColor ($pos[0]+10, $pos[1]+5)
$Quadrant2y = PixelGetColor ($pos[0]+5, $pos[1]+10)

$Quadrant3x = PixelGetColor ($pos[0]-10, $pos[1]+5)
$Quadrant3y = PixelGetColor ($pos[0]-5, $pos[1]+10)

$Quadrant4x = PixelGetColor ($pos[0]-10, $pos[1]-5)
$Quadrant4y = PixelGetColor ($pos[0]-5, $pos[1]-10)

If $Quadrant1x = 13158600 And $Quadrant1y = 13158600 Then
    $MenuLocation = 1
    For $i = 1 to 1000
        $Var = PixelGetColor ($pos[0]+350, $pos[1]-1 )
        $DoubleCheck = PixelGetColor ($pos[0]+150, $pos[1]-1 )
            If $Var = 8421504 and $doublecheck = 8421504 then
                $Lastpos = $pos[1]
            Endif

        $pos[1] = $pos[1]-1
    Next
    $LastPosInit = $Lastpos

    For $g = 1 to 500
        $Var = PixelGetColor ($pos[0]+350, $Lastpos - 1 )
        $DoubleCheck = PixelGetColor ($pos[0]+150, $Lastpos - 1)
            If $Var = 13158600 and $doublecheck = 13158600 then
                $Top = $Lastpos 
            Endif
        $Lastpos = $Lastpos -1
    Next

$1stLinePos = -1*($Top - $LastposInit + 1)

ElseIf $Quadrant2x = 13158600 And $Quadrant2y = 13158600 Then
    $MenuLocation = 2
    For $i = 1 to 500 
        $var = PixelGetColor ($pos[0]+300, $pos[1]+1 )
            If $var = 8421504 then
                $barcount = $barcount+1
                $1stLinePos = $pos[1] - $InitY 
                $i = 499
            Endif
        $pos[1] = $pos[1]+1
    Next
ElseIf $Quadrant3x = 13158600 And $Quadrant3y = 13158600 Then
    $MenuLocation = 3
    For $i = 1 to 500 
        $var = PixelGetColor ($pos[0]-300, $pos[1]+1 )
            If $var = 8421504 then
                $barcount = $barcount+1
                $1stLinePos = $pos[1] - $InitY 
                $i = 499
            Endif
        $pos[1] = $pos[1]+1
    Next
ElseIf $Quadrant4x = 13158600 And $Quadrant4y = 13158600 Then
    $MenuLocation = 4
    For $i = 1 to 1000
        $Var = PixelGetColor ($pos[0]-350, $pos[1]-1 )
        $DoubleCheck = PixelGetColor ($pos[0]-150, $pos[1]-1 )
            If $Var = 8421504 and $doublecheck = 8421504 then
                $Lastpos = $pos[1]
            Endif

        $pos[1] = $pos[1]-1
    Next
    $LastPosInit = $Lastpos

    For $g = 1 to 500
        $Var = PixelGetColor ($pos[0]-350, $Lastpos - 1 )
        $DoubleCheck = PixelGetColor ($pos[0]-150, $Lastpos - 1)
            If $Var = 13158600 and $doublecheck = 13158600 then
                $Top = $Lastpos 
            Endif
        $Lastpos = $Lastpos -1
    Next

$1stLinePos = -1*($Top - $LastposInit + 1)
Endif



MsgBox(0,"Output", $1stLinePos & "," & $MenuLocation)

EndFunc
Edited by boogieoompa
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...