Jump to content

Help Out With Simple Code


Recommended Posts

Here's the code:

Func this()
Do

    Send ("{tab}")
    Send ("{enter}")
    Sleep (23000)
    Send ("{ALT} + {F4}")
    $x = 0
    $x = $x + 1

Until $x = 50
Endfunc

HotKeySet ("{pause}", "this")

While 1
Wend
This is for a browser. When it presses enter, it opens a new window and waits. Then, I want it to close the window and go to the next link. However, the window just doesn't want to close :P What am I doing wrong? I would do WinClose ("Firefox"), but there is always more than one firefox window open. How do I close that top window to go back to the original?

Also, what's the code to press pause again (or another key) to stop the script?

Thanks a bunch.

Link to comment
Share on other sites

Also, what's the code to press pause again (or another key) to stop the script?

To be honest, thats the part i only understand.

Anyway:

Func this()
$stop = 0
Do

    Send ("{tab}")
    Send ("{enter}")
    Sleep (23000)
    Send ("{ALT} + {F4}")
    $x = 0
    $x = $x + 1

Until $x = 50

Endfunc

HotKeySet ("{pause}", "this")
hotkeyset("{INS}","pause")

Func pause()
if $stop = 0 Then
$stop = 1
Else
$stop = 0
Endif
EndFunc

While 1
Wend

Pressing Insert will pause the script

Also, if you want to make it pause on 1 key only then use

Func something();;Where something is your func
$stop = NOT $stop
While $stop
;;do stuff here
WEnd
EndFunc
Edited by NegativeNrG

[size=20]My File Upload[/size]Register at my site and upload.

Link to comment
Share on other sites

  • Moderators

Here's the code:

Func this()
Do

    Send ("{tab}")
    Send ("{enter}")
    Sleep (23000)
    Send ("{ALT} + {F4}")
    $x = 0
    $x = $x + 1

Until $x = 50
Endfunc

HotKeySet ("{pause}", "this")
I didn't look past Send ("{ALT} + {F4}") till just now...

In your loop you have:

$x = 0 << put this before the loop.

$x = x + 1

Until $x = 50 << $x will never = anything but 0 and 1

Func this()
Local $x = ''
Do

    Send ("{tab}")
    Send ("{enter}")
    Sleep (23000)
    Send ("!{F4}")
    $x = $x + 1

Until $x = 50
Endfunc
Try that

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