Jump to content

Simple Script


 Share

Recommended Posts

Okay im new to using AutoIt and boy have i heard great things about it!

Im basically writing to ask for a little help from the community to hopefully push start me into writing some ncie little scripts.

I was wondering if anyone could help me make a simple script that only does a few things.

You see, im a wierd learner and i find learning easier if i work from examples.

Im making a little script for a game i play in which i require the script to send the following keys to the game client window:

Space bar x2 (double tap spacebar)

[Wait 10 seconds]

Press 'T'

[Wait 10 seconds]

Press 'T'

And then Loop

Extremly simple i guess but hey! Im new.

This would help me alot and maybe i could make a small paypal donation to the eprson kidn enough to help.

Thank you in advance.

Hope this kickstarts my AutoIt future.

:P

Dominic Kirkwood.

Link to comment
Share on other sites

  • Moderators

While/Send/Sleep/Send/Sleep/Send/WEnd

Those can be looked up, and you can fill in the blanks :P

Edit:

Actually I looked down and saw AutoIt's Donation button, so here you go:

While 1
    Send('{SPACE} 2')
    Sleep(10000)
    Send('T')
    Sleep(10000)
    Send('T')
WEnd
AutoIt Donation Click Here Edited by SmOke_N

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

While/Send/Sleep/Send/Sleep/Send/WEnd

Those can be looked up, and you can fill in the blanks :nuke:

Edit:

Actually I looked down and saw AutoIt's Donation button, so here you go:

While 1
    Send('{SPACE} 2')
    Sleep(10000)
    Send('T')
    Sleep(10000)
    Send('T')
WEnd
AutoIt Donation Click Here
Wow thanks for the speedy reply!

Strangly enough i kind of understand what you have there.

I have a few questions if you dont mind?

What Measurements are the sleep numbers? Miliseconds? Seconds?

Also how can i target this script to run in my game window?

I'll ask for if i can think.

Thanks for the link to the autoit donation page.

Great member :P

Link to comment
Share on other sites

  • Moderators

To target a specific window you can do 1 of 2 things.

1. If the window is active, then the script will send to that window regardless.

2. Take a look at ControlSend() rather than Send(),

ControlSend(Window Title, 'ControlID or ClassNameNN text', 'ControlID or ClassNameNN', '{SPACE} 2')oÝ÷ ÚØZ·lë-¦Ëv(uæíÁ«ìZ^"µÊ.Ö¥²()jëh×6ControlSend(Window Title, '', '', '{SPACE} 2')
Leaving the 2 control parameters with just quotes and no info should target the window (Providing your game doesn't have bot blocking software).

On the time for Sleep [AKA: Wait] yes, it's in Milliseconds.

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

I've done some searching but can't seem to find the answers i'm after.

Is there a way to make this loop indefiatly say when i press F11 and end when i press F12?

Just i really need the script to be activated by the press of a button, loop indefinatly and then terminate on the press of F12.

I'm picking this stuff up quite well.

Thanks for your help 'SmOke_N' :P

More than gratefully appreciated.

Link to comment
Share on other sites

Lookup HotKeySet in the help file.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Thanks will do, any information on the looping?

Thank you BigDod

Okay, i have:

HotKeySet ( "F11" [, "function"])

As for function, how do i get the function to start the script.

Is it:

HotKeySet ( "F11" [, "while 1"])

Complete guess.

My code so far:

HotKeySet ( "F11" [, "function"])

While 1

Send('{SPACE} 2')

Sleep(10000)

Send('T')

Sleep(10000)

Send('T')

WEnd

Edited by Router
Link to comment
Share on other sites

  • Moderators

Try the examples in the help file under HotKeySet and follow what each thing is doing... and you'll understand easily.

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

HotKeySet("{F12}", "Stop")
HotKeySet("{F11}", "Start")

While 1
    Sleep(100)
WEnd

Func Stop()
    Exit 0
EndFunc  ;==>Stop

Func Start()
    While 1
        Send('{SPACE} 2')
        Sleep(10000)
        Send('T')
        Sleep(10000)
        Send('T')
    WEnd
EndFunc  ;==>Start


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

don't you mean "{SPACE 2}" and not "{SPACE} 2" ?

I put two and two together.

Im familiarising myself with the program and it's great!

I made my first game bot yesterday fully working!

I have another question though (sorry :P)

Say if i wanted the script to send these guys to the game window...

Is there a line of code that sends it to a certain window not just the active window?

Just, my pc has alot of spyware that appears unremovable by all the major programs and often they popup over the game window and the script stops acting upon the game window.

Im guessing i'll need a window name?

I have a question about that too,

Is the window name the name that appeats on the bottom bar (with windows start on) or is it the window title at the top of the game i need?

I hope i'm not getting too annoying, im just insanely interested in this program.

Thanks to everyones help :nuke:

Link to comment
Share on other sites

I put two and two together.

Im familiarising myself with the program and it's great!

I made my first game bot yesterday fully working!

I have another question though (sorry :P)

Say if i wanted the script to send these guys to the game window...

Is there a line of code that sends it to a certain window not just the active window?

Just, my pc has alot of spyware that appears unremovable by all the major programs and often they popup over the game window and the script stops acting upon the game window.

Im guessing i'll need a window name?

I have a question about that too,

Is the window name the name that appeats on the bottom bar (with windows start on) or is it the window title at the top of the game i need?

I hope i'm not getting too annoying, im just insanely interested in this program.

Thanks to everyones help :D

Hi, I just wanted to say that's exactly how I like to learn things to! And good luck on your programming future. :nuke:

Oh and..

winwait("The name of the game")
winactivate("The name of the game")
winwaitactive("The name of the game")

Put that wherever you need it :)

Edit: Press ctrl+alt+delete and look in the applications tab for the task name. That should always be accurate.

Edited by Azu
Link to comment
Share on other sites

Hi, I just wanted to say that's exactly how I like to learn things to! And good luck on your programming future. :P

Oh and..

winwait("The name of the game")
winactivate("The name of the game")
winwaitactive("The name of the game")

Put that wherever you need it :nuke:

Edit: Press ctrl+alt+delete and look in the applications tab for the task name. That should always be accurate.

Im sure there us a name for our type of learning but thats another matter!

Thanks for the kind words.

This will send all the functions to the window even if it's minimized?

It appears with the winwait that the script stops untill the window is active.

Thanks.

Link to comment
Share on other sites

Im sure there us a name for our type of learning but thats another matter!

Thanks for the kind words.

This will send all the functions to the window even if it's minimized?

It appears with the winwait that the script stops untill the window is active.

Thanks.

It will pause the script for an instant, but then it will bring the window back over the popup ad or whatever, and resume the script.

Simulating mouse clicks on minimized windows isn't easy as far as I know. I've been wanting to but haven't been able to. Simulating keystrokes for it is easy though;

controlsend("Name of the game","","","{key}")
Link to comment
Share on other sites

It will pause the script for an instant, but then it will bring the window back over the popup ad or whatever, and resume the script.

Simulating mouse clicks on minimized windows isn't easy as far as I know. I've been wanting to but haven't been able to. Simulating keystrokes for it is easy though;

controlsend("Name of the game","","","{key}")
Control send didn't work at all for me.

Maybe i made a mistake somewhere but the guys are no longer being sent.

EDIT: Code is long, see attached file

What are the blank speech marks for here:

controlsend("Name of the game","","","{key}")

I read in tutorial something about window titles or something.

Thanks for your help.

Control.au3

Edited by Router
Link to comment
Share on other sites

  • Moderators

As I said in post number 4, are you sure the game doesn't block simulated key commands?

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

Where it says "Name of the game" replace it with the exact name found in the task manager.

Where it says "{key}" replace it with the button you want to press.. for example "T" or "{enter}"

As for the blank spaces, just leave 'em.

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