Jump to content

Mouse Emulation


Recommended Posts

hey. I'm making a bot for a game that would assist you shile playing the game (eating food). This bot is meant to be used while the player is still playing the game. I have my bot up and working but it would really be a lot more useful if... autoit didn't move the mouse as i was trying to play the game. I have tried a few things to solve this but i haven't had any luck yet. Basically, I need autoit to have its own seperate cursor that it would control (or something that would work the same way). having it quickly click and then move the mouse back to where it was will not work. thanks in advance,

Kyler

Link to comment
Share on other sites

  • Moderators

1. Welcome to the forum

2. What is the name of the game?

3. You may be able to use ControlClick()

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.

Link to comment
Share on other sites

thanks. the name of the game is Runescape. i dun really understand the control click... but basically it should be moving the mouse on its own and clicking on food when it needs to... i dunno if that would work in RS or not. If you can tell me how to add that... since the help file (what i have learned everything in so far) doesn't go too in depth about it.

#include <GUIConstants.au3>
#include <File.au3>


;######Variables#########
$location = "C:\RSEB.ini"

$count = 0
$eat = ""
$check = ""

$hp_bottom = 0
$hp_left = ""
$hp_right = ""
$hp_top = ""

$inv_bottom = 0
$inv_left = ""
$inv_right = ""
$inv_top = ""

$food = ""
$color = ""

$num = ""
$input = ""
$input_1 = ""
$Input_2 = ""
$Input_3 = ""
$Input_4 = ""
$Input_5 = ""
$life = ""
$heal = ""

$rand = 0
$rand_51 = ""
$rand_52 = ""

$pack_left = ""
$pack_top = ""
$pack_right = ""
$pack_bottom = ""
$pack_x = ""
$pack_y = ""

$button_6 = ""
$slider = ""
$slider1 = "55"
$trans = 235
$trans2 = 0

;#######Saved Variables######

$hit = IniRead($location,"hitpoints", "$hit", "0")
$hp_left = IniRead($location,"Coords", "$hp_left", "0")
$hp_top = IniRead($location,"Coords", "$hp_top", "0")
$hp_right = IniRead($location,"Coords", "$hp_right", "0")
$hp_bottom =IniRead($location,"Coords", "$hp_bottom", "0")
$inv_left  =IniRead($location,"Coords", "$inv_left", "0")
$inv_top  =IniRead($location,"Coords", "$inv_top", "0")
$inv_right  =IniRead($location,"Coords", "$inv_right", "0")
$inv_bottom  =IniRead($location,"Coords", "$inv_bottom", "0")
$trans = IniRead($location, "Trans","$trans","235")




;###### GUI ######

Opt("GUICoordMode", 1)
GUICreate("Runecsape Eating Bot --- By: «  K¥£R  »", 400,370)
WinSetTrans("Runecsape Eating Bot --- By: «  K¥£R  »","", $trans)

$file = GUICtrlCreateMenu ("&File")
$file_save = GUICtrlCreateMenuitem ("Save settings",$file)
$file_delete = GUICtrlCreateMenuitem ("Delete settings",$file)
$file_exit = GUICtrlCreateMenuitem ("Exit",$file)

$view = GUICtrlCreateMenu ("&View")
$view_trans = GUICtrlCreateMenuitem("Set transparancy",$view)

$food = GUICtrlCreateGroup ("Type of Food", 30, 30, 145, 180)
GUIStartGroup()
    $radio_1 = GUICtrlCreateRadio ("Lobster", 50, 60, 70, 20)
    $radio_2 = GUICtrlCreateRadio ("Swordfish", 50, 90, 70, 20)
    $radio_3 = GUICtrlCreateRadio ("Tuna", 50, 120, 70, 20)
    $radio_4 = GUICtrlCreateRadio ("Shark", 50, 150, 70, 20)
    $radio_5 = GUICtrlCreateRadio ("Other", 50, 180, 70, 20)
if $num = 1 then GUICtrlSetState ( $radio_1 ,$GUI_CHECKED)
if $num = 2 then GUICtrlSetState ( $radio_2 ,$GUI_CHECKED)
if $num = 3 then GUICtrlSetState ( $radio_3 ,$GUI_CHECKED)
if $num = 4 then GUICtrlSetState ( $radio_4 ,$GUI_CHECKED)
if $num = 5 then GUICtrlSetState ( $radio_5 ,$GUI_CHECKED)
GUICtrlCreateGroup ("Hitpoints?", 30, 240, 145, 50)
GUIStartGroup()
    $input = GUICtrlCreateInput( $hit , 50, 260, 105, 20)
    $button_1 = GUICtrlCreateButton("Run Bot",70,300,60,30)
    $button_2 = GUICtrlCreateButton("Cancel",270,300,60,30)
GUICtrlCreateGroup ("Set Locations", 225, 30, 145, 130)
GUIStartGroup()
    If $hp_bottom = 0 Then $button_3 = GUICtrlCreateButton("Set HP bar", 245, 60, 105,30)
    if $hp_bottom <> 0 Then $button_3 = GUICtrlCreateButton("Reset HP bar", 245, 60, 105,30)
    If $inv_bottom = 0 Then $button_4 = GUICtrlCreateButton("Set Invintory", 245, 110, 105,30)
    If $inv_bottom <> 0 Then $button_4 = GUICtrlCreateButton("Reset Invintory", 245, 110, 105,30)
GUICtrlCreateGroup ("Other Config", 225, 185, 145, 105)
GUIStartGroup()
    $button_5 = GUICtrlCreateButton("Set color", 245, 215, 105,30)
    $input2 = GUICtrlCreateInput("HP healed by food", 245, 260, 105, 20)

GUISetState ()


While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then exit1();ExitLoop
    If $msg = $button_1 Then eat_check()
    if $msg = $button_2 then exit1()
    if $msg = $file_exit then exit1()
    If $msg = $button_3 Then hp_choose()
    If $msg = $button_4 Then inv_choose()
    If $msg = $button_5 Then Color()
    if $msg = $file_delete then FileDelete($location) 
    if $msg = $file_save then ini_save()
    if $msg = $view_trans Then
        $i = 0
        If $trans2 = 0 then $trans1 = $trans
        GUICreate("Transparency",200,120)
        $slider1 = GUICtrlCreateSlider(20,40,160,30)
        GUICtrlSetLimit(-1,255,63.75)
        If $trans2 = 0 Then GUICtrlSetData($slider1, $trans)
        If $trans2 = 1 Then
            GUICtrlSetData($slider1, $trans1)
            $trans2 = 0
        EndIf
        $oldvalue = GUICtrlRead($slider1)
        GUICtrlCreateLabel( round(guictrlread($slider1) / 2.55,0) & "%" ,75,20,50,20)
        $button_6 = GUICtrlCreateButton("Set",70,90,50,20)
        GUICtrlCreateLabel( "More", 20, 20, 40, 20)
        GUICtrlCreateLabel( "Less", 150, 20, 40, 20)
        GUISetState()
        Do
        $msg = GUIGetMsg()
            If $oldvalue <> GUICtrlRead($slider1) Then
                $oldvalue = GUICtrlRead($slider1)
                $Status = GUICtrlCreateLabel( round(guictrlread($slider1) / 2.55,0) & "%" ,75,20,50,20)
                $trans = $oldvalue
                WinSetTrans("Runecsape Eating Bot --- By: «  K¥£R  »","", $trans)
            EndIf
            If $msg = $button_6 Then
                GUISetState( @SW_HIDE )
                $trans = guictrlread($slider1)
                WinSetTrans("Runecsape Eating Bot --- By: «  K¥£R  »","", $trans)
                $i = 1
            EndIf
            If $msg = $GUI_EVENT_CLOSE Then 
                $i = 1
                WinSetTrans("Runecsape Eating Bot --- By: «  K¥£R  »","", $trans1)
                $trans2 = 1
                GUISetState( @SW_HIDE )
            EndIf
        Until $i = 1
    EndIf
    
    Select
       ;<===Lobster===>
        Case $msg = $radio_1
            $food = "0xB35E14"
            $rand = 1
            $heal = 12
            IniWrite($location, "food1","$food1", "1")
       ;<===Swordies===>
        Case $msg = $radio_2
            $food = "0x73517A"
            $rand = 2
            $heal = 14
            IniWrite($location, "food1","$food1", "2")
       ;<===Tuna===>
        Case $msg = $radio_3
            $food = "0x685652"
            $rand = 3
            $heal = 10
            IniWrite($location, "food1","$food1", "3")
       ;<===Shark===>
        Case $msg = $radio_4
            $food = "0x664E39"
            $rand = 4
            $heal = 20
            IniWrite($location, "food1","$food1", "4")
       ;<===Other===>
        Case $msg = $radio_5
            $food = "0x" & hex($color, 6)
            $rand = 5
            $heal = GuiCtrlRead($Input2)
            IniWrite($location, "food1","$food1", "5")
    EndSelect
Wend


;###### Functions ######
Func ini_save(); <=== Saves options in an .ini
    IniWrite($location, "hitpoints","$hit", $hit)
    IniWrite($location,"Coords","$hp_left", $hp_left)
    IniWrite($location,"Coords","$hp_top", $hp_top)
    IniWrite($location,"Coords","$hp_right", $hp_right)
    IniWrite($location,"Coords","$hp_bottom", $hp_bottom)
    IniWrite($location,"Coords","$inv_left", $inv_left)
    IniWrite($location,"Coords","$inv_top", $inv_top)
    IniWrite($location,"Coords","$inv_right", $inv_right)
    IniWrite($location,"Coords","$inv_bottom", $inv_bottom)
    IniWrite($location, "Trans", "$trans", $trans)
EndFunc


Func hp_choose(); <=== Creates tooltip for autofinding HP bar
    HotKeySet("{f6}", "auto_hp")
    ToolTip('Attempting to autofind your HP bar. Move your mouse slightly above your HP bar and slightly to the left of it and press "F6". Your HP bar must be visible', 0, 0)
EndFunc

Func auto_hp(); <=== Autofinds HP bar location
    $pos = MouseGetPos()
    $coord = PixelSearch(($pos[0] - 20) , ($pos[1] - 20) , ($pos[0] + 20) , ($pos[1] + 20), 0x00FF00 )
    If IsArray($coord) = 1 Then
        $hp_left = $coord[0] - 17
        $hp_top = $coord[1] -17
        $hp_right = $hp_left + 65
        $hp_bottom = $hp_top + 35
        ToolTip("" , 0, 0)
    Else
        HotKeySet("{f7}", "hp_area"); <=== Tooltip for manually finding HP bar location
        ToolTip('Autofind unsuccessful. Press "F7" to set the position of your HP bar.  You should set it a little above your bar and a little to the left.', 0, 0)
    EndIf
EndFunc


Func color(); <=== Creates tooptip for finding color of "other food"
    HotKeySet("{f9}", "color_set")
    ToolTip('Press "F9" to set the color of your food.  You should choose a color unique to that food and that is in the upper left corner of the food.', 0, 0)
EndFunc


Func Color_Set(); <=== Select color of "other food"
$pos1 = MouseGetPos()
    If IsArray($pos1) = 1 Then
        $color = PixelGetColor( $pos1[0] , $pos1[1] )
    EndIf
    ToolTip("" , 0, 0)
    $food = "0x" & hex($color, 6)
EndFunc



Func hp_area(); <=== Sets coords of HP bar after manual finding
    $pos = MouseGetPos()
    $hp_left = $pos[0]
    $hp_top = $pos[1]
    $hp_right = $pos[0] + 65
    $hp_bottom = $pos[1] + 35
    ToolTip("" , 0, 0)
EndFunc


Func inv_choose(); <=== Tooltip for invintory
    HotKeySet("{f8}", "auto_inv")
    ToolTip('Attempting to autofind your invintory. Move your mouse slightly above  slightly to the left of the upper left corner of your invintory  and press "F8".', 0, 0)
EndFunc

Func auto_inv(); <=== Autofinds invintory
    $pos = MouseGetPos()
    $coord = PixelSearch(($pos[0] - 50) , ($pos[1] - 50) , ($pos[0] + 50) , ($pos[1] + 50), 0x00B500 )
    If IsArray($coord) = 1 Then
        $inv_left = $coord[0] - 31
        $inv_top = $coord[1] + 27
        $inv_right = $inv_left + 195
        $inv_bottom = $inv_top + 260
        ToolTip("" , 0, 0)
    Else
        HotKeySet("{f10}", "inv_area"); <=== Tooltip for manually finding invintory location
        ToolTip('Autofind unsuccessful. Press "F10" to set the position of your HP bar.  You should set it a little above your bar and a little to the left.', 0, 0)
    EndIf
EndFunc


Func inv_area(); <=== Sets coords of invintory 
    $pos1 = MouseGetPos()
    $inv_left = $pos1[0]
    $inv_top = $pos1[1]
    $inv_right = $pos1[0] + 195
    $inv_bottom = $pos1[1] + 260
    ToolTip("" , 0, 0)
EndFunc


Func rand(); <=== Random amount to move from pixel color on food
If $rand = 1 Then 
    $rand_51 = random(1,8) - random(2,10)
    $rand_52 = random(2,12)
EndIf
If $rand = 2 Then 
    $rand_51 = random(2,10) - random(1,3)
    $rand_52 = random(1,11)
EndIf
If $rand = 3 Then 
    $rand_51 = random(3,9) - random(2,8)
    $rand_52 = random(3,13)
EndIf
If $rand = 4 Then 
    $rand_51 = random(3,10) - random(2,6)
    $rand_52 = Random(0,8)
EndIf
If $rand = 5 Then 
    $rand_51 = random(1,7) - random(1,7)
    $rand_52 = random(1,10)
EndIf
EndFunc


Func eat_check(); <=== Checks to make sure that all options have been set
    $check = 0
    If $rand = 5 Then $heal = GuiCtrlRead($Input2)
    $hit = GuiCtrlRead($Input)
    If $rand = 0 Then $check = $check + 1
    If $rand = 5 and $heal = "HP healed by food" Then $check = $check + 2
    If $rand = 5 And $food = "0x000000" Then $check = $check + 4
    If $hit = 0 Then $check = $check + 8
    If $hp_bottom = 0 Then $check = $check + 16
    If $inv_bottom = 0 Then $check = $check + 32
    
    If $check = 0 Then eat()
    If $check = 1 Then MsgBox(0,"Please set all options.","Please select a type of food.")
    If $check = 2 Then MsgBox(0,"Please set all options.","Please set the amount of HP healed by your food.")
    If $check = 4 Then MsgBox(0,"Please set all options.","Please set a color for your food.")
    If $check = 6 Then MsgBox(0,"Please set all options.","Please set a color for your food and set the amount of HP healed by your food.")
    If $check = 8 Then MsgBox(0,"Please set all options.","Please set your HP.")
    If $check = 9 Then MsgBox(0,"Please set all options.","Please set your HP and select a type of food.")
    If $check = 10 Then MsgBox(0,"Please set all options.","Please set your HP and set the amount of HP healed by your food.")
    If $check = 12 Then MsgBox(0,"Please set all options.","Please set your HP and set a color for your food.")
    If $check = 14 Then MsgBox(0,"Please set all options.","Please set your HP, set a color for your food, and set the amount of HP healed by your food.")
    If $check = 16 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar.")
    If $check = 17 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar and select a type of food.")
    If $check = 18 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar and set the amount of HP healed by your food.")
    If $check = 20 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar and set a color for your food.")
    If $check = 22 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar, set a color for your food, and set the amount of HP healed by your food.")
    If $check = 24 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar and set your HP.")
    If $check = 25 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar, set your HP, and select a type of food.")
    If $check = 26 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar, set your HP, and set the amount of HP healed by your food.")
    If $check = 28 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar, set your HP, and set a color for your food.")
    If $check = 30 Then MsgBox(0,"Please set all options.","Please set the location of your HP bar, set your HP, set a color for your food, and set the amount of HP healed by your food.")
    If $check = 32 Then MsgBox(0,"Please set all options.","Please set the location of your invintory.")
    If $check = 33 Then MsgBox(0,"Please set all options.","Please set the location of your invintory and select a type of food.")
    If $check = 34 Then MsgBox(0,"Please set all options.","Please set the location of your invintory and set the amount of HP healed by your food.")
    If $check = 36 Then MsgBox(0,"Please set all options.","Please set the location of your invintory and set a color for your food.")
    If $check = 38 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set a color for your food and, set the amount of HP healed by your food.")
    If $check = 40 Then MsgBox(0,"Please set all options.","Please set the location of your invintory and set your HP.")
    If $check = 41 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set your HP, and select a type of food.")
    If $check = 42 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set your HP, and set the amount of HP healed by your food.")
    If $check = 44 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set your HP, and set a color for your food. ")
    If $check = 46 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set your HP, set a color for your food, and set the amount of HP healed by your food.")
    If $check = 48 Then MsgBox(0,"Please set all options.","Please set the location of your invintory and set the location of your HP bar.")
    If $check = 49 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar, and select a type of food.")
    If $check = 50 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar and, set the amount of HP healed by your food.")
    If $check = 52 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar and set a color for your food.")
    If $check = 54 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar, set a color for your food, and set the amount of HP healed by your food.")
    If $check = 56 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar, and set your HP.")
    If $check = 57 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar, set your HP, and select a type of food.")
    If $check = 58 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar, set your HP, and set the amount of HP healed by your food.")
    If $check = 60 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar, set your HP, and set a color for your food.")
    If $check = 62 Then MsgBox(0,"Please set all options.","Please set the location of your invintory, set the location of your HP bar, set your HP, set a color for your food, and set the amount of HP healed by your food.")
    
    ini_save()

EndFunc


Func eat(); <=== Actually does the autoeating

$i = 0

if $hit > 100 then $hit = $hit / 20
$input_2 = 30 / $hit
$input_3 = $hit - $heal 
$input_4 = $input_3 * $input_2 
$input_5 = round($Input_4 - 0.49,0)
If $life < 10 then $life = 10
$life = $input_5 -4


$pack_left = $inv_left +72
$pack_top = $inv_top  - 33
$pack_right = $inv_left + 114
$pack_bottom = $inv_top - 2
    
HotKeySet("{esc}","exit1")
GUISetState( @SW_HIDE )

ini_save()

do
$pack_x = $pack_left + Random(5,35)
$pack_y = $pack_top + Random(5,25)

rand()

$coord = pixelsearch( $hp_left, $hp_top, $hp_right, $hp_bottom, 0x00FF00)
If IsArray($coord) = 1 Then
    $left = $coord[0] + $life
    $top = $coord[1]
    $right = $left + 3
    $bottom = $top + 3
    $coord2 = pixelsearch($left,$top,$right,$bottom,0xFF0000)
        If IsArray($coord2) = 1 Then
        sleep(random(995,1250))
        $coord11 = pixelsearch( $hp_left, $hp_top, $hp_right, $hp_bottom, 0x00FF00)
            If IsArray($coord11) = 1 Then
            $left = $coord[0] + $life
            $top = $coord[1]
            $right = $left + 3
            $bottom = $top + 3
            $coord22 = pixelsearch($left,$top,$right,$bottom,0xFF0000)
                If IsArray($coord22) = 1 Then
                    $pack = PixelSearch($pack_left,$pack_top, $pack_right, $pack_bottom,0x7E2B2B,5)
                        if IsArray($pack)  Then
                            sleep(random(335,690))
                            $coord5 = pixelsearch($inv_left,$inv_top,$inv_right,$inv_bottom,$food,2)
                            if IsArray($coord5) = 1 Then
                                $coord51 = $coord5[0] + $rand_51;+ random(0,3) - random(1,7)
                                $coord52 = $coord5[1] + $rand_52;+ random(4,11)
                                sleep(random(105,195))
                                Mouseclick( "left", $coord51, $coord52, 0, round(random(4,8),0))
                                sleep(random(95,121))
                                Mouseclick( "left", $coord51, $coord52, 1, round(random(6,10),0))
                                sleep(random(390,424))
                                $m = round(random(1,4),0)
                     
                                if $m = 1 then
                                    $x = $coord[0]  + random(0,15) - random(0,15)
                                    $y = $coord[1] + random(3,15)
                                    MouseMove($x,$y,random(5,15))
                                endif
                                if $m = 2 Then
                                EndIf
                                if $m = 3 Then
                                    $x = random(260,775)
                                    $y = random(145,480)
                                    MouseMove($x,$y,random(5,15))
                                EndIf
                                if $m = 4 then
                                    $x = $coord[0]  + random(0,50) - random(0,50)
                                    $y = $coord[1] + random(5,60) - random(5,30)
                                    MouseMove($x,$y,random(5,15))
                                endif
                                sleep(random(3390,4124))
                            EndIf
                            Else
                          ; MsgBox(0,"", $pack_x & " " & pack_y)
                            MouseClick("left", $pack_x, $pack_y,1,random(5,10))
                            sleep(random(380,720))
                        EndIf
                    EndIf
                EndIf
                sleep(Random(695,955))
            Else
                sleep(random(360,450))
                EndIf
            EndIf
            sleep(random(95,105))
        until $i = 1
        
    

EndFunc
    

Func exit1(); <=== Exits
    ini_save()
    Exit
EndFunc

also... script is messy, i know but its still in dev and its only like my 2nd week using autoit

Link to comment
Share on other sites

  • Moderators

Have you looked at the function in the Help File?

ControlClick ( "title", "text", controlID [, button] [, clicks]] )

You hold the AutoInfo tool over the control you want to click, if it has a ControlID you may not need to use MouseClick(), you can do ControlClick() so you would just replace all of your MouseClick() functions with ControlClick() functions. What don't you understand about it specifically... Maybe we could explain better.

If this doesn't work, then do a search for MouseClickPlus() / or ClickInControl() in the forum... (If ControlClick() doesn't work, I doubt ClickInControl() will)

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.

Link to comment
Share on other sites

ok, the main reason that i wasn't getting the control click was that i wasn't getting a control ID from window info. now it makes more sense that it just won't work. as for the mouseclickplus() this is the code i am trying to test it but it isn't clicking on the screen.

;===============================================================================
;
; Function Name:  _MouseClickPlus()
; Version added:  0.1
; Description:  Sends a click to window, not entirely accurate, but works 
;                minimized.
; Parameter(s):   $Window    =  Title of the window to send click to
;                $Button     =  "left" or "right" mouse button
;                $X       =  X coordinate
;                $Y       =  Y coordinate
;                $Clicks     =  Number of clicks to send
; Remarks:      You MUST be in "MouseCoordMode" 0 to use this without bugs.
; Author(s):      Insolence <insolence_9@yahoo.com>
;
;===============================================================================
Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON    =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP    =  0x0202
  
  Local $MK_RBUTTON    =  0x0002   
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP    =  0x0205

  Local $WM_MOUSEMOVE    =  0x0200
  
  Local $i              = 0
  
  Select 
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
  
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
  
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc




Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

_mouseclickplus("RuneScape - the massive online adventure game by Jagex Ltd - Windows Internet Explorer","left",572,410,1)

am i doing something wrong or is it that none of these will work?

EDIT: Runescape is java based so... could that be why none of this is working?

Edited by Kyler Carlson
Link to comment
Share on other sites

Func QuickClick($button="left",$x,$y,$clicks=1)
     Local $Pos = MouseGetPos()
     MouseClick($button,$x,$y,$clicks,0)
     MouseMove($Pos[0],$Pos[1],0)
EndFunc

Made just for you. You won't notice it's there. I use this for many games, in which i only want help when playing.

Edit: RuneScape doesn't allow ControlGetText or ControlClick/ControlSend. All you can do with the control is determine the size of the window, and it's position. Which is still very usefull to any scripted, this allows you to script it for variable window circumstances.

Edit: I have found a bug

Edited by Manadar
Link to comment
Share on other sites

  • Moderators

Func QuickClick($button,$x,$y)
     Local $Pos = MouseGetPos()
     MouseClick($button,$x,$y,0)
     MouseMove($Pos[0],$Pos[1],0)
EndFunc
That's funny :wacko:... might actually work, but your brain had better be multi tasked!! :D

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.

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