Sending key to inactive & active window.
Sending key to inactive & active window.
Fixed.
Last edited by Vexides on 25 Jun 2021, 17:54, edited 1 time in total.
Re: Sending key to inactive & active window.
Hallo,
always take the first step before the second! Before you start a longer script, test if Autohotkey can distinguish your two tabs.
Try:
always take the first step before the second! Before you start a longer script, test if Autohotkey can distinguish your two tabs.
Try:
Code: Select all
q::
WinGet, GotaPID, List, ahk_exe javaw.exe
Loop,% GotaPID
MsgBox,% "GotaPID" A_Index ": " GotaPID%A_Index%
Return
Re: Sending key to inactive & active window.
Yes! They both have different PIDs.Rohwedder wrote: ↑25 Jun 2021, 05:00Hallo,
always take the first step before the second! Before you start a longer script, test if Autohotkey can distinguish your two tabs.
Try:Code: Select all
q:: WinGet, GotaPID, List, ahk_exe javaw.exe Loop,% GotaPID MsgBox,% "GotaPID" A_Index ": " GotaPID%A_Index% Return
Re: Sending key to inactive & active window.
Then try:
Code: Select all
#Warn
SetTitleMatchMode, 2
End::ExitApp
q::
Hotkey, *~t, Toggle
WinGet, GotaPID, List, ahk_exe javaw.exe
Return
*~t::
SetKeyDelay, 1
IF WinActive("ahk_pid " GotaPID1)
ControlSend, , t, ahk_pid %GotaPID2%
Else
ControlSend, , t, ahk_pid %GotaPID1%
sleep 10
return
Re: Sending key to inactive & active window.
This code isn't sending any key in any of those tabs.Rohwedder wrote: ↑25 Jun 2021, 12:03Then try:Code: Select all
#Warn #Persistent SetTitleMatchMode, 2 End::ExitApp q:: Hotkey, *~$t, Toggle WinGet, GotaPID, List, ahk_exe javaw.exe Return *~$t:: SetKeyDelay, 1 ControlSend, , t, ahk_pid %GotaPID1% ControlSend, , t, ahk_pid %GotaPID2% sleep 10 return
Re: Sending key to inactive & active window.
Here this works with two Notepad windows:or:
Code: Select all
q:: ;opens 2 Notepad windows side by side
Loop, 2
{
Run, Notepad.exe
Sleep, 500
WinMove, A,,% 500 * (A_Index-1),0 ,500, 500
}
Return
~w:: ;writes w each also in the other Notepad window
WinGet, ID, List, ahk_exe Notepad.exe
; ToolTip,% ID1 " > " ID2
IF WinActive("ahk_id " ID1)
ControlSend,, w, ahk_id %ID2%
Else
ControlSend,, w, ahk_id %ID1%
Return
Code: Select all
Loop, 2
{ ;opens 2 Notepad windows side by side
Run, Notepad.exe
Sleep, 500
WinMove, A,,% 500 * (A_Index-1),0 ,500, 500
}
WinGet, ID, List, ahk_exe Notepad.exe
Loop
{ ;writes also in the other Notepad window
Input, Key, VCL1
IF WinActive("ahk_id " ID1)
ControlSend,, {%Key%}, ahk_id %ID2%
Else
ControlSend,, {%Key%}, ahk_id %ID1%
}
Return
Who is online
Users browsing this forum: No registered users and 67 guests