Jump to content

Using Multiple "if" statements


 Share

Recommended Posts

Hey everyone, I have almost got my script completely working, it goes and clicks where I want except the end part does not work like I am wanting it to.

MouseMove(845, 401)
Sleep(4000)
If MouseGetCursor() = 0 Then
MouseClick("left", 845, 401)
Sleep(28000)
MouseMove(311, 124, 5)
ElseIf MouseGetCursor() = 2 Then Sleep(10000)
MouseClick("left", 545, 403)
If MouseGetCursor() = 0 Then Send("^w")
EndIf

I know its more then likely coded a little (or a lot) wrong but, it kind of works.

Here is where it is not doing what I want:

I can get it to do the mouse movements and clicks, it gets stuck after it moves to "311, 124"

It does not seem to be detecting the last part of the code which is below:

If MouseGet Cursor() =0 Then Send("^w")

I keep messing with the script so if I get it solved I will get the forum know. Thanks for all the help you guys provide :lmao:

Link to comment
Share on other sites

there are two if statements in there, so you need two [endif statements

Matt :idiot:

nope, only one is a block if, that part is correct. i think your condition being evaluated may be flawed. You only want to perform the action if the mouse cursor is an unknown cursor? if you are using default cursors (or even themed) in windows, you're not going to receive an unknown cursor. you can check this by adding this line before that check:

msgbox(0,"cursor",MouseGetCursor()) that will tell you what it's seeing when you want it to be returning 0...

Link to comment
Share on other sites

i am not exactly sure what you are trying to do, but i beleive this line is your problem

"ElseIf MouseGetCursor() = 2 Then Sleep(10000)"

something like this maybe?

MouseMove(845, 401)
Sleep(4000)
If MouseGetCursor() = 0 Then
    MouseClick("left", 845, 401)
    Sleep(28000)
    MouseMove(311, 124, 5)
ElseIf MouseGetCursor() = 2 Then
    Sleep(10000)
EndIf
MouseClick("left", 545, 403)
If MouseGetCursor() = 0 Then Send("^w")
Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Link to comment
Share on other sites

i think you missed 1 EndIf, for every If line, if there is nothing after "Then" on the same line, you have to close the If..Then set with an EndIf, otherwise error.

In other word you need to add back an EndIf just about the line

If MouseGetCursor() = 0 Then Send("^w")

Link to comment
Share on other sites

i think you missed 1 EndIf, for every If line, if there is nothing after "Then" on the same line, you have to close the If..Then set with an EndIf, otherwise error.

In other word you need to add back an EndIf just about the line

If MouseGetCursor() = 0 Then Send("^w")

he only has one block if. he does not need a second endif for the ElseIf.
Link to comment
Share on other sites

  • Moderators

Just out of curiousity, when you do this manually, does the cursur change for you at this point?

ElseIf MouseGetCursor() = 2 Then Sleep(10000) ; << is wrong first off

MouseClick("left", 545, 403)

If MouseGetCursor() = 0 Then Send("^w")

Should be:

ElseIf MouseGetCursor() = 2 Then 
Sleep(10000)
MouseClick("left", 545, 403)
If MouseGetCursor() = 0 Then Send("^w")

You could alwyas debug:

MouseMove(845, 401)
Sleep(4000)
If MouseGetCursor() = 0 Then
    MouseClick("left", 845, 401)
    Sleep(28000)
    MouseMove(311, 124, 5)
ElseIf MouseGetCursor() = 2 Then 
    Sleep(10000)
    MsgBox(0, 'Debug Test 1', 'The Cursor is: ' & MouseGetCursor())
    MouseClick("left", 545, 403)
    MsgBox(0, 'Debug Test 2', 'The Cursor is: ' & MouseGetCursor() & @CRLF & 'Before you try to send ^w')
    If MouseGetCursor() = 0 Then Send("^w")
EndIf

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hey everyone thanks for the feedback :lmao:

I used the AutoIt v3 Active Window Info screen to get the X and Y areas and to get the Cursor ID as it says both in the "Mouse Details" section.

I think I may have placed things in the incorrect order but, I am not sure.

@SmOke_N

No, the cursor does NOT change at that point, unless the Cursor ID = 0. When the cursor ID is 0 then it is a clickable link.

This is the same with the final part of the Script. When it moves to 311, 124 the Cursor (according to the AutoIt v3 Active Window Info Screen).

I want the window to close if the Cursor ID is equal to ZERO; the Mouse Details in AutoIt v3 Active Window Info says

>>>>>Mouse Details<<<<<<

Screen: X: 311 Y: 124

Cursor ID: 0

Sorry if I am making things worse. If needed I will copy and paste my whole script in a reply so you guys can look the whole thing over. I just copied and pasted what I thought was causing the problem.

Link to comment
Share on other sites

  • Moderators

You still need to debug... here I used the ToolTip() instead of message boxes, that way you can see if you are backwards or not.

MouseMove(845, 401)
Sleep(4000)
If MouseGetCursor() = 0 Then
    MouseClick("left", 845, 401)
    Sleep(28000)
    MouseMove(311, 124, 5)
ElseIf MouseGetCursor() = 2 Then
    Sleep(10000)
    ToolTip('Debug Test 1' & @CRLF & 'The Cursor is: ' & MouseGetCursor() & @CRLF & 'Before you try to send ^w', 0, 0)
    MouseClick("left", 545, 403)
    ToolTip('Debug Test 2' & @CRLF & 'The Cursor is: ' & MouseGetCursor() & @CRLF & 'Before you try to send ^w', 0, 0)
    If MouseGetCursor() = 0 Then Send("^w")
EndIf

You mentioned the term 'clickable link', if you are using a browser, you may want to look at Dale's IE.au3 in the Scripts and Scraps forum.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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