Hi all
I have, for example, 5 NOX (android emulator) session open into my desktop and working on it with 5 game opened.
i make one single macro for mouseclick at specific coordinates into active windows ... and this it's not a problem ... after macro ending i activate other session and "macro-work" with next
my "goal" are to start working macro on active windows (with some mouse clicks on it) -> activate other windows and start other macro (with some mouse clicks on it) -> activate other window ecc. ... so:
- mouse clicks on window n.1 continue like programmed ...
- mouse clicks on window n.2 continue like programmed ...
- use "normally" mouse and keyboard on windows n.3 or 4 ecc.
BUT
I think if AHK send mouse click on specific position and i'm working on other windows ... probably i have problem with mouse movment ... and i know coordinates of "active window", if I activate other windows my "normal" macro go over the new activated
are possibilities to, for wxample, SendEvent {Click 100, 200} without interact with normal mouse operation and not in active windows ?
Any "idea" are welcome
EDIT: change title
Run multiple macro at the same time (for multiple application)
Run multiple macro at the same time (for multiple application)
Last edited by scriptors on 13 Aug 2018, 04:59, edited 1 time in total.
Re: Best way (if possible) to have multiple macro on multiple application
I am having a hard time understanding the problem, but taking a look at controlClick may help. ControlClick lets you click on an inactive windows without actually using the mouse. To click on inactive windows you must specify which window you want to click on using the ahk_id rather than using the active window.
Re: Best way (if possible) to have multiple macro on multiple application
Thanks, i try it
write one example of part of my script:
So i think must have two possibilities:
1. write two macro, one for "night working" (time-opens nox session, activate single windows and automatic work on it) and one for when i'm online and use more NOX session at same time with "ControlClik"
2. write one macro usable for night and morning session
.... i must make more knowledge about it
So ... I have, for example, 3 nox session opened ... "1", "2" and "3" ... then:
BUT ... i think ... i need someone like "ControlPixelGetColor"
write one example of part of my script:
Code: Select all
Mission_GG:
Loop
{
PixelGetColor, Res, 435, 160, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
MouseClick, left, 435, 160 ; click Mission
}
Return
1. write two macro, one for "night working" (time-opens nox session, activate single windows and automatic work on it) and one for when i'm online and use more NOX session at same time with "ControlClik"
2. write one macro usable for night and morning session
.... i must make more knowledge about it
So ... I have, for example, 3 nox session opened ... "1", "2" and "3" ... then:
Code: Select all
Mission_GG:
Loop
{
PixelGetColor, Res, 435, 160, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
ControlClick, x435 y 160, 1,,,, NA ; click Mission ... BUT it's work only for NOX window named "1" and NOT for all windows, so must make one for every windows
}
Return
Re: Best way (if possible) to have multiple macro on multiple application
Try this. It looks like your window names are integers so I just used a_index as their window name.
Code: Select all
;use absolute coordinates rather than relative so you dont have to activate any windows
CoordMode ,Pixel,Screen ;set this to use absolute coordinates
numberOfNOXWindows := 4
Mission_GG:
Loop
{
loop %numberOfNOXWindows%
{
guiName := A_index ; if all your window names are integers you can just us a_index as their name
WinGetPos , X, Y, Width, Height, %guiName%, ;get the position of the window you want to search
newX := X + 435
newY := Y + 160
PixelGetColor, Res, %newX%, %newY%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
tooltip % "x" . newX . " y" . newY
ControlClick, x%newX% y%newY%, %guiName%,,,, NA ; this should click on every window using absolute coordinates
}
}
Return
Re: Best way (if possible) to have multiple macro on multiple application
God idea
I just think to solve problem by "position-fix the NOX-windows" and use absolute coordinates ... with your solution it's more clear how to make it
only problem it's to have two different AHK.macro because normally, i use ActiveWindows CoordMode for the "night macro"
i try this and post result ... work must to be functional and completed
ps. and sorry for my bad english
EDIT: ... but I can change all "windows coordinates" by use windows name and relative position
I just think to solve problem by "position-fix the NOX-windows" and use absolute coordinates ... with your solution it's more clear how to make it
only problem it's to have two different AHK.macro because normally, i use ActiveWindows CoordMode for the "night macro"
i try this and post result ... work must to be functional and completed
ps. and sorry for my bad english
EDIT: ... but I can change all "windows coordinates" by use windows name and relative position
Re: Run multiple macro at the same time (for multiple application)
Hi again
The solution from @colt are ok, but it make "one step" at time ... for some situation i need more time to make it for all my NOX session so i think about two solution:
1. make more file.ahk with macro for every single NOXSession (without activate it)
2. i don't know if it's possible to have more Loop run simultaneously and how to make it
For stupid things i use (like example):
I must repeat this for 3 time (different coordinates for different things) and must add color control control for "safe" working ... but this are simply and stupid use of AHK ... but work
My goal are to, for example:
Of course this situation make first loop one then loop two ... and are not good for me
I must try to make N1.ahk and N2.ahk (run at some time) with:
N1.ahk
N2.ahk
i don't know if the same !^m:: call at some time the two loop ... but try
sorry for my english and ... i hope you understand me and have more "professional" solution for solve this
The solution from @colt are ok, but it make "one step" at time ... for some situation i need more time to make it for all my NOX session so i think about two solution:
1. make more file.ahk with macro for every single NOXSession (without activate it)
2. i don't know if it's possible to have more Loop run simultaneously and how to make it
For stupid things i use (like example):
Code: Select all
!^+a::
; first FIVE windows have the same dimension (small)
ControlClick, x435 y 160, N1,,,, NA ; click help button
Sleep 100
ControlClick, x435 y 160, N2,,,, NA ; click help button
Sleep 100
ControlClick, x435 y 160, N3,,,, NA ; click help button
Sleep 100
ControlClick, x435 y 160, N4,,,, NA ; click help button
Sleep 100
ControlClick, x435 y 160, N5,,,, NA ; click help button
Sleep 100
; next FOUR windows have the same dimension (more big)
ControlClick, x385 y 125, N6,,,, NA ; click help button
Sleep 100
ControlClick, x385 y 125, N7,,,, NA ; click help button
Sleep 100
ControlClick, x385 y 125, N8,,,, NA ; click help button
Sleep 100
ControlClick, x385 y 125, N9,,,, NA ; click help button
Sleep 100
Return
My goal are to, for example:
Code: Select all
;use absolute coordinates rather than relative so you dont have to activate any windows
CoordMode ,Pixel,Screen ;set this to use absolute coordinates
Mission_GG:
Loop ; first Loop for N1 window
{
WinGetPos , X, Y, Width, Height, N1, ;get the position of the window N1
newX := X + 435
newY := Y + 160
PixelGetColor, Res, %newX%, %newY%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
tooltip % "x" . newX . " y" . newY
ControlClick, x%newX% y%newY%,N1,,,, NA ; click on N1 window using absolute coordinates ... work for 10 clicks and 10 seconds
}
Loop ; second Loop for N2 window
{
WinGetPos , X, Y, Width, Height, N2, ;get the position of the window N2
newX := X + 435
newY := Y + 160
PixelGetColor, Res, %newX%, %newY%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
tooltip % "x" . newX . " y" . newY
ControlClick, x%newX% y%newY%,N2,,,, NA ; click on N2 window using absolute coordinates ... work for 10 clicks and 10 seconds
}
.... other Loop
Return
I must try to make N1.ahk and N2.ahk (run at some time) with:
N1.ahk
Code: Select all
;use absolute coordinates rather than relative so you dont have to activate any windows
CoordMode ,Pixel,Screen ;set this to use absolute coordinates
!^m:: ; just for example
Loop ; first Loop for N1 window
{
WinGetPos , X, Y, Width, Height, N1, ;get the position of the window N1
newX := X + 435
newY := Y + 160
PixelGetColor, Res, %newX%, %newY%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
tooltip % "x" . newX . " y" . newY
ControlClick, x%newX% y%newY%,N1,,,, NA ; click on N1 window using absolute coordinates ... work for 10 clicks and 10 seconds
}
Code: Select all
!^m:: ; just for example
Loop ; second Loop for N2 window
{
WinGetPos , X, Y, Width, Height, N2, ;get the position of the window N2
newX := X + 435
newY := Y + 160
PixelGetColor, Res, %newX%, %newY%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
tooltip % "x" . newX . " y" . newY
ControlClick, x%newX% y%newY%,N2,,,, NA ; click on N2 window using absolute coordinates ... work for 10 clicks and 10 seconds
}
Return
sorry for my english and ... i hope you understand me and have more "professional" solution for solve this
Re: Run multiple macro at the same time (for multiple application)
I think I understand your problem. Use setTimer so you get multithreading behavior. If you use set timer your sleep commands will run independent and won't interfere with the rest of the program while still having all your code in one script.
Something like This
Something like This
Code: Select all
setTimer t1,500
setTimer t2,500
;these two timers will be running in parallel
t1:
WinGetPos , X, Y, Width, Height, N1, ;get the position of the window N1
newX := X + 435
newY := Y + 160
PixelGetColor, Res, %newX%, %newY%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
tooltip % "x" . newX . " y" . newY
ControlClick, x%newX% y%newY%,N1,,,, NA ; click on N1 window using absolute coordinates ... work for 10 clicks and 10 seconds
return
t2:
WinGetPos , X, Y, Width, Height, N2, ;get the position of the window N1
newX := X + 435
newY := Y + 160
PixelGetColor, Res, %newX%, %newY%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4D5D or Res = 0x394B58){ ; checks if MISSION are END
Sleep 2000
break ; Terminate the loop
}
Sleep 500
tooltip % "x" . newX . " y" . newY
ControlClick, x%newX% y%newY%,N2,,,, NA ; click on N2 window using absolute coordinates ... work for 10 clicks and 10 seconds
return
Re: Run multiple macro at the same time (for multiple application)
well, i try it ... but:
Threads: https://autohotkey.com/docs/misc/Threads.htm
Threads: https://autohotkey.com/docs/misc/Threads.htm
i try with simply and small loop and test how work... Although AutoHotkey doesn't actually use multiple threads, it simulates some of that behavior ...
Re: Run multiple macro at the same time (for multiple application)
i have poor result ... but depend by my poor knowledge
i must use ControlClick with internal Windows coorinates ... so if i use !^k:: one part of macro work correctly
i must use ControlClick with internal Windows coorinates ... so if i use !^k:: one part of macro work correctly
Code: Select all
!^g::
setTimer N4, 500
setTimer N5, 500
Return
N4:
!^k::
Loop
{
WinGetPos , X, Y, Width, Height, 4, ;get the position of the window 4
newX4 := X + 320
newY4 := Y + 120
PixelGetColor, Res, %newX4%, %newY4%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4E5C or Res = 0x3F4E5C){ ; checks if MISSION are ON
Sleep 500
MsgBox finito
break ; Terminate the loop
}
Sleep 500
; tooltip % "x" . newX4 . " y" . newY4
ControlClick, x320 y120, 4,,,, NA ; click on N4 window using internal coordinates (absolute coordinates NOT work)
Sleep 300
}
return
N5:
Loop
{
WinGetPos , X, Y, Width, Height, 5, ;get the position of the window N5
newX5 := X + 320
newY5 := Y + 120
PixelGetColor, Res, %newX5%, %newY5%, RGB ; Gets the colour at the coordinates (x, y) in the active window
if(Res = 0x3F4E5C or Res = 0x3F4E5C){ ; checks if MISSION are ON
Sleep 500
MsgBox finito
break ; Terminate the loop
}
Sleep 500
; tooltip % "x" . newX5 . " y" . newY5
ControlClick, x320 y120, 5, , , , NA ; click on N5 window using internal coordinates (absolute coordinates NOT work)
Sleep 300
}
return
Re: Run multiple macro at the same time (for multiple application)
Adjust some mistake ... now work but:
first finish on Window N5 and after start on window N4
first finish on Window N5 and after start on window N4
Spoiler
Who is online
Users browsing this forum: No registered users and 338 guests