Jump to content

Requesting A Very Simple Script


Recommended Posts

Hi, I'm fairly new to AutoIt and I've been playing around with it, but I can't create the script that I want just yet.

All I want it to do is to press the x key on the keyboard every other second and have this run indefinitely until I close the program to end the script. Could anyone help me with this?

Link to comment
Share on other sites

  • Moderators

Hi, I'm fairly new to AutoIt and I've been playing around with it, but I can't create the script that I want just yet.

All I want it to do is to press the x key on the keyboard every other second and have this run indefinitely until I close the program to end the script. Could anyone help me with this?

Look at While/WEnd - Sleep() - Send() in the helpfile.

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

...until I close the program to end the script...

Welcome to the forums.

What SmOke_N said and...

while 1

if winexists... then

if winactive... then send x

else

exit

endif

sleep

wend

You can fill in the blanks using the help file and the AutoIt Window Info tool.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Here is what I have so far:

$i = 0

While 1 $i <= 100000

If WinExists("X Test") Then

If WinActive("X Test") Then

send (x)

$i = $i + 1

Wend

else

exit

endif

sleep

It keeps telling me that my Wend statement has no matching While statement, but I do have a While statement. I can't figure out why this won't work.

Link to comment
Share on other sites

maybe

$i = 0
While 1 $i <= 100000
    If WinExists("X Test") Then
        If WinActive("X Test") Then
            Send(x)
            $i = $i + 1
        EndIf
    EndIf
    Sleep(10)
WEnd

the code tags help you see the visual "use" and location of each command...

also you should follow cybers suggestion

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

try

While 1
    If WinExists("X Test") Then
        If WinActive("X Test") Then Send("x")
    Else
        Exit
    EndIf
    Sleep(2000)
WEnd

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Ah thanks guys. One last question.

It says that x is an unknown function. I thought Send(x) was the way to send the x keystroke. I also tried Send("x") with no luck.

Edit: nevermind, got it working. Thanks all. =)

Edited by Snuggles
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...