Sign in to follow this  
Followers 0
mavor

Threading and Parrallel script execution

7 posts in this topic

Hello all, I apologize if this question has already been answered and could have been found by using the search engine. I did not turn anything up when I searched.

I would like to know if it is possible to create multiple parallel script execution branches using AutoIT. Eg. sending a 400 ms keypress to one application, and at the same time, send a 700 ms keypress to another application. In more detail, I wish to create a script capable of branching itself out based on how many applications are open at the same time. If i were to open application A, then the script would begin running on it, and if i happened to open application B, the script would detect the new application being opened and then begin initiating a new branch of itself on that application (sending keystrokes and the like).

Thank you very much for your time and again I apologize if this has already been answered before.

Share this post


Link to post
Share on other sites



For something like that you could use _Timer_SetTimer.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

You might want to reinstall your browser as the search function on it seems to be broken, or on auto ignore.

My search for threading turned up tons of results on multi threading.

General opnion seems to be no, but you might want to look at some og trancex posts in the example scripts forum.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

True multithreading is not currently available in AutoIt at the current time. There are several UDFs and workarounds that will allow you to get similar results, but no true multithreading. Trancxx has made a few great examples somewhere on here. AdlibRegister in the new beta version is an easy alternative to multithreading. There is also an adlib udf that uses adlib functions in an intuitive way to create the effect of multithreading. If you searched the forum for multithreading and didn't come up with anything, something is wrong. This topic has been discussed and developed many times before.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Would it be possible to just start up an instance of AutoIT3 for each application I want to run it on? Is it possible for the same key to be "pressed" in two or more applications at the same time?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Would it be possible to just start up an instance of AutoIT3 for each application I want to run it on?

Yes, you can run as many scripts at once as you like, or you can compile them and run the exes.

Is it possible for the same key to be "pressed" in two or more applications at the same time?

Only one proces can have the keyboard focus, but you could set a hotkey the same in each application. Then you would have to resend that key sequence while the hotkey was temporarily turned off. Something like this.(not tested)

HotKeySet("{F10}","dostuff")


while 1
 sleep(90)
wend

Func dostuff()
 HotKeySet("{F10}");so that we can send this hotkey and not respond to it

 Send("{F10}");send the hotkey so other applications will see it
 $T = timerinit()

;stuff to be done

 while TimerDiff($T) < 2000;allow time for other processes to deal with the hotkey
 sleep(50)
 wend
HotKeySey("{F10}");turn it back on again
EndFunc
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

So if i had two scripts open one in each application and they both wanted to press a key for 500 ms... only one of them would actually be able to do so and the other one would be out of luck? The problem with hotkeys is that in one program you might want a 500 ms keypress whereas in the other you might want a 1500 ms keypress ;D

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