Jump to content
Sign in to follow this  
sYs73m

New w/ AutoIT

Recommended Posts

sYs73m

Hello!

I've been trying to teach myself AutoIT, but I've been having a hard time making this script work. Odds are, I'm way off and don't know what I'm doing. Here is basically what I'm looking to do;

I wanted to set a script up to do a keystroke, wait a designated amount of time, hit another keystroke, wait another designated amount of time, then I want the it to basically restart, and endlessly repeat itself until I manually turn off the script.

Can anyone help me with this? I can post what I have if you want, but I'm trying to save face so I'd rather not, that way ya'll don't laugh at me! :)

Thanks.

Share this post


Link to post
Share on other sites
Björn Kaiser

i will just give you some hints

While 1
    SendKeys("ABC")
    Sleep(100)
WEnd

Or something close to that. I dont have the helpfile here right now. And you would need to set a hotkey to exit the script or you have to close it from the tray menu.


"I teleported home one nightWith Ron and Sid and Meg.Ron stole Meggie's heart awayAnd I got Sidney's leg."- A poem about matter transference beams.

Share this post


Link to post
Share on other sites
sYs73m

i will just give you some hints

While 1
    SendKeys("ABC")
    Sleep(100)
WEnd

Or something close to that. I dont have the helpfile here right now. And you would need to set a hotkey to exit the script or you have to close it from the tray menu.

Yeah, it would be a manual close from the tray.

I'm going to assume that the "Sleep(100)" is in seconds, although I don't understand what the "While 1" part is. I'll play with it some more. Thanks. Anyone else who can help, please do.

Edit: Tried playing with what you gave me, got an error when I try to run it. I'm pretty new so I'm sorry if I'm not getting it..

Edited by sYs73m

Share this post


Link to post
Share on other sites
Björn Kaiser

Yeah, it would be a manual close from the tray.

I'm going to assume that the "Sleep(100)" is in seconds, although I don't understand what the "While 1" part is. I'll play with it some more. Thanks. Anyone else who can help, please do.

"While 1 ... WEnd" is an infinite loop, it will run until you exit the loop or the script. Sleep() uses miliseconds. oh and Read The Fine Manual. It helps. Really!

edit: i knew i messed something up.

Replace SendKeys() with Send()

Edited by Björn Kaiser

"I teleported home one nightWith Ron and Sid and Meg.Ron stole Meggie's heart awayAnd I got Sidney's leg."- A poem about matter transference beams.

Share this post


Link to post
Share on other sites
MISIIM

Sleep is in milliseconds so 1000 = 1 second.

It is actually Send() not SendKeys().

Edited by MISIIM

Share this post


Link to post
Share on other sites
ofLight

HotKeySet("`","_Go")
HotKeySet('{esc}', '_Exit')

While 1
    ToolTip("Press tilde to Start "&@LF&"Press ESC to Exit")
    Sleep(100)
WEnd

Func _Go()
    While 1
        Send("{F1}") ;the Key you want to send
        Sleep(5000) ;Time you want to Wait, 5second
        ;More Sends... .. .
        ;More Sleeps... .. .
        Send(8)
        Sleep(5*60*1000) ;<<-------- 5 minutes
    Wend
EndFunc 

Func _Exit()
    ToolTip('          '&@CRLF&'  EXITING  '&@CRLF&'          ')
    Sleep(500)
    Exit
EndFunc


There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Share this post


Link to post
Share on other sites
sYs73m

Okay, here is what I have so far, and it's mostly working;

While 1
    Sleep(5000)
    Send("{F2}")
    Sleep(5000)
    Send("3")
    Sleep(5000)
    Send("Q")
    Sleep(5000)
    Send("A")
    Sleep(2000)
    Send("D")
    Sleep(2000)
    Send("T")
    Sleep(40000)
WEnd

Pushing F2 works, pushing 3 works, pushing Q works, but after it pushes Q, it ignores the A, D and T function. Any suggestions?

Thanks, ofLight, but that looks really confusing to me. I'll give it a shot if what I'm doing is useless/broken.

Share this post


Link to post
Share on other sites
Björn Kaiser

....

Pushing F2 works, pushing 3 works, pushing Q works, but after it pushes Q, it ignores the A, D and T function. Any suggestions?

...

maybe the program/window you are trying to send input to got inactive.

you can either check if the window is active every time or you can use ControlSend() as that works also with inactive windows.


"I teleported home one nightWith Ron and Sid and Meg.Ron stole Meggie's heart awayAnd I got Sidney's leg."- A poem about matter transference beams.

Share this post


Link to post
Share on other sites
sYs73m

Try this one first of all :)

Run("c:\Program Files\AutoIt3\AutoIt.chm")
/bonk

Thanks everyone for their help, I managed to get it working. ofLight, I worked with yours for a bit and it was flawless, bar the fact that it bogged down the entire computer. I chopped some of it out, such as the start/stop feature. Thanks a bunch.

Share this post


Link to post
Share on other sites
sYs73m

maybe the program/window you are trying to send input to got inactive.

you can either check if the window is active every time or you can use ControlSend() as that works also with inactive windows.

It wasn't that. Not sure why it wasn't working. I just started from scratch and it worked fine. Maybe I had some unknown typo in there...

Edit: I've spent a good ten minutes looking for one thing; When I installed AutoIt, it asked me if I wanted to edit, or run, a script when I double-clicked it. How can I change this? I want it to run it, instead of editing it.

Anyone know how I can change the setting? Searching the FAQ didn't help much either, kept getting release note updates and stuff, heh..

Edited by sYs73m

Share this post


Link to post
Share on other sites
ofLight

Donno the awnser to that one :)

but reinstalling is Easy nuff :)


There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Share this post


Link to post
Share on other sites
crash748

It wasn't that. Not sure why it wasn't working. I just started from scratch and it worked fine. Maybe I had some unknown typo in there...

Edit: I've spent a good ten minutes looking for one thing; When I installed AutoIt, it asked me if I wanted to edit, or run, a script when I double-clicked it. How can I change this? I want it to run it, instead of editing it.

Anyone know how I can change the setting? Searching the FAQ didn't help much either, kept getting release note updates and stuff, heh..

Have you install SciTE4AutoIt3.exe it was an editor which was really usefull to write your script..

In the installation you will be ask what you want to do when double clicking your script (Run or Edit).

http://www.autoitscript.com/autoit3/scite/downloads

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.