Run multiple macro at the same time (for multiple application) Topic is solved

Ask for help, how to use AHK_H, etc.
scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Run multiple macro at the same time (for multiple application)

27 Aug 2018, 04:09

Hi all ;)

I have "problem" with standard AHK because it's NOT multithread so ... found this :clap:

Now, ask if it's possible to do this "simple" macro:

i have 15 NOX (android simulator) windows open with the same game and want to make the same "macro" on all NOX windows in the same time:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



This work ok on single NOX session (activate) , the question is: how to translate in multithread for work on 15 different windows ??

if it's possible of course ;)

I think it's impossible to make "active" 15 windows at the some time, so must change CoordMode to Screen and use ControlClick ecc.


EDIT: please move to Ask for Help section .. sorry :oops:
HotKeyIt
Posts: 1686
Joined: 29 Sep 2013, 18:35
Contact:

Re: Run multiple macro at the same time (for multiple application)

27 Aug 2018, 15:33

You will have to check if ControlClick works and all windows would need to be side by side so PixelGetColor will work.
You will need find the window position and get the relative coordinates.
Script would be something like this (above not applied), depending on how you want to control it:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)

29 Aug 2018, 04:12

Great ... so i just create one or more thread and use it.
I haven't time to realize some script, just download and use/substitute AutoHotkey_H ;) ... then my idea, NOT tested, and just for "test about correct thread syntax":

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Every Loop need about 20/30 sec to finish ... so my idea are to start one Loop, then start the other ... everyone with/in different thread ... so all work in the same time

EDIT: ... or it's good idea to put "Stop execution in thread and free resources" at the end of Loop into the function ?
HotKeyIt
Posts: 1686
Joined: 29 Sep 2013, 18:35
Contact:

Re: Run multiple macro at the same time (for multiple application)

29 Aug 2018, 15:02

It would not work that way since your coordinates would be the same, you will have to calculate coordinates inside the loop, you can use WinGet to cycle through all windows.
scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)

30 Aug 2018, 13:10

Well, I have make one "running" thread :thumbup: ... but have strange problem ... someone "solved" and someone not :shock:

sorry for too many ";" but i want to "store" old code ;)

1. if i set CoordMode to Screen, at the begin of script ... of course it not work for the new thread, so add CoordMode into begin of the new thread and it work perfectly ;)
2. script work perfectly but if i use "ahkthread_free(ahk_Buldrain),ahk_Buldrain:="" " ... it stop to work :?: why :shifty:

now the script

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

HotKeyIt
Posts: 1686
Joined: 29 Sep 2013, 18:35
Contact:

Re: Run multiple macro at the same time (for multiple application)

30 Aug 2018, 16:05

Simply do ahk_Buldrain:="", rest will be done automatically.
scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)

31 Aug 2018, 04:47

Thanks ;)

Now i need to start one other thread like for other window ... just change mouse and color coordinates.
Easy way are to make other HotKey (!^x:: for example) ... but for start two, or more, thread with only one HotKey ?
scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)

31 Aug 2018, 10:24

sorry, i make stupid question before ... just add, other "thread", next to the other ... work fine and it's really GREAT form me :superhappy:

now i must try more, more idea :D

Wonderfull AutoHotkey_H :clap:
scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)

02 Sep 2018, 08:40

Hi again, simply question about my stupid macro ... can i improve it into one more "professional way" ?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Create a Function to begin one thread and pass to function pixel data ?
HotKeyIt
Posts: 1686
Joined: 29 Sep 2013, 18:35
Contact:

Re: Run multiple macro at the same time (for multiple application)

02 Sep 2018, 13:25

It does not make sense to Stop execution in thread and free resources directly after starting the thread, I will not have a chance to do anything!
Here the function:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)

03 Sep 2018, 07:05

It work fine now ;)

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by scriptors on 03 Sep 2018, 15:03, edited 2 times in total.
HotKeyIt
Posts: 1686
Joined: 29 Sep 2013, 18:35
Contact:

Re: Run multiple macro at the same time (for multiple application)

03 Sep 2018, 14:31

See the example above MsgBox " xClick "... instead of MsgBox %xClick%...
scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)

03 Sep 2018, 15:03

yes, last edit before, now work fine
scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)

03 Sep 2018, 16:13

mmm ... it stop working when i change coords

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



and i must change:

Code: [Select all] [Download] GeSHi © Codebox Plus

	ControlClick, x%xClick% y%yClick%, %wname%,,,, NA

with

Code: [Select all] [Download] GeSHi © Codebox Plus

	ControlClick, x%xClick% y%yClick%, " wname ",,,, NA

probably all function work with same data ... and i don't understand difference for: " FunctionVariable "
scriptors
Posts: 139
Joined: 25 Feb 2016, 09:01

Re: Run multiple macro at the same time (for multiple application)  Topic is solved

04 Sep 2018, 14:04

stupid error, I wrong the coordinates (must x348 and I wrote x384 :crazy: ) and then the function was not going ... so this is working function for call how many thread i like

this work at 100%

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


It is true that 99% of the problems lie between the chair and the keyboard :lol:

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 1 guest