Jump to content

Registering Clicks Outside of GUI


 Share

Recommended Posts

I've been at this for a while and I haven't yet discvovered how to do this.

I'm trying to get the position of a click that is outside the GUI that i have like lets say... An IE window, or a Firefox window or any other thing that isn't the GUI for the script.

I have this

Func _Select()
    
    MsgBox( 64, "Click", "Click At the Desired Corners", 2000)
    $i = 1
    $clickpoint = String("Top Right: ")
    Do
        $msg = GuiGetMsg()
    
                $pos = MouseGetPos()
                $tooltip = ToolTip($ClickPoint & $pos[0] & "," & $pos[1],$pos[0]+25,$pos[1]+25)

        If $msg = $GUI_EVENT_PRIMARYDOWN then 
            $pos = mousegetpos()
            $i += 1
            elseif $i = 1 Then 
                GuiCtrlSetData($in1, $pos[0])
                GuiCtrlSetData($in2, $pos[1])
            elseif $i = 2 Then
                $clickpoint = String("Bottom Left: ")
                GuiCtrlSetData($in3, $pos[0])
                GuiCtrlSetData($in4, $pos[1])           
            ElseIf $i = 3 Then
                $clickpoint = String("Top Right: ")
                GuiCtrlSetData($in5 , $pos[0])
                GuiCtrlSetData($in6, $pos[1])
            Elseif $i = 4 Then
            $clickpoint = String("Bottom Left: ")
                GuiCtrlSetData($in7, $pos[0])
                GuiCtrlSetData($in8, $pos[1])
        EndIf   
            
    Until $i = 5
        $tooptip = ToolTip("")
EndFunc

But because it is GUIGetMsg() it only gets the msg for moy GUI. I dont really know how to do otherwise.

Edited by PoopDeck
Link to comment
Share on other sites

look in the help file for Mousegetpos and _ispressed

#include <GuiConstants.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
$Main = GUICreate ("test", 200,150 )

GUISetState ()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    $a = MouseGetPos ()
        If _IsPressed("01", $dll) Then
        MsgBox(0,"_IsPressed", "Mouse position is"&@CRLF& $a[0] &@CRLF& $a[1])
    EndIf
WEnd
Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

Thanks, I just did try that method. I do however have one problem with that method. And that is if u keep holding down the mouse It cycles through all 4 times

and skips 3 of them because it's in a loop.

I had to add a sleeper to it and that just made it slower, also if I were to hold my mouse it would also cycle through it.

Is there just a simple User has clicked or way to get around this obnoctious loop.

Btw thx for the reply.

Link to comment
Share on other sites

I think I may know what you mean by annoying loop, if you mean what I think, then you can avoid it like this:

#include <GUIConstants.au3>
#Include <Misc.au3>

$GUI = GUICreate("Form1", 165, 113, 193, 125)
$Label = GUICtrlCreateLabel("", 32, 24, 36, 17)
GUISetState(@SW_SHOW)
$click = 0
While 1
    If $click <> GUICtrlRead($Label) Then GUICtrlSetData($Label, $click)
    If _IsPressed(01) Then
        While _IsPressed(01);  WAIT WHILE BUTTON IS HELD
            Sleep(10)
        WEnd
        $click += 1
    EndIf
WEnd

This waits after the click until the click is released.

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...