rockin-john

variables and mouseclick do not work

9 posts in this topic

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 

Share this post


Link to post
Share on other sites



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 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.


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

Share this post


Link to post
Share on other sites

#5 ·  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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

TY, it is now working, although i do not why it could not work the way I tried. 

John.

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

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

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

TY again, I see now, all is running ok now.

Close topic.

John

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