Sign in to follow this  
Followers 0
stefionesco

Noobie - Problem with Looping a MouseClick

8 posts in this topic

Hi, there
 
I try to put together this script but I do something wrong and I can't understand where.
Here is my script:

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.3.12.0
 Author:
#ce ----------------------------------------------------------------------------

#include <GUIConstants.au3>

$windows = GUICreate("Title", 280, 110)

GUICtrlCreateLabel ("Route", 30, 10)
    $Radio1 = GUICtrlCreateRadio("1", 30, 30, 100, 20)
    $Radio2 = GUICtrlCreateRadio("2", 30, 50, 100, 20)
    GUICtrlSetState($Radio1, $GUI_CHECKED)

$startbutton = GUICtrlCreateButton("START", 150, 40, 85, 25)

; BUTTON
$button_x = 745
$button_y = 720

;LEFT BUTTON
$left_button_x = 935
$left_button_y = 585

;RIGHT BUTTON
$right_button_x = 385
$right_button_y = 585

GUISetState(@SW_SHOW)


#comments-start ----------------------------------------------------------------------------

While $action = $startbutton

If $Radio1 = $GUI_CHECKED   Then MouseClick ("", $button_x, $button_y)

If $Radio2 = $GUI_CHECKED   Then MouseClick ("", $button_x, $button_y)
                            Sleep (2000)
                            Then MouseClick ("", $right_button_x, $right_button_y)
                            Sleep (2000)
                            Then MouseClick ("", $button_x, $button_y)
                            Sleep (2000)
                            Then MouseClick ("", $left_button_x, $left_button_y)
                            Sleep (2000)

 Sleep 5 minutes after all this
 Loop until ESC or EXIT

#comments-end ----------------------------------------------------------------------------


HotKeySet("{ESC}", "_Terminate")
    Func _Terminate()
        Exit
    EndFunc

While 1
    $action = GUIGetMsg()
        If $action = $GUI_EVENT_CLOSE Then
            ExitLoop
        EndIf
WEnd

Can somebody help me?

Thanks in advance

Route script.au3

Share this post


Link to post
Share on other sites



It is difficult to troubleshoot for you when you just say "I did something wrong, somewhere". Can you please let us know what application/window you're trying to manipulate? What do you expect the script to do, and at what point is it failing?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I can't compile the script. I did something wrong with "while" when I try to activate the start button.

The program must click on a refresh button on a windows, and there is 2 different windows that I must choose with Radio buttons. This when I click the start button, and then repeat after 5 minutes. I use hotkeys ESC for exit.

In the comment part of the script must be all the information needed, but I can't put it together.

:(

Share this post


Link to post
Share on other sites

Your script compiles just fine for me.  The bad news is that your script doesn't do anything except wait for a $GUI_EVENT_CLOSE action.  If you are looking for an action from your start button then you have to check for it.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.3.12.0
 Author:
#ce ----------------------------------------------------------------------------

#include <GUIConstants.au3>

$windows = GUICreate("Title", 280, 110)

GUICtrlCreateLabel ("Route", 30, 10)
    $Radio1 = GUICtrlCreateRadio("1", 30, 30, 100, 20)
    $Radio2 = GUICtrlCreateRadio("2", 30, 50, 100, 20)
    GUICtrlSetState($Radio1, $GUI_CHECKED)

$startbutton = GUICtrlCreateButton("START", 150, 40, 85, 25)

; BUTTON
$button_x = 745
$button_y = 720

;LEFT BUTTON
$left_button_x = 935
$left_button_y = 585

;RIGHT BUTTON
$right_button_x = 385
$right_button_y = 585

GUISetState(@SW_SHOW)

While $action = $startbutton

If $Radio1 = $GUI_CHECKED   Then MouseClick ("", $button_x, $button_y)

If $Radio2 = $GUI_CHECKED   Then MouseClick ("", $button_x, $button_y)
                            Sleep (2000)
                            Then MouseClick ("", $right_button_x, $right_button_y)
                            Sleep (2000)
                            Then MouseClick ("", $button_x, $button_y)
                            Sleep (2000)
                            Then MouseClick ("", $left_button_x, $left_button_y)
                            Sleep (2000)

 Sleep (100000)

WEnd

#comments-start---------

 Here it must Loop until ESC or EXIT

#comments-end-----------


HotKeySet("{ESC}", "_Terminate")
    Func _Terminate()
        Exit
    EndFunc

While 1
    $action = GUIGetMsg()
        If $action = $GUI_EVENT_CLOSE Then
            ExitLoop
        EndIf
WEnd

I was just put the comment line where was the errors. Without comment line didn't compile anymore.

It's a webcam that I must click refresh every 5 minutes clicking one button. In another location there are 2 webcams so I must click on the refresh button, click on the next webcam, refresh this one, and then click back for returning on the first webcam.

Share this post


Link to post
Share on other sites

sephianesco,

Are you using the full SciTE editor for AutoIT?

Have you tried running the code using SciTE (F5)?

You need to read the Help file (and Wiki) for GUI management.  You are missing a message loop and misusing the controls.

kylomas  


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

#include <GUIConstants.au3>

$mainwindow = GUICreate("Title", 280, 200)

GUICtrlCreateLabel ("Route", 10, 10)
    $Radio1 = GUICtrlCreateRadio("1", 30, 30, 100, 20)
    $Radio2 = GUICtrlCreateRadio("2", 30, 50, 100, 20)
    GUICtrlSetState($Radio1, $GUI_CHECKED)

$start_button = GUICtrlCreateButton("START", 150, 40, 85, 25)

$refresh_button_x = 745
$refresh_button_y = 720

$next_button_x = 935
$next_button_y = 585

$prev_button_x = 385
$prev_button_y = 585

GUISetState(@SW_SHOW)

HotKeySet("{ESC}", "_Terminate")
    Func _Terminate()
        Exit
    EndFunc

While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $start_button
                Select
                    Case $Radio1 = $GUI_CHECKED
                        MouseClick ("", $refresh_button_x, $refresh_button_y)
                        Sleep (300000)

                    Case $Radio2 = $GUI_CHECKED
                        MouseClick ("", $refresh_button_x, $refresh_button_y)
                        Sleep (2000)
                        MouseClick ("", $next_button_x, $next_button_y)
                        Sleep (2000)
                        MouseClick ("", $refresh_button_x, $refresh_button_y)
                        Sleep (2000)
                        MouseClick ("", $prev_button_x, $prev_button_y)
                        Sleep (300000)
                EndSelect


        EndSwitch
    WEnd

This is where I got until now, but it didn't do the "MouseClick".

And yes, I use the full SciTE, and I use the F5 for compiling. It's compiling but didn't do anything.

I don't know what to do.

:(

Edited by stefionesco

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Your radio controls cannot be tested that way.  Read the Help file for GuiCtrlRead and GuiCtrlCreateRadio.

edit: spelling

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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