Sign in to follow this  
Followers 0
ghostofdeath

Double Clicks

14 posts in this topic

Hello.. I need help with this:I must call a MousegetPos() when the mouse double clicks anywhere on the screen.. So when the person double clicks, i record where he double clicked in a var and use it later..

i need it as fast as you can help me!

thanks

Share this post


Link to post
Share on other sites



What do you have so far?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Well exactly.. nothing =P but ill show my script here its an autojoiner for garena

Opt("MouseCoordMode", 0)
While 1
If WinExists("Garena")=1 Then
    ControlClick("Garena", "","[CLASS:ATL:00618B88; INSTANCE:1; ID:1243680]","",2,$pos[0],$pos[1])
EndIf
Do
    Sleep(1000)
Until WinActive("Error")=1
ControlClick("Error","OK",2)
WEnd

Share this post


Link to post
Share on other sites

Look at _IsPressed() in the help file, write some code... when it fails then post a thread with the failing code... Which is the point that Valuater was getting at I'm sure.


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

I tried using the ispressed command but it only checked one click.. i wanna check double clicks

Share this post


Link to post
Share on other sites

I tried using the ispressed command but it only checked one click.. i wanna check double clicks

Right, you're still missing the point... Show us how you tried to determine a double click.

Then there's always the search feature before you post a new thread :)http://www.autoitscript.com/forum/index.ph...ble+click\


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

ic .. but i deleted everything that i was trying to check it.. but the last one was using an example that i found using search. it was about a timing set with a function.. but it didnt work

Share this post


Link to post
Share on other sites

#Include <Misc.au3>
Opt("MouseCoordMode", 0)
$pos=MouseGetPos()
While 1
    If _IsPressed("01") Then
        $begin=TimerInit()
        While _IsPressed("01")
            Sleep(50)
        WEnd
        $diff=TimerDiff($begin)
        if ($diff<100)Then
            $pos=MouseGetPos()
        EndIf
    EndIf
If WinExists("Garena")=1 Then
    ControlClick("Garena", "","[CLASS:ATL:00618B88; INSTANCE:1; ID:1243680]","",2,$pos[0],$pos[1])
EndIf
Do
    Sleep(1000)
Until WinActive("Error")=1
ControlClick("Error","OK",2)
WEnd

i tried this.. it isnt working as well

Share this post


Link to post
Share on other sites

I'm thinking there could be a nice udf made with SetTimer + CallBack for double click:

Global $_DOUBLE_CLICK_DELAY_TIME = _GetDoubleClickTime()
Global $_DOUBLE_CLICK_PRIMARY_BUTTON = _MouseGetPrimary()
Global $_DOUBLE_CLICK_SECONDARY_BUTTON = Abs(($_DOUBLE_CLICK_PRIMARY_BUTTON - 1))

While 1
    If _IsMouseDoubleClick("Left") Then
        MsgBox(64, "Info", "You double clicked")
    EndIf
    Sleep(100)
WEnd

Func _IsMouseDoubleClick($s_button = "primary")
    Local $n_timer = TimerInit()
    
    If StringInStr(",primary,secondary,left,right,middle,", _
            "," & $s_button & ",") = 0 Then
        Return SetError(1, 0, 0)
    EndIf
    
    Local $n_type, $s_type = StringLower($s_button), $b_click = False
    
    Switch $s_type
        Case "left"
            $n_type = 0x01
        Case "right"
            $n_type = 0x02
        Case "middle"
            $n_type = 0x04
        Case "primary"
            If $_DOUBLE_CLICK_PRIMARY_BUTTON Then
                $n_type = 0x01
            Else
                $n_type = 0x02
            EndIf
        Case "secondary"
            If $_DOUBLE_CLICK_SECONDARY_BUTTON Then
                $n_type = 0x01
            Else
                $n_type = 0x02
            EndIf
        EndSwitch
        
    If __IsPressed_($n_type) = 0 Then Return SetError(2, 0, 0)
    Sleep(Int($_DOUBLE_CLICK_DELAY_TIME/3))
    While 1
        Sleep(10)
        If __IsPressed_($n_type) Then
            $b_click = True
            ExitLoop
        EndIf
        If TimerDiff($n_timer) >= $_DOUBLE_CLICK_DELAY_TIME Then
            ExitLoop
        EndIf
    WEnd
    If $b_click Then Return SetError(0, 0, 1)
    Return SetError(3, 0, 0)
EndFunc

Func __IsPressed_($n_type)
    Local $a_GAKS = DllCall("User32.dll", _
                                "int", _
                                "GetAsyncKeyState", _
                                "int", _
                                $n_type)
    If Not @error And _
        BitAND($a_GAKS[0], 0x8000) Then
        Return 1
    EndIf
    Return 0
EndFunc

Func _GetDoubleClickTime()
    Local $a_GDCT = DllCall("User32.dll", "dword", "GetDoubleClickTime")
    If @error Then Return SetError(1, 0, -1)
    Return SetError(0, 0, $a_GDCT[0])
EndFunc

Func _MouseGetPrimary()
    ; 0 = Right, 1 = Left
    Local $a_SMB = DllCall("User32.dll", "int", "SwapMouseButton", "int", True)
    If IsArray($a_SMB) And ($a_SMB[0] <> 0) Then Return 0
    If IsArray($a_SMB) And ($a_SMB[0] = 0) Then
        ; Reset
        DllCall("User32.dll", "int", "SwapMouseButton", "int", False)
    EndIf
    Return 1
EndFunc
This works ok, but not a fan of sleeping for 900 ms (that's my delay time for double clicks).

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

#10 ·  Posted (edited)

Well yours script works fine.. trying to get it into my one and trying to understand your script too ^^

EDITING:

Well i think the double click time, for my script, dont need to be the windows double click. and i got a problem.. i must declare the $pos before as an array and not inside an IF statement, if so the script will return an error that the variable doenst exist, but if i declare it as mousegetpos() it ll double click the first time where the mouse is and thats not the point.

Edited by ghostofdeath

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Well Im trying another code now because the other failed. its a kind of hotkey but didnt work could you tell me whats wrong?

#Include <Misc.au3>
Opt("MouseCoordMode", 2)
    Do
        Sleep(100)
    Until _IsPressed("2d")
While 1
If _IsPressed("2d") Then
    $pos=MouseGetPos()
    msgbox(01,"",$pos[0]& ","& $pos[1],500)
EndIf
If WinExists("Garena")=1 Then
    ControlClick("Garena", "","[CLASS:ATL:00618B88; INSTANCE:1; ID:1243680]","",2,-$pos[0],-$pos[1])
EndIf
If  WinActive("Error")=1 Then
    ControlClick("Error","OK",2)
EndIf
WEnd

Edit: the msg box is unecessary it was just a test box to see if the mouse was found

Edited by ghostofdeath

Share this post


Link to post
Share on other sites

What exactly are you trying to do? I have a feeling it's 10x's easier than the way you're approaching it.


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

The ideia is to get the mouse position of a room inside GArena so the bot will auto click on that room and Press the OK button when the error message (room is full) appears. but i dont know how to get the mouse position of the room that the person choose.

Share this post


Link to post
Share on other sites

any ideia guys? I cant see any solution yet

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