Check for active window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ozzynotwood
Posts: 30
Joined: 16 Nov 2017, 19:19

Check for active window

08 May 2019, 03:23

Hi everyone

I'm having trouble with this script.

I want to trigger the compiled EXE with Touch Portal ( https://www.touch-portal.com ). For those who don't know what this is, it is a software version of a Stream Deck. This software has it's own features but I am using it to launch EXE files.

I want the script to load only when Discord.exe is the active window. Currently the script launches when anything is active. Other than that, the script does work, I just want to isolate it running when Discord.exe is active.

What needs to be done here?

Code: Select all

 #IfWinActive ahk_exe Discord.exe
    Inputbox, dv_Discord_Bold, Send BOLD text, What text do you need to convert to a bold font?
    if ErrorLevel
    Return
    else
    SendInput, {* 4}{Space}{Left 3}%dv_Discord_Bold%{Right 3}
    Return
#IfWinActive
[Mod note: Topic name added.]
User avatar
elModo7
Posts: 217
Joined: 01 Sep 2017, 02:38
Location: Spain
Contact:

Re: Check for active window

08 May 2019, 06:01

I don't have discord in this pc, should fix yours at home this afternoon.
Meanwhile, I'd not use #ifWinActive this time.
I'd suggest you take a look at this:

Code: Select all

If WinExist("ahk_exe discord.exe"){
	WinActivate
	Inputbox, dv_Discord_Bold, Send BOLD text, What text do you need to convert to a bold font?
	if ErrorLevel
	Return
	else
	SendInput, {* 4}{Space}{Left 3}%dv_Discord_Bold%{Right 3}
	Return
}

Also, I have been working on a Stream Deck alike app to work specifically with AHK (desktop client and server were made in AHK too):
https://www.youtube.com/watch?v=-S0fjprEzfQ
Just in case you are curious (although that one is in spanish sadly but have a few covering the app in english)
ozzynotwood
Posts: 30
Joined: 16 Nov 2017, 19:19

Re: Check for active window

08 May 2019, 06:18

Close, it activates discord but does not select the text field, so no text is sent. It ok though, my requirements have changed, will come up with a new script & post any issues soon.
elModo7 wrote:
08 May 2019, 06:01
I don't have discord in this pc, should fix yours at home this afternoon.
Meanwhile, I'd not use #ifWinActive this time.
I'd suggest you take a look at this:

Code: Select all

If WinExist("ahk_exe discord.exe"){
	WinActivate
	Inputbox, dv_Discord_Bold, Send BOLD text, What text do you need to convert to a bold font?
	if ErrorLevel
	Return
	else
	SendInput, {* 4}{Space}{Left 3}%dv_Discord_Bold%{Right 3}
	Return
}

Also, I have been working on a Stream Deck alike app to work specifically with AHK (desktop client and server were made in AHK too):
https www.youtube.com /watch?v=-S0fjprEzfQ Broken Link for safety
Just in case you are curious (although that one is in spanish sadly but have a few covering the app in english)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 66 guests