Sign in to follow this  
Followers 0
DeFirence

Multiple Procedures

19 posts in this topic

#1 ·  Posted (edited)

Hello

First of all i wanna say im totally new to autoit but im loving it :whistle:

Now, this may be a little confusing for me to explain what i need but ill try my best.

I want to write 2 scripts or 2 parts of a script that are slightly different.

When i run it the first time it must run the first script and when run the second time, it must run the second script.

So it must alternate between the two scripts each time it is run.

Ie:

First time: Script 1

Second: Script 2

Third time: Script 1

Forth time: Script 2

and so on...

I have no clue where to start, i have looked in the forums but im not too sure what to search for...

Thanks alot

DeFirence

Edited by DeFirence

Share this post


Link to post
Share on other sites



Hello

First of all i wanna say im totally new to autoit but im loving it :whistle:

Now, this may be a little confusing for me to explain what i need but ill try my best.

I want to write 2 scripts or 2 parts of a script that are slightly different.

When i run it the first time it must run the first script and when run the second time, it must run the second script.

So it must alternate between the two scripts each time it is run.

Ie:

First time: Script 1

Second: Script 2

Third time: Script 1

Forth time: Script 2

and so on...

I have no clue where to start, i have looked in the forums but im not too sure what to search for...

Thanks alot

DeFirence

i think in order to be helped you need to explain what you are needing the scripts to do. There are conditions that can be met and if they are they can run the 1st part, then the 2nd and so on. There are so many ways to do this you need to elaborate more on what you are trying to do.


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Ok, thanks for the quick reply, i really wanna get this working :whistle:

In short, its gonna automate hosting warcraft III dedicated servers, however if Game 3 was created with name: Game3

Then after the game has ended, the new game cant have the same name as the old game otherwise it doesnt show up on battle.net .

thats basically what it needs to do, thats why i said alternate the name each time it hosts.

Thanks again

DeFirence

Share this post


Link to post
Share on other sites

Anyone got ideas?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Anyone got ideas?

just have one script use ProcessExists() to detect the other, and run the second instead if the first is running

***edit***

sorry, i misunderstood and hadn't read all of your explanation. you could use an external file to save and check the name each time it's run.

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Wow, that is exactly what i was thinking!

Only thing is I have no idea how, could some1 help me with the script required please?

DeFirence

Share this post


Link to post
Share on other sites

Wow, that is exactly what i was thinking!

Only thing is I have no idea how, could some1 help me with the script required please?

DeFirence

Sure thing man, check in your helpfile for FileWrite(),FileRead(),IniRead(),IniWrite().

Some people like the ini functions better, i typically just use a plain text file or a registry entry


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Could you please tell me what thre difference is between the ini and the file functions and also how to use it roughly, ive read the functions and Im guessing you gotta use and IF statement, but im still very new to it.

DeFirence

Share this post


Link to post
Share on other sites

Could you please tell me what thre difference is between the ini and the file functions and also how to use it roughly, ive read the functions and Im guessing you gotta use and IF statement, but im still very new to it.

DeFirence

because your file is probably going to contain only a single entry, the difference is just preference. ini files have sections with values, and alot of people use them for settings etc.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Could you please tell me what thre difference is between the ini and the file functions and also how to use it roughly, ive read the functions and Im guessing you gotta use and IF statement, but im still very new to it.

DeFirence

The help file has examples for each function


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

The help file has examples for each function

*sigh*

Dude. the help file does, and i can use them, but u need more then those 2 functions to make what i want to do to work.

I have no idea what other commands you use, im guessing, IF readini1 = 2 then goto Procedure3

But obviously thats wrong.

Please man, help me out here, i cant find help on howto do this!!!

DeFirence

Share this post


Link to post
Share on other sites

*sigh*

Dude. the help file does, and i can use them, but u need more then those 2 functions to make what i want to do to work.

I have no idea what other commands you use, im guessing, IF readini1 = 2 then goto Procedure3

But obviously thats wrong.

Please man, help me out here, i cant find help on howto do this!!!

DeFirence

i'm sorry, i wanted to give you a chance to figure it out yourself before doing it for you.

what are the files that you are running, and the possible values uponwhich to base the decision of which to run...


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Its ok man and thanx for ur help so far :whistle:

Heres my code (sorry if its messy):

;Create game on bnet

RunAsSet("1", "DeFirence", "1")
Run("J:\war3z\w3l.exe", "J:\war3z")

WinWaitActive("Warcraft III")

Sleep(3000)

Send("{ENTER}")

Send("{LCTRL}b")

Sleep(4500)

Send("password{ENTER}")

Sleep(4100)

Send("!g")
Sleep(2500)
Send("!c")
Sleep(2500) 
Send("!o")
Sleep(1500)

MouseClickDrag("left", 543, 194, 529, 240, 10)

Sleep(1000)


***             ***
*** Check INI File ***
***             ***


*** If ini=2 goto here ***
    
Send("DotA Dedicated Host 1{ENTER}")

IniWrite that gamename 1 was used

*** end of procedure ***

*** If ini=1 goto here ***
    
Send("DotA Dedicated ONE{ENTER}")

IniWrite that gamename 2 was used

*** end of procedure ***


Sleep(4500)

MouseMove(32, 252, 1)
MouseClick("left")
MouseMove(81, 286, 1)
MouseClick("left")
MouseMove(52, 321, 1)
MouseClick("left")

Share this post


Link to post
Share on other sites

It looks like you are trying to learn how to run a marathon, and you still need to learn to walk. My advice, slow down, and start small. You should first try Valuater's AutoIt 123. Do that, then take a look at the help file. Try the examples in the there, and see how they work. Once you get a feel for it, try to do what you want to do. It will make it MUCH easier for you if you take this approach. Also, if you want, take a look at this link: Learning to Script with AutoIt 3 By LxP. It may be of help to you.

It is much better to try to learn how to fish, instead of asking for fish. We are more than happy to teach you to fish. We do not however like someone trying to ask for fish....

Share this post


Link to post
Share on other sites

It looks like you are trying to learn how to run a marathon, and you still need to learn to walk. My advice, slow down, and start small. You should first try Valuater's AutoIt 123. Do that, then take a look at the help file. Try the examples in the there, and see how they work. Once you get a feel for it, try to do what you want to do. It will make it MUCH easier for you if you take this approach. Also, if you want, take a look at this link: Learning to Script with AutoIt 3 By LxP. It may be of help to you.

It is much better to try to learn how to fish, instead of asking for fish. We are more than happy to teach you to fish. We do not however like someone trying to ask for fish....

Hi man,

I hear what youre saying but i would just like to get this script done, im going to learn and that myself but i need this done asap...

If anyone could help me with my script it would be greatly appreciated :whistle:

Thanks again

DeFirence

Share this post


Link to post
Share on other sites

I was writing my response when you posted again.

  • To check a ini = iniread
  • You will also need a "while" loop to keep your script running.
  • Instead of using send, use controlsend - more stable
  • Also, you use a bunch of sleep statements - what happens when you remove them? Does it mess up? This is where controlsend mak make it more stable.
  • Mouseclickdrag? wondering about that one. Is the GUI you are working with have a item you have to move? You also used 10 for the speed. You can drop that off for that is the default speed.
  • What do you plan to use for a screen event or process event to trigger what function you want to use? You would need to be specific. Look on using the AutoIt window info tool if needed. It is part of the full download of AutoIt.
  • Whats with the mouseclicks at the end? You may want to use controlclick. more stable, and if the window isn't active, it still works.

Share this post


Link to post
Share on other sites

I was writing my response when you posted again.

  • To check a ini = iniread
  • You will also need a "while" loop to keep your script running.

    im not quite sure where to put it

  • Instead of using send, use controlsend - more stable
  • Also, you use a bunch of sleep statements - what happens when you remove them? Does it mess up? This is where controlsend mak make it more stable.

    i need the sleep statements cause on warcraft's menu there is animation when u choose an option

  • Mouseclickdrag? wondering about that one. Is the GUI you are working with have a item you have to move? You also used 10 for the speed. You can drop that off for that is the default speed.

    i used mouseclickdrag instead of click move click :S

  • What do you plan to use for a screen event or process event to trigger what function you want to use? You would need to be specific. Look on using the AutoIt window info tool if needed. It is part of the full download of AutoIt.

    The way i plan to do this isnt with a trigger but rather a mirc script i wrote that will start the autoit script when a player whispers the bot

  • Whats with the mouseclicks at the end? You may want to use controlclick. more stable, and if the window isn't active, it still works.I will look into it, i have never used control :S

If you could at all, please help me with the code once you understand everything.

Ask anymore questions u need, ill reply asap as i want this soon :whistle:

DeFirence

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

It is MUCH faster for you to do what I suggested at first, then come back and try again. Your code will be much better, and MUCH closer to just what you need. Again, you are trying to learn to run, and you don't have much of a idea on how to walk. Have you tried AutoIt 123 yet? It takes a hour to do at most, but it will address most of the issues you have. Trust me on this. It is well worth your time to take the course, (it will take a hour and a halve at most) then try tweaking your code.

edit: Sorry if I'm seeming to be somewhat harsh. I'm not meaning to be. I understand you would like to get this done as fast as possible, but it is quite hard to do when I'm not in front of the PC in question. If we can get you up to speed faster, then we can solve your issue faster. My post was not meant to be mean. It was meant to be directive.

Edited by Volly

Share this post


Link to post
Share on other sites

hehe, its cool man, as long as youre there to help me alone :whistle:

However it seems like im going to be up all night again, i slept 2 hours today and nothing last nite, its now 10:16pm...

Heres the deal now, ive done the AutoIt 123 and it is quite good, im still pretty much lost as hell tho.

I cant get the control id for warcraft :P and i would like to use controlsend.

Is there any other way to get it, the window info thing only gives the title =\

DeFirence

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