Sign in to follow this  
Followers 0
Joseph

how do i make my gui buttons operate more than once?

4 posts in this topic

here is something i made that if the pixel is there then it shows a message box saying that the pixel is found and then moves the mouse there, and if the pixel is not there it says nope.. but that only works one time and if u click the button again it does nothing, is that because of the while 1 i'm using or what? heres what the script is

#include <guiconstants.au3>
$GUI = GUICreate("If Pixel Clicker", 200,20,-1,-1,-1)
$Exit = GUICtrlCreateButton("Exit",0,0,20,20)
$Search = GUICtrlCreateButton("Pixel Search",20,0,180,20)

GUISetState(@SW_SHOW)
WinSetOnTop($GUI, "", 1)

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg= $Exit
        GUIDelete()
        Exit
    Case $msg= $search 
        searcher()
    EndSelect
WEnd

Func searcher()
$search=PixelSearch(50,50,200,200,0x63CEFF,50)
if IsArray($search) then
MsgBox(0,"","found that colour at X" &$search[0]&"   Y"&$search[1],0)
MouseMove($search[0],$search[1])
Else
    MsgBox(0,"Pixel Not There","nope",0)
EndIf
EndFunc

Share this post


Link to post
Share on other sites



here is something i made that if the pixel is there then it shows a message box saying that the pixel is found and then moves the mouse there, and if the pixel is not there it says nope.. but that only works one time and if u click the button again it does nothing, is that because of the while 1 i'm using or what? heres what the script is

#include <guiconstants.au3>
$GUI = GUICreate("If Pixel Clicker", 200,20,-1,-1,-1)
$Exit = GUICtrlCreateButton("Exit",0,0,20,20)
$Search = GUICtrlCreateButton("Pixel Search",20,0,180,20)

GUISetState(@SW_SHOW)
WinSetOnTop($GUI, "", 1)

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg= $Exit
        GUIDelete()
        Exit
    Case $msg= $search 
        searcher()
    EndSelect
WEnd

Func searcher()
$search=PixelSearch(50,50,200,200,0x63CEFF,50)
if IsArray($search) then
MsgBox(0,"","found that colour at X" &$search[0]&"   Y"&$search[1],0)
MouseMove($search[0],$search[1])
Else
    MsgBox(0,"Pixel Not There","nope",0)
EndIf
EndFunc
In your function searcher you have a variable $search used for the return from PixelSearch. But that name was previously used for the button! Use a different name for the PixelSearch result otherwise you destroy the reference to the button.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <guiconstants.au3>
$GUI = GUICreate("If Pixel Clicker", 220, 20, -1, -1, -1)
$Exit = GUICtrlCreateButton("Exit", 0, 0, 40, 20)
$Search = GUICtrlCreateButton("Pixel Search", 40, 0, 180, 20)

GUISetState(@SW_SHOW)
WinSetOnTop($GUI, "", 1)

Func searcher()
    $pixel_search = PixelSearch(50, 50, 200, 200, 0x63CEFF, 50)
    if IsArray($pixel_search) then
        MsgBox(0, "", "found that colour at X" & $pixel_search[0] & "   Y" & $pixel_search[1], 0)
        MouseMove($pixel_search[0], $pixel_search[1])
    Else
        MsgBox(0, "Pixel Not There", "nope", 0)
    EndIf
EndFunc

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Exit
        GUIDelete()
        Exit
    Case $msg = $search
        searcher()
    EndSelect
WEnd

EDIT 1:

didnt see the above reply this works fully and is more readable

EDIT 2:

the searcher always finds that colour as it is in the containing box around the pixel searcher form.

Edited by FaT3oYCG

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Share this post


Link to post
Share on other sites

#include <guiconstants.au3>
$GUI = GUICreate("If Pixel Clicker", 220, 20, -1, -1, -1)
$Exit = GUICtrlCreateButton("Exit", 0, 0, 40, 20)
$Search = GUICtrlCreateButton("Pixel Search", 40, 0, 180, 20)

GUISetState(@SW_SHOW)
WinSetOnTop($GUI, "", 1)

Func searcher()
    $pixel_search = PixelSearch(50, 50, 200, 200, 0x63CEFF, 50)
    if IsArray($pixel_search) then
        MsgBox(0, "", "found that colour at X" & $pixel_search[0] & "   Y" & $pixel_search[1], 0)
        MouseMove($pixel_search[0], $pixel_search[1])
    Else
        MsgBox(0, "Pixel Not There", "nope", 0)
    EndIf
EndFunc

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Exit
        GUIDelete()
        Exit
    Case $msg = $search
        searcher()
    EndSelect
WEnd

EDIT 1:

didnt see the above reply this works fully and is more readable

EDIT 2:

the searcher always finds that colour as it is in the containing box around the pixel searcher form.

ok i see that now thanks for the help

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