Change language input when WhatsApp is active Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pgeugene
Posts: 30
Joined: 27 Jun 2019, 04:36

Change language input when WhatsApp is active

Post by pgeugene » 02 Jun 2023, 03:50

Below is the code that supposed to press #{Space} when WhatsApp is active
Unfortunately immediately the script is launched, #{Space} is pressed although WhatsApp is not active
When I made WhatsApp active, #{Space} is not pressed
Anything wrong with the code ?

Code: Select all

if WinActive("ahk_exe WhatsApp.exe")
          Send #{Space}

User avatar
boiler
Posts: 16928
Joined: 21 Dec 2014, 02:44

Re: Change language input when WhatsApp is active  Topic is solved

Post by boiler » 02 Jun 2023, 04:38

pgeugene wrote: Anything wrong with the code ?
Yes. Why would you expect it to send that whenever it becomes active? You have nothing that says to keep executing those lines of code. You could put them in a loop or use SetTimer, but then it would keep sending it over and over. I assume you want it sent once each time it becomes active. This will do that:

Code: Select all

loop {
	WinWaitActive, ahk_exe WhatsApp.exe
	Send #{Space}
	WinWaitNotActive, ahk_exe WhatsApp.exe
}

pgeugene
Posts: 30
Joined: 27 Jun 2019, 04:36

Re: Change language input when WhatsApp is active

Post by pgeugene » 03 Jun 2023, 03:57

@boiler
Thank you for your help

Post Reply

Return to “Ask for Help (v1)”