How to make the script work in multiple windows at once?

Ask gaming related questions (AHK v1.1 and older)
Zura1203
Posts: 1
Joined: 30 Jul 2021, 13:59

How to make the script work in multiple windows at once?

Post by Zura1203 » 30 Jul 2021, 14:12

Hi everyone.
I read a bunch of topics on how to make the script work in several minecraft at once, but did not find anything, I will be very glad if someone can help me with the code.
Here's my scenario. P.S. And please forgive the mistakes, I am Russian.

Code: Select all

#SingleInstance, force
#IfWinActive, ahk_exe javaw.exe
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
DetectHiddenWindows, On
SetTitleMatchMode, 2
Gui,1:+AlwaysOnTop
Gui, Add, Edit, x12 y60 w120 h20 vPressAD gTime_all,
Gui, Add, Edit, x12 y90 w120 h20 vPressW gTime_all,
Gui, Add, Edit, x12 y120 w120 h20 vClick1 gTime_all,
Gui, Add, Edit, x12 y150 w120 h20 vClick2 gTime_all,
Gui, Add, Edit, x12 y180 w120 h20 vClick3 gTime_all,
Gui, Add, Text, x142 y60 w100 h25 , Время зажатия A,D
Gui, Add, Text, x142 y90 w100 h25 , Время зажатия W
Gui, Add, Text, x142 y120 w100 h25 , Клавиша ломания ростков
Gui, Add, Text, x142 y148 w100 h25 , Бинд для /is
Gui, Add, Text, x142 y178 w100 h25 , Бинд для /skyblock
Gui, Add, Text, x12 y30 w610 h20 , Made by Zura
Gui, Add, Text, x12 y220 w220 h25 , Нажми F8 для запуска Авто-Фарма
Gui, Show, w260 h250, Авто фарм V.3
return
GuiClose:
ExitApp
Time_all:
Gui, Submit, NoHide
F8::
Loop
{
	ControlSend,, {%Click2% down}, ahk_exe javaw.exe
	sleep 100
	ControlSend,, {%Click2% up}, ahk_exe javaw.exe
	sleep 400
	ControlSend,, {%Click3% down}, ahk_exe javaw.exe
	sleep 100
	ControlSend,, {%Click3% up}, ahk_exe javaw.exe
	sleep 400
	
	ControlSend,, {w down}, ahk_exe javaw.exe
	sleep %PressW%
	ControlSend,, {w up}, ahk_exe javaw.exe
	
	ControlSend,, {a down}, ahk_exe javaw.exe
	sleep 400
	ControlSend,, {a up}, ahk_exe javaw.exe

	ControlSend,, {s down}, ahk_exe javaw.exe
	sleep 400 
	ControlSend,, {s up}, ahk_exe javaw.exe
	
	ControlSend,, {%Click1% down}, ahk_exe javaw.exe
	sleep 400

	ControlSend,, {a down}, ahk_exe javaw.exe
	sleep, %PressAD%
	ControlSend,, {a up}, ahk_exe javaw.exe
	
	ControlSend,, {w down}, ahk_exe javaw.exe
	sleep %PressW%
	ControlSend,, {w up}, ahk_exe javaw.exe
 
	ControlSend,, {d down}, ahk_exe javaw.exe
	sleep, %PressAD%
	ControlSend,, {d up}, ahk_exe javaw.exe
	
	ControlSend,, {%Click1% up}, ahk_exe javaw.exe
	sleep 100
}
Return
F12::ExitApp
Thanks for the help.
Last edited by gregster on 30 Jul 2021, 14:19, edited 1 time in total.
Reason: Topic moved from 'Scripts and Functions > ...'.

User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: How to make the script work in multiple windows at once?

Post by mikeyww » 30 Jul 2021, 17:06

Here is just a Notepad demonstration that might help with an idea.

Code: Select all

F3::type("notepad", "Test")

type(proc, keys) {
 WinGet, win, List, ahk_exe %proc%.exe
 Loop, %win%
  ControlSend,, %keys%, % "ahk_id " win%A_Index%
}
Or:

Code: Select all

F3::type("ahk_exe notepad.exe", "Test")

type(winTitle, keys) {
 WinGet, win, List, %winTitle%
 Loop, %win%
  ControlSend,, %keys%, % "ahk_id " win%A_Index%
}

Post Reply

Return to “Gaming Help (v1)”