Sign in to follow this  
Followers 0
Effect

Keydown and loop?

14 posts in this topic

Hi there, i've been use AutoIT for about 1 year ago, but since then i haven't done anything in AutoIT, but now i would want to start learn again.. But i forgot alot >.>

I see the AutoIT help file, but i haven't find these..

Example, i write something here for example, and then i want it to hold down the left arrow like 5 secounds.

I tried do this

Send("{LEFT DOWN}")

Sleep(5000)

Send("{LEFT UP}")

But it's not working! I was google fast and saw a thread from this forum, about a guy who wanted made SHIFT up, so they wrote {SHIFTDOWN} instead, but i tried that with the LEFT to write {LEFTDOWN} but it didn't work too :S

How to do!?

And the other question is how to make a loop..

Example this, i dont know how the start on the top was going to look like :S

[sTART]

If 1=1 then

Send("{LEFT DOWN}")

Sleep(1000)

Send("{LEFT UP}")

Sleep(1000)

GoTo START

Share this post


Link to post
Share on other sites



OMG -.-

In example, in the AutoIT help file it says

Send("{a down}") ;Holds the A key down

Send("{a up}") ;Releases the A key

But it doesn't even work, i tried press in a Sleep(5000) between the down and up codes..

But not worked ._.

Share this post


Link to post
Share on other sites

Hi Effect...

1. I don't know either.. There is another similar topic: http://www.autoitscript.com/forum/index.php?showtopic=103087&st=0&p=731386&#entry731386 , which we have discussed yesterday... ends with no solution.

2. That was an old syntax.. the "goto" command. According to the Help File:

Just to get you started, the most basic use of Goto in version 2.64 was an infinite loop like:

:mylabel

...do something...

...and something else...

goto, mylabel

A simple v3 version of that is a While loop that is always "true".

While 1 = 1

...do something...

...do something else...

Wend


Hi ;)

Share this post


Link to post
Share on other sites

OMG -.-

In example, in the AutoIT help file it says

Send("{a down}") ;Holds the A key down

Send("{a up}") ;Releases the A key

But it doesn't even work, i tried press in a Sleep(5000) between the down and up codes..

But not worked ._.

Hi,

I couldn't run Send ("{a up}") as well. It's just given one a.

So you might use a loop, e.g.:

shellexecute ("notepad.exe")
WinWaitActive ("Untitled")
$i = 0
While $i < 50
    Send ("{a}") 
    $i += 1
Wend

;-))

Stefan

Share this post


Link to post
Share on other sites

stefan's script will do the trick.. You can also experiment with this:

Send("{down 20}") ; Press down arrow 20 times


Hi ;)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Gaah would be better to use a hold down key :S Why not working? Before it was work :S

OMG what have they done? nothing works nowadays, before it was 100000 times better

Sleep(1000)

GoTo Test()

Func Test()

$x = 0

While $x < 50

Send ("{X}")

$x += 1

Wend

EndFunc

Look that not working, how come?

I also need to have functions, its better, but why not working? i tried without the GoTo func first but it didnt jump into the function, so how to get in there?

Edited by Effect

Share this post


Link to post
Share on other sites

Well, hold down a key is not the same as repeatedly press a key(or is it?)... but, that's all I can think of right now


Hi ;)

Share this post


Link to post
Share on other sites

Dudes i need help a loop, i done while in rows without functions now.. but i need go back to top!

but how?

I tried type :loop on top, and there down i tried type GoTo loop

but this didn't work -.-

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I don't know about the old autoit, my first was 3.3.0.0 ... I tested your script and works nicely... what version you're using now?

Sleep(1000)
Test()

Func Test()
    $x = 0
    While $x < 50
        Send ("{X}") 
        $x += 1
    Wend
EndFunc
Edited by Mison

Hi ;)

Share this post


Link to post
Share on other sites

OMG -.-

In example, in the AutoIT help file it says

Send("{a down}") ;Holds the A key down

Send("{a up}") ;Releases the A key

But it doesn't even work, i tried press in a Sleep(5000) between the down and up codes..

But not worked ._.

The AutoIt help file states:

To hold a key down (generally only useful for games)

Send("{a down}") ;Holds the A key down

Send("{a up}") ;Releases the A key

If it is not "working" in a game then maybe a tool like game guard is blocking automated key strokes.

"a down" is not the same as a human pressing the "a" key on the keyboard until the "key repeat" function kicks in

I doubt that your god cares what the AutoIt help file says... such an over used phrase.


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

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

The AutoIt help file states:

To hold a key down (generally only useful for games)

Send("{a down}") ;Holds the A key down

Send("{a up}") ;Releases the A key

If it is not "working" in a game then maybe a tool like game guard is blocking automated key strokes.

"a down" is not the same as a human pressing the "a" key on the keyboard until the "key repeat" function kicks in

I doubt that your god cares what the AutoIt help file says... such an over used phrase.

Well, i was tried it in a notepad and it didn't work to hold or repeat the key that way, so

Send("{a down}")

sleep(5000)

Send("{a up}")

works like just typing Send("a")

and yes, in the game it would work, but not even work in notepad so.

Edited by Effect

Share this post


Link to post
Share on other sites

I know Send("{a down}") won't works as I've tried it before, despite what help file says.. Send("{SHIFTDOWN}") works... Send("{a 10}") also works..

It seems like Send("{a down}") behaves just like Send("a")


Hi ;)

Share this post


Link to post
Share on other sites

... despite what help file says.. Send("{SHIFTDOWN}") works... Send("{a 10}") also works..

Shift is a modifier key and it "works" with "down" differently than "a down". Both work as they work as designed. You just gotta get it out of your head that "a down" is going to do the same thing that would happen if a human held the a key down. They are two different things - mainly for gaming.

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

Share this post


Link to post
Share on other sites

Thanks herewasplato, that explains a lot. I tested it in notepad and now I know why it's not working.


Hi ;)

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  
Followers 0