Jump to content

variables and mouseclick do not work


Recommended Posts

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 

Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

  • Moderators

rockin-john,

Quote

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

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

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