Sign in to follow this  
Followers 0
kjpolker

Trouble "getting coordiantes"

3 posts in this topic

#1 ·  Posted (edited)

I want my button "$coords" to make it so you can click anywhere on the screen and it stores the X and Y values into the input boxes, but it's not. It just stays and won't do anything.

Take a look at the VERY bottom for: Func _get_mousepos()

There's the part of the code that's not working.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:Dazzled

 Script Function: 
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ImageListConstants.au3>
#Include <GuiMenu.au3>
#include <GuiComboBoxEx.au3>
#include <GUIButton.au3>
#Include <GuiSlider.au3>
#include <IE.au3>
#include <SliderConstants.au3>
#include <StructureConstants.au3>

FileInstall("C:\Users\Kevin\Desktop\Stinky Pete\Images\Icon.ico", @Scriptdir & "\Images\Icon.ico")
FileInstall("C:\Users\Kevin\Desktop\Stinky Pete\Images\Info.ico", @Scriptdir & "\Images\Info.ico")
FileInstall("C:\Users\Kevin\Desktop\Stinky Pete\Images\Coord.ico", @Scriptdir & "\Images\Coord.ico")
FileInstall("C:\Users\Kevin\Desktop\Stinky Pete\Images\StinkyPeteBG.jpg", @Scriptdir & "\Images\StinkyPeteBG.jpg")


HotKeySet( "{PAUSE}", "TogglePause")
Global $Paused

#Region ### START Koda GUI section ### Form=
$main = GUICreate("Stinky Pete", 301, 201, -1, -1)
GUISetIcon(@Scriptdir & "\Images\Icon.ico")
$Website = GUICtrlCreateButton("Info", 232, 120, 61, 75, BitOR($BS_ICON,$WS_GROUP))
GUICtrlSetImage(-1, @Scriptdir & "\Images\Info.ico", -1)
GUICtrlSetCursor (-1, 0)
Global $slider1 = GUICtrlCreateSlider(10, 175, 100, 20)
GUICtrlSetBkColor(-1,0)
GUICtrlSetLimit(-1, 255, 126)
GUICtrlSetData(-1, 255)
GUISetState()
$Xcoord = GUICtrlCreateInput("X-Coordinate", 8, 74, 57, 21)
$Ycoord = GUICtrlCreateInput("Y-Coordiante", 8, 98, 57, 21)
$coords = GUICtrlCreateButton("", 8, 130, 57, 41, BitOR($BS_ICON,$WS_GROUP))
GUICtrlSetImage(-1, @Scriptdir & "\Images\Coord.ico", -1)
GUICtrlSetCursor (-1, 0)
$start = GUICtrlCreateButton("Start!", 112, 160, 110, 33, $WS_GROUP)
GUICtrlSetCursor (-1, 0)
$background = GUICtrlCreatePic(@Scriptdir & "\Images\StinkyPeteBG.jpg", 0, 0, 300, 200)
GUISetState(@SW_SHOW, $main)
#EndRegion ### END Koda GUI section ###

WinSetOnTop("[CLASS:AutoIt v3 GUI]", "", 1)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $slider1
            WinSetTrans($main, "", GUICtrlRead($slider1))
            ToolTip("")
            sleep (100)
        Case $Website
            ToolTip("")
            ShellExecute("http://www.Google.com")
        Case $coords
            ToolTip('Please click anywhere on the screen to set your coordinates', 0, 0)
            _get_mousepos()
            ToolTip("")
        Case $start
            GUICtrlSetData($start, "Stop!")
            TooLTip('', 0, 0)
            _start()
            ToolTip("")
    EndSwitch
WEnd

Opt("TrayIconHide", 1)

Func TogglePause()
    If GUICtrlRead($start) = "Start!" Then Return
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip("", 0, 0)
    WEnd
    ToolTip("")
EndFunc

Func _start()
    Local $start, $X_Pos, $Y_Pos, $Xcoord, $Ycoord
    $X_Pos = GUICtrlRead($Xcoord)
    $Y_Pos = GUICtrlRead($Ycoord)
    While 1
    MouseClick("right", $X_Pos, $Y_Pos, 1)
    Sleep(3250)
    MouseClick("left", $X_Pos, $Y_Pos, 1)
    SLeep(200)
    MouseClick("left", $X_Pos, $Y_Pos+20, 1)
    SLeep(200)
    MouseClick("left", $X_Pos, $Y_Pos+40, 1)
    SLeep(200)
    MouseClick("left", $X_Pos, $Y_Pos+60, 1)
    Sleep(1000)
WEnd
EndFunc
    
Func _get_mousepos()
    Local $coords
    If GUICtrlRead($coords) = "Stop!" Then Return
    Local $dll = DllOpen("user32.dll")
    While Not _IsPressed("01", $dll)
        Sleep(10)
    WEnd
    DllClose($dll)
    Local $Mouse_Pos = MouseGetPos()
    GUICtrlSetData($Xcoord, $Mouse_Pos[0])
    GUICtrlSetData($Ycoord, $Mouse_Pos[1])
EndFunc
Edited by kjpolker

Share this post


Link to post
Share on other sites



Case $start

TooLTip('The mining bot has begun! Be sure to keep your World of Warcraft window active at all times!', 0, 0)

Game Bots

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

I think the link needs to be added to the auto-insert section with autoit, trac and twitter. :mellow:

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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