Sign in to follow this  
Followers 0
boogieoompa

Problem with mouse click

2 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



I just figured it out, the right click menu take 130 ms to turn on. My script was running faster than the gui could react. I put in a sleep of 130 and all was well.

Thanks anyway.

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