Jump to content

Any kind of Threading Support?


Recommended Posts

Mabey im doing something wrong... *shrugs* but i have made a hotkey application that when you press a hotkey, it activates a loop, that when activated again, it will turn itself off, (IE: brake the loop)... only sometimes it will brake the loop sometimes it wont, and while that loop is in session, no other hotkey loops will process... am i doing something wrong? or am i just completely missing on you how thread in this language? If not, threading should so come out in the next version. :-). The code in question is attached. :-) thanks for any help/advice/million dollars :-P. :-).Starcraft_Hotkey.au3

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Link to comment
Share on other sites

Ok,

You have learned how to write hotkeys, and they can "lock-up" other script operations ( by the way there appears to be a few errors, but i am sure you know what they are)

there is nothing wrong with this version of autoit doing what you want

what is it you would like to do in the "middle" of which function, and which function "sometimes" works.... please explain

NEWHeader1.png

Link to comment
Share on other sites

The code is posted, its called Starcraft_Hotkey. Im trying to send key commands to a game, and im trying to loop the same key being sent until i stop it by hitting the same hotkey, it does a thing if $hotkeyrun = 1 then $hotkeyrun = 0 and that causes the while loop to break.

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Link to comment
Share on other sites

The code is posted, its called Starcraft_Hotkey.

I viewed the script

Im trying to send key commands to a game

thats obvious

and im trying to loop the same key being sent until i stop it by hitting the same hotkey

i understand that

it does a thing if $hotkeyrun = 1 then $hotkeyrun = 0 and that causes the while loop to break.

there is no hotkeyrun??

You have to understand I cannot test this script of yours because i dont play that game.

If you would like help then please.... as stated before

what is it you would like to do in the "middle" of which function, and which function "sometimes" works.... please explain

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

*sighs* i understand $hotkey run does not exist, i was an example... okie dokie, this is how it works, i hit crtl + 1, and it goes in, tests if $build_Observer is 1 or 0, if one, it changes it to 0 which would cause the while statement running in build_Observer2 to stop. If it is 0, it changes it to a 1 then calls build_Observer2, which then runs on an internal loop. Now, you see something in there called Tagging, what i do for that is when i press Crtl+w, it records the mouse coords, and adds them to two arrays. and both work perfectly fine alone, although sometimes lately, the scripts dont turn off immidately, it takes a few tries of hitting the hotkey, but iv changed nothing, *shrugs* but what doesnt happen, is when i press crtl+q, the cycle function hotkey once iv started the build_observer2 function. they wont run at the same time, the idea is that cycle will cycle and click on buildings that i have tagged on the screen, the mouse coords, and that cycle will go through and click on each one for 100 ms, and while that is happening, the build_observer is constantly sending the hotkey for observers, which is "o", so it would cycle through the buildings constatnly building observers... thing is, they wont do it at the same time no matter what i do... any questions?

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Link to comment
Share on other sites

Just so you know AutoIt doesnt support 'multi-threading' as you are wanting it. A single AutoIt script cannot perform 2 tasks at the same time. It follows the code in a top to bottom order.

One thing you can do is create multiple scripts that will do what you need done at the same time the main script is doing something and call that when you need it, or figure out how to do something in a logical top down order.

I have played Starcraft - BroodWar. It is quite fun and I enjoy it. I understand, partially what you want it to do. Tell me if I am wrong. You basically want everytime you click on a building it fills up the building with the 'observer' per say?

If the above is true, I do believe there is a way to do this without having to have 2 scripts running at the same time. Please confirm the process you want.

Thanks and I hope I can help,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

okie dokie,

this doesnt work

CheckOut: http://www.kay-lync.com

and here is an example too

Func Build_Marine()

if $build_Marine = 0 Then

$build_Marine = 1

;build_Marine2() ; removed this line

EndIF

if $build_Marine = 1 Then

$build_Marine = 0

EndIf

EndFunc

and********

While $run = 1

if $build_Marine = 1

send("m")

sleep(5)

Endif

WEnd

you need to remove

Func Build_Marine2()

you can add more instances similar to this in your loop....

get it???

8)

NEWHeader1.png

Link to comment
Share on other sites

no, mostly i got the idea from a map called Mario Vs Pokemon, where you can make superunits if you mass enough of them to a certain location, like observers for instance... and after like 2 games, my hand felt like it was gonna fall off, so i made the first part, wehre it would just mass send the o key when i pressed crtl+1, and it worked beautifully, but i still had to click between 12 buildings... which isnt so bad, but why click them if you dont have to. ;-), and i know i could just write that when it clicks a "taged" area, it could just send the hotkey... but i wanna make it so that either i can use the hotkey on one building, like for a regular map, so i could just tap it to fill production queue, or tag a group of buildings, and it would just continute to loop through the "tag'ed areas" and build all my units while saving the world from carpols tunnel. :-P

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Link to comment
Share on other sites

also... the way it executes, you said from top to bottom, havent done that kinda thought process in years, iv been addicted to Java for like 2 years. So when a hotkey is pressed, does it bring the stack to the beginning of the method called by the hotkey? as you stated it doesnt do two things at once.

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Link to comment
Share on other sites

i am using the forum, i am using pm to allow you to know that i have replied, i was just heading off to bed before i figured id check if anyone had answered my question. Anyways no, but basically i know what i have to do. But threading would be something totally awesome to add to AI4. :-)... i dont know how to add modules, i am a limited C programmer, could i write a module or plugin or something for it? only kinda used AI for like 2 or 3 days total.

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Link to comment
Share on other sites

and about your code, you cant do it:

if $build_Marine = 0 Then

$build_Marine = 1

;build_Marine2() ; removed this line

EndIF

if $build_Marine = 1 Then

$build_Marine = 0

EndIf

you do an if twice, if $build_Marine = 0 Then

$build_Marine =1

end if

and right after that

if $build_Marine = 1 then

$build_Marine =0

endif

so no matter what, at the end, the value is gonna be 0

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Link to comment
Share on other sites

anyways, im pretty sure i know how to redesign it, just thought i was missing something, havent found a language/script that didnt have some form of support for parallelism. aside from like Javascript (which i dont know that it doesnt) and things of that nature. Threading is seriously under-rated. :-). Thanks for the awesome help and response tome. :-).

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Link to comment
Share on other sites

Alrighty. Been alot of discussion since I have been sleeping.

AutoIt can do multiple things at the same time by running multiple scripts. That isnt an issue.

AutoIt being based on C++ is similiar to it in architecture. It is a top down language. Granted you can call functions and they will execute their code, but unlike C++ it doesnt have threading support. Maybe you could list this in the Ideas forum. For all I know someone is trying to currently implement it. I know enough C++ to get done with my Encryption project not much more. I am using my project to push me to learn more about that area of C++.

Now back to your issue. Unless you are going to be able to get the screen at the same place every time then the MouseClick() isnt going to work out so well. What you can do is control your buildings with Ctrl+1 and so on... (just like grouping the soldiers). Then you can have AutoIt send that command to get you to the buildings.

I would say the be solution is that you click the buildings yourself. Because your screen would have to be on location with your base in order to send the proper commands. Its not like you could be watching your fight while your stuff is building up.

If you can pose some technical issues you are having with the actual script again I would love to help more, but I dont want to write a script at this time especially since I dont have that game on this computer.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Sorry.... its in a function...; do this

and return here

Func Build_Marine()

if $build_Marine = 0 Then

$build_Marine = 1

;build_Marine2() ; removed this line

return

EndIF

ok???

8)

<{POST_SNAPBACK}>

Couple of things. Include code in the [ code ] [ / code ] tags without the space.

Another issue is that above code you wrote is incomplete. As well as useless. You didnt EndFunc As well as you didnt Return anything at all. I dont know if that will produce an error or not but any way about it, its not a good practice.

Where are you getting this code from?

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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