Jump to content
Sign in to follow this  
meamrussian

Help Out With Simple Code

Recommended Posts

meamrussian

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.

Share this post


Link to post
Share on other sites
NegativeNrG

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.

Share this post


Link to post
Share on other sites
SmOke_N

Send ("{ALT} + {F4}") = Send("!{F4}")


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.

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites
seandisanti

Send ("{ALT} + {F4}") = Send("!{F4}")

actually i think

Send ("{ALT} + {F4}") = Send("{ALT}{SPACE}{LSHIFT DOWN}{SPACE}{LSHIFT UP}{F4}")

Share this post


Link to post
Share on other sites
LxP

Another way of instructing the active window to close:

WinClose('')

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
Sign in to follow this  

×