Jump to content

_WinAPI_Mouse_Event help?


Recommended Posts

I was looking around the helpmefile for mouse clicks and this function popped up. How would I use this in a script properly, such as searching an area of 10sq pixels of my mousepos. Is this much better than the normal mouseclick?

"I think, therefore I am"[size="1"]René Descartes[/size]

Link to comment
Share on other sites

I was looking around the helpmefile for mouse clicks and this function popped up. How would I use this in a script properly, such as searching an area of 10sq pixels of my mousepos. Is this much better than the normal mouseclick?

Regular MouseGetPos() would be better. No need to use the more complex API unless you need additional functionality.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well, why is it that my code isn't effective in game.

$pos = MouseGetPos()
            $coord = PixelSearch(($pos[0] - 10) , ($pos[1] - 10) , ($pos[0] + 10) , ($pos[1] + 10), 0x00FF00)
            If IsArray($coord) = 1 Then
                
                MouseClick('left', $coord[0], $coord[1], 1, 0)

"I think, therefore I am"[size="1"]René Descartes[/size]

Link to comment
Share on other sites

@Firefox, hahaha I've been working with some people for 5 months now and they call me jarrett still instead of garrett.

#include <GUIConstants.au3>
Global $Aimbot = 0, $found = "no"

WinActivate("Quake 3: Arena")


While 1

HotKeySet("{HOME}", "ToggleAimbot")
HotKeySet("{END}", "TurnoffAimbot")


$status = GUICtrlCreateLabel("Aimbot Status: Off", 16, 624, 500, 33)

    GUISetState()
    If $Aimbot = 1 Then; Green
            $pos = MouseGetPos()
            $coord = PixelSearch(($pos[0] - 10) , ($pos[1] - 10) , ($pos[0] + 10) , ($pos[1] + 10), 0x00FF00)
            If IsArray($coord) = 1 Then
                
                MouseClick('left', $coord[0], $coord[1], 1, 0)
            EndIf
    EndIf   
        
        
        
    If $Aimbot = 2 Then; Red
            $pos = MouseGetPos()
            $coord = PixelSearch(($pos[0] - 10) , ($pos[1] - 10) , ($pos[0] + 10) , ($pos[1] + 10), 0xFF0000)
            If IsArray($coord) = 1 Then
                
                MouseClick('left', $coord[0], $coord[1], 1, 0)
            EndIf
        
    EndIf   
        
    WEnd    
        
        
        
        Func ToggleAimbot()
    If $Aimbot < 2 Then
        $Aimbot = $Aimbot + 1
    Else
        $Aimbot = 0
    EndIf
    Select
        Case $Aimbot = 0
            GUICtrlSetData($status, "Aimbot Status: Off")
        Case $Aimbot = 1
            GUICtrlSetData($status, "Aimbot Status: Green")
        Case $Aimbot = 2
            GUICtrlSetData($status, "Aimbot Status: Red")
        
    EndSelect
EndFunc  ;==>ToggleAimbot
    

Func TurnoffAimbot()
    $Aimbot = 0
    GUICtrlSetData($status, "Aimbot Status: Off")
EndFunc  ;==>TurnoffAimbot

Took a lot of it from Simucal's example.

"I think, therefore I am"[size="1"]René Descartes[/size]

Link to comment
Share on other sites

Some notes which might not deal with the problem, I'm assuming this script is as it is:

- Try to use If @error Then instead of IsArray, IMO it's better.

- Do you aware that you keep calling HotKeySet function over and over?

- Try to use ToolTip for this purpose it'll make sense as I see no GuiCreate call in the code.

- ...

Link to comment
Share on other sites

@dgarrett8

_IsArray is wrong there, use return value :)

Edit : place hotkeyset at top of your script and not in while :lmao:

Note : for delete your hotkey just do :

HotKeySet("{END}", "_Func");create
HotKeySet("{END}");delete

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Thank you Firefox and Authenticity. I tested this outside of Quake and it works perfectly, but in quake it has no effect. Why is that?

#include <GUIConstants.au3>
Global $Aimbot = 0, $found = "no"

WinActivate("Quake 3: Arena")

HotKeySet("{HOME}", "ToggleAimbot")
HotKeySet("{END}", "TurnoffAimbot")


While 1





    GUISetState()
    If $Aimbot = 1 Then; Green
            $pos = MouseGetPos()
            $coord = PixelSearch(($pos[0] - 20) , ($pos[1] - 20) , ($pos[0] + 20) , ($pos[1] + 20), 0x00FF00)
            If Not @error then
                
                MouseClick('left', $coord[0], $coord[1], 1, 0)
            EndIf
    EndIf   
        
        
        
    If $Aimbot = 2 Then; Red
            $pos = MouseGetPos()
            $coord = PixelSearch(($pos[0] - 10) , ($pos[1] - 10) , ($pos[0] + 10) , ($pos[1] + 10), 0xFF0000)
            If Not @error then
                
                MouseClick('left', $coord[0], $coord[1], 1, 0)
            EndIf
        
    EndIf   
        
    WEnd    
        
        
        
        Func ToggleAimbot()
    If $Aimbot < 2 Then
        $Aimbot = $Aimbot + 1
    Else
        $Aimbot = 0
    EndIf
    Select
        Case $Aimbot = 0
            ToolTip("Aimbot Status: Off",0,0)
        Case $Aimbot = 1
            ToolTip ("Aimbot Status: Green",0,0)
        Case $Aimbot = 2
            ToolTip("Aimbot Status: Red",0,0)
        
    EndSelect
EndFunc  ;==>ToggleAimbot
    

Func TurnoffAimbot()
    $Aimbot = 0
    ToolTip ("Aimbot Status: Off",0,0)
EndFunc  ;==>TurnoffAimbot

"I think, therefore I am"[size="1"]René Descartes[/size]

Link to comment
Share on other sites

I"ve cleaned your script a little bit, though I couldn't find why your script can't do the job. Read about the Opt function's option like - MouseCoordMode, MouseClickDelay or MouseClickDownDelay and play around with their values, maybe it'll make the change.

Opt('MustDeclareVars', 1)

Global $Aimbot = 0, $found = "no"

HotKeySet("{HOME}", "ToggleAimbot")
HotKeySet("{END}", "TurnoffAimbot")

WinActivate("Quake 3: Arena")


While 1
    
    Local $coord, $pos
    ; GuiSetState() <=== Completely useless.
    
    Select
        Case $Aimbot = 1 ; Green
            $pos = MouseGetPos()
            $coord = PixelSearch(($pos[0] - 20) , ($pos[1] - 20) , ($pos[0] + 20) , ($pos[1] + 20), 0x00FF00)
                If Not @error Then MouseClick('left', $coord[0], $coord[1], 1, 0)
        
        Case $Aimbot = 2 ; Red
            $pos = MouseGetPos()
            $coord = PixelSearch(($pos[0] - 10) , ($pos[1] - 10) , ($pos[0] + 10) , ($pos[1] + 10), 0xFF0000)
                If Not @error Then MouseClick('left', $coord[0], $coord[1], 1, 0)
            
    EndSelect

        Sleep(20)
WEnd    
        
        
        
Func ToggleAimbot()
    Select
        Case $Aimbot = 2
            ToolTip("Aimbot Status: Red",0,0)
                $Aimbot = 0
            
        Case $Aimbot = 1
            ToolTip ("Aimbot Status: Green",0,0)
                $Aimbot += 1
            
        Case $Aimbot = 0
            ToolTip("Aimbot Status: Off",0,0)
                $Aimbot += 1
        
    EndSelect
EndFunc  ;==>ToggleAimbot
    

Func TurnoffAimbot()
    $Aimbot = 0
    ToolTip ("Aimbot Status: Off",0,0)
EndFunc  ;==>TurnoffAimbot
Link to comment
Share on other sites

@Authenticity

Ty for cleaning it up, but some questions.

~ What does $Aimbot += 1 do that my script didn't do before?

~ What does Local do that my script didn't do before?

Do those things fit under the category of cleaning the script, or do they do something different?

I've tried using the Opt functions, none of them fix the problem.

"I think, therefore I am"[size="1"]René Descartes[/size]

Link to comment
Share on other sites

The Local word is necessary because we're now using the MustDeclareVars option so that it'll save you time to go figure why declaring variable $X = 5 and then doing something like that doesn't give you the desire effect ;] $Y = $x * 10 (understand?)

- $Aimbot += 1 is equivalent to $Aimbot = $Aimbot + 1 and it's more readable this way.

- I think you'll need to use some ConsoleWrite in some spots in your code to see what are the values and why it's not the other wanted way. Keep test it.

Link to comment
Share on other sites

I was looking around the helpmefile for mouse clicks and this function popped up. How would I use this in a script properly, such as searching an area of 10sq pixels of my mousepos. Is this much better than the normal mouseclick?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$winhandle = GUICreate("Win", 493, 220, 227, 202)
$Group1 = GUICtrlCreateGroup("Group1", 16, 8, 153, 185)
$Label1 = GUICtrlCreateLabel("", 180, 16, 200, 22)
$Label2 = GUICtrlCreateLabel("", 180, 48, 200, 22)
GUISetState(@SW_SHOW)


Do
$CursorInfo = GUIGetCursorInfo($winhandle)
if IsArray($CursorInfo) Then
GUICtrlSetData($Label1,"Mouse X coord \ Mouse left ===> " & $CursorInfo[0])
GUICtrlSetData($Label2,"Mouse Y coord \ Mouse top ====> " & $CursorInfo[1])
EndIf
$bool = Searching_Mouse(16 ,8,153,185,$winhandle) ; ===> Searching pos Group1 ("Group1", 16, 8, 153, 185)
if $bool = True Then MsgBox(0,"Mouse in Group1","OK")
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func Searching_Mouse($left ,$top,$width,$height,$win_handle)
$CursorInfo = GUIGetCursorInfo($win_handle)
if IsArray($CursorInfo) Then
if $CursorInfo[0] >= $left And $CursorInfo[0] <= ($left + $width ) And $CursorInfo[1] >= $top And $CursorInfo[1] <= ($top + $height) Then 
Return True
Else
Return False
EndIf
EndIf
EndFunc
Edited by wolf9228

صرح السماء كان هنا

 

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