Jump to content

Recommended Posts

Posted

HI,

I am having trouble getting the variables to work with the mouseclick, its keeps sending the mouse to 0,0 Top left of screen, I am new to autoit and only used basic from the days of the comodores, this seems correct to me. what have i missed out?.

Local $x

Local $y

If loop = 0 Then $x = 500 & $y = 500

Mouseclick("Left", $x, $y)

(Rest of program)

Next

Thanks 

  • Developers
Posted

This shown script is full with syntax errors. Install the Full SciTE4AutoIt3 installer which will then run au3check automatically when pressing F5/Run.

Just a couple of pointers: 

  • a variable starts with teh dollar sign ($) so loop is not considered to be a variable.
  • There is a Next without a For statement.
  • Open the helpfile for more proper syntax help and start reading
  • While you are in reading mode: Also have a look at our forum rules.

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Hi,  I have now cut & pasted the part of the code, removing the $ sign from the loop, but when checking with syntaxcheck prod (ctrl & F5) it errors until the $ is put back, but the point i was trying to make was the $x and $y varibles are causing the fault, on adding the message box when the count reaches 1 on the Variables they are false or not being assigned,

Local $x
Local $y

For $L = 0 To 3

If $L = 1 Then $x = 915 & $y = 497

 MsgBox($MB_SYSTEMMODAL, "", "Count down!" & @CRLF & $L & " " & $x)

MouseClick ("Left",$x,$y)         
Sleep (1000)                    
MouseClick ("Left",813,475)     
Sleep (1000)

Next

  • Moderators
Posted

Try this instead:

If $L = 1 Then
        $x = 915
        $y = 497
    EndIf

Also, please put your code in code tags (<> symbol when posting), as it makes it far easier to read.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

  • Developers
Posted (edited)

This will not result in what you are expecting:

If $L = 1 Then $x = 915 & $y = 497

Check the values of both $x and $x after this statement and you will understand.

Jos

EDIT: See  @JLogan3o13 already gave the answer away ;)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • Moderators
Posted

rockin-john,

  Quote

although i do not why it could not work the way I tried

Expand  

Because you were using the wrong syntax. You cannot expect AutoIt to read your mind, you have to tell it exactly what you want it to do - and syntax is, as in all computer languages, how you do this.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Developers
Posted

That is simple... Run this:

$L = 1
$x=0
$y=0
If $L = 1 Then
    $x = 915 & $y = 497
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $y = ' & $y & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $x = ' & $x & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
EndIf

It will return the values for $x and $y in the SciTE output pane:

@@ Debug(6) : $y = 0
>Error code: 0
@@ Debug(7) : $x = False
>Error code: 0

So $x is set to :

  1. 915 & $y = 497
  2. 915 & 0 = 497
  3. 9150 = 497
  4. False

$y is not set at all so remain 0

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...