Sign in to follow this  
Followers 0
kjpolker

Cannot read/write from input!

14 posts in this topic

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

Share this post


Link to post
Share on other sites



The variable $Mouse_Pos is declared locally in the _get_mousepos() function, so it's values don't make to $Xcoord and $Ycoord. Declare it globally, after $Paused.


- 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

Func _get_mousepos()
    Local $start
    If GUICtrlRead($start) = "Stop!" Then Return
    Local $dll = DllOpen("user32.dll")
    While Not _IsPressed("01", $dll)
        Sleep(10)
    WEnd
    DllClose($dll)
    $Mouse_Pos = MouseGetPos()
    GUICtrlSetData($Xcoord, $Mouse_Pos[0])
    GUICtrlSetData($Ycoord, $Mouse_Pos[1])
EndFunc

The whole first part of the function I have must be causing the problem (with the DLL)With it my button does absolutely nothing at all when clicked, but if I remove it than when I click the button it gets the coordinates of exactly where I clicked. It won't wait until the second left click to get the coordinates.

Also why won't my button change to "Stop!" when clicked?

Case $start
            GUICtrlSetData($start, "Stop!")
            TooLTip('', 0, 0)
            _start()

Share this post


Link to post
Share on other sites

What about this:

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

 AutoIt Version: 3.3.0.0
 Author:Dazzled

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
#Include <Misc.au3>
#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, Default, $WS_EX_TOPMOST)
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))
GUICtrlSetTip(-1, "Please click anywhere on the screen to set your coordinates")
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))
    Case $Website
    ShellExecute("http://www.Google.com")
    Case $coords

    Case $start
    GUICtrlSetData($start, "Stop!")
    _start()
    EndSwitch
    _get_mousepos()
WEnd

Opt("TrayIconHide", 1)

Func TogglePause()
    If GUICtrlRead($start) = "Start!" Then Return
    $Paused = Not $Paused
    While $Paused
    Sleep(100)
    WEnd
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
    If _IsPressed("01") Then
        Local $Mouse_Pos = MouseGetPos()
        GUICtrlSetData($Xcoord, $Mouse_Pos[0])
        GUICtrlSetData($Ycoord, $Mouse_Pos[1])
    EndIf
EndFunc

BR,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Gives an error for line 85:

If _IsPressed("01") Then

Says unknown function. Not sure exactly what all is happening in this code.

Share this post


Link to post
Share on other sites

#Include <Misc.au3> is probably missing.

Did you test my posted code or just replaced the function?

BR,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Replaced the function, how much of it changed?

Share this post


Link to post
Share on other sites

Not so much - just compare it :mellow:

BR,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Okay so with your script it will get the coords when you "click" $coords button, and then again when you click a second time, how to remove the first one? And when you click on Start why is it clicking at 0,0 and not the coords?

Edited by kjpolker

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Okay so with your script it will get the coords when you "click" $coords button, and then again when you click a second time, how to remove the first one? And when you click on Start why is it clicking at 0,0 and not the coords?

The button $coords has no functionality yet - you can press lmb anywhere to get the coordinates!

Further you used Local $Xcoord, $Ycoord in Func _start() which will erase both variables! :mellow:

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

 AutoIt Version: 3.3.0.0
 Author:Dazzled

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
#Include <Misc.au3>
#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, Default, $WS_EX_TOPMOST)
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))
GUICtrlSetTip(-1, "Please click anywhere on the screen to set your coordinates")
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))
    Case $Website
    ShellExecute("http://www.Google.com")
    Case $coords

    Case $start
    GUICtrlSetData($start, "Stop!")
    _start()
    EndSwitch
    _get_mousepos()
WEnd

Opt("TrayIconHide", 1)

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

Func _start()
    Local $start, $X_Pos, $Y_Pos
    $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
    If _IsPressed("01") Then
    Local $Mouse_Pos = MouseGetPos()
    GUICtrlSetData($Xcoord, $Mouse_Pos[0])
    GUICtrlSetData($Ycoord, $Mouse_Pos[1])
    EndIf
EndFunc


Exit

BR,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Well what I want it to do is when I click "get coords" I can click anywhere on the screen and it gets the coords, than locks them, so no matter how many more times I click nothing happens. it's a 1 click 1 time button until clicked again, than for "start" it does the simple loop indefinitely until I click "stop!" so let me repost my original script since it is slightly changed and maybe we can figure it out I hope.

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

 AutoIt Version: 3.3.0.0
 Author:Dazzled

 Script Function: 
    Template AutoIt script.

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

#Include <Misc.au3>
#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, $Mouse_Pos

#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()
        Case $start
            GUICtrlSetData($start, "Stop!")
            TooLTip('', 0, 0)
            _start()
    EndSwitch
WEnd

Opt("TrayIconHide", 1)

Func _get_mousepos()
    Local $coords
;~  If GUICtrlRead($coords) = "Stop!" Then Return
    If _IsPressed("01") Then
        Local $Mouse_Pos = MouseGetPos()
        GUICtrlSetData($Xcoord, $Mouse_Pos[0])
        GUICtrlSetData($Ycoord, $Mouse_Pos[1])
    EndIf
EndFunc

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 = GUICtrlRead($Xcoord)
        $Y = GUICtrlRead($Ycoord)
    While 1
    MouseClick("right", $X, $Y, 1)
    Sleep(3250)
    MouseClick("left", $X, $Y, 1)
    SLeep(200)
    MouseClick("left", $X, $Y+20, 1)
    SLeep(200)
    MouseClick("left", $X, $Y+40, 1)
    SLeep(200)
    MouseClick("left", $X, $Y+60, 1)
    Sleep(1000)
WEnd
EndFunc

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Well what I want it to do is when I click "get coords" I can click anywhere on the screen and it gets the coords, than locks them, so no matter how many more times I click nothing happens. it's a 1 click 1 time button until clicked again, than for "start" it does the simple loop indefinitely until I click "stop!" so let me repost my original script since it is slightly changed and maybe we can figure it out I hope.

Your code design is not good to implement your items properly. Why? Because how you want to check the start/stop button when your script is performing the _start() function in While/Wend loop incl. sleep()?

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

 AutoIt Version: 3.3.0.0
 Author:Dazzled

 Script Function:
    Template AutoIt script.

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

#Include <Misc.au3>
#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, $Mouse_Pos

#Region ### START Koda GUI section ### Form=
$main = GUICreate("Stinky Pete", 301, 201, -1, -1, Default, $WS_EX_TOPMOST) ;<------------- changed
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)

$coords_check = -1 ;<------------- changed
$start_chk = -1 ;<------------- changed
AdlibRegister("Check", 100) ;<------------- changed

While Sleep(30) ;<------------- changed
    If $coords_check = 1 Then _get_mousepos() ;<------------- changed
    If $start_chk = 1 Then _start() ;<------------- changed
WEnd

AdlibUnRegister("Check") ;<------------- changed

Opt("TrayIconHide", 1)

Func Check()
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $nMsg = $slider1
    WinSetTrans($main, "", GUICtrlRead($slider1))
    ToolTip("")
;~ sleep (100) ;<------------- changed
    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() ;<------------- changed
    $coords_check *= -1 ;<------------- changed
    Case $start
    If $start_chk = -1 Then ;<------------- changed
    GUICtrlSetData($start, "Stop!")
    $start_chk *= -1 ;<------------- changed
;~  _start()
    Else ;<------------- changed
    GUICtrlSetData($start, "Start!") ;<------------- changed
    $start_chk *= -1 ;<------------- changed
    EndIf
    TooLTip('', 0, 0)
;~ _start() ;<------------- changed
    EndSwitch
EndFunc

Func _get_mousepos()
    Local $coords
;~ If GUICtrlRead($coords) = "Stop!" Then Return
    If _IsPressed("02") Then ;<------------- changed
    Local $Mouse_Pos = MouseGetPos()
    GUICtrlSetData($Xcoord, $Mouse_Pos[0])
    GUICtrlSetData($Ycoord, $Mouse_Pos[1])
    EndIf
EndFunc

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 ;<------------- changed
    $X = GUICtrlRead($Xcoord)
    $Y = GUICtrlRead($Ycoord)
    While $start_chk = 1    ;<------------- changed
    MouseClick("right", $X, $Y, 1)
    Sleep(3250)
    If $start_chk = -1 Then ExitLoop ;<------------- changed
    MouseClick("left", $X, $Y, 1)
    SLeep(200)
    If $start_chk = -1 Then ExitLoop ;<------------- changed
    MouseClick("left", $X, $Y+20, 1)
    SLeep(200)
    If $start_chk = -1 Then ExitLoop ;<------------- changed
    MouseClick("left", $X, $Y+40, 1)
    SLeep(200)
    If $start_chk = -1 Then ExitLoop ;<------------- changed
    MouseClick("left", $X, $Y+60, 1)
    Sleep(1000)
    If $start_chk = -1 Then ExitLoop ;<------------- changed
WEnd
EndFunc

Exit

BR,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Okay so it finally does what I originally wanted it to do all except for one thing, when you click to get coords the input boxes stay the same. Not sure why they won't get written to. Other than that I appreciate everything, I guess I was way off of what I needed to do.

Share this post


Link to post
Share on other sites

Okay so it finally does what I originally wanted it to do all except for one thing, when you click to get coords the input boxes stay the same. Not sure why they won't get written to. Other than that I appreciate everything, I guess I was way off of what I needed to do.

Then I missunderstood you because you wrote:

Well what I want it to do is when I click "get coords" I can click anywhere on the screen and it gets the coords, than locks them, so no matter how many more times I click nothing happens. it's a 1 click 1 time button until clicked again, than for "start" it does the simple loop indefinitely until I click "stop!" so let me repost my original script since it is slightly changed and maybe we can figure it out I hope.

By clicking the coord button the script enables the capture of the coodinate by rmb. When you press the coord button again the capturing will be disabled.

Anyway, the rest is "homework" for you. :mellow:

BR,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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