Jump to content

AHK _Class problem

Go to solution Solved by userid,

The class Chrome_WidgetWin1 is used by a variety of software. You may hit this roadblock in the future again, so it's a good exercice to learn other methods.

 

The AutoHotKey installation folder (should be: C:\Program Files\AutoHotkey) contains a veyr useful ahk script called "window spy".

You can use it to easily find the ahk_class of a window, but also:

its title (usually the same as the one in the top bar of the window)

its exe (the .exe that spawned it)

And much more.

 

For the simple scenario that you are describing and since we're talking about two different programs, you could replace instances of ahk_class Chrome_WidgetWin_1 to ahk_exe your_program.exe.

 

Note that if the programs in question have multiple windows open at the same time, AutoHotKey will, depending on the script's settings, either apply the instructions to the first window it finds that belongs to the indicated .exe (usually searching from the foremost windows and going down the pile), or to all of them.

 

If the programs you use have multiple windows open at one time then, using their title would be better. For that, just type the title literally, without enclosing quotes.

 

Examples:

 

currently:

intended for one program

WinActivate, ahk_class Chrome_WidgetWin_1

WinWaitActive, ahk_class Chrome_WidgetWin_1

Send, Hello{Enter}

 

intended for another one

WinActivate, ahk_class Chrome_WidgetWin_1

WinWaitActive, ahk_class Chrome_WidgetWin_1

Send, +{Tab}{Space}

 

This solution may be problematic, whereas this one

 

new script:

intended for one program

WinActivate, ahk_exe program_1.exe

WinWaitActive, ahk_exe program_1.exe

Send, Hello{Enter}

 

intended for another one

WinActivate, program_2.exe

WinWaitActive, program_2.exe

Send, +{Tab}{Space}

 

should work better, as long as these programs don't have multiple windows, in which case it may or may not work depending on several factors.

 

Try that method, and come back to let us know how it went. There are many more solutions if your use case require

Recently I used on of Taran's scripts and adjusted it to fit my workflow. I use the numpad (as you can see in the code) as my 'macro pad' but the problem is that my Video Editing Program of Choice 'Hitfilm Epress' and OBS both have  the same ahk_class. I found it on his github 2nd-keyboard-master.zip\2nd-keyboard-master\Taran's_Windows_Mods\I_do_not_use 

I would really appreciate i someone can help me

 

A workaround I found 'For now' is to make a numpad button press a hotkey and setting the app to launch if that hothey is pressed (as you can see in the last few lines). Maybe @TaranLMG

Here is all the code:

NumpadEnd::
IfWinNotExist, ahk_class CabinetWClass
    Run, explorer.exe
if WinActive("ahk_class CabinetWClass")
    Send ^{tab}
else
    WinActivate ahk_class CabinetWClass
Return

NumpadDown::
IfWinNotExist, ahk_class Chrome_WidgetWin_1
    Run, msedge.exe
if WinActive("ahk_class Chrome_WidgetWin_1")
    Send ^{tab}
else
    WinActivate ahk_class Chrome_WidgetWin_1
Return

NumpadHome::
IfWinNotExist, ahk_class TaskManagerWindow
    Run, Taskmgr.exe
WinActivate ahk_class TaskManagerWindow
Return

NumpadPgDn::
IfWinNotExist, ahk_class Qt5QWindowIcon
    Run, C:\Program Files\FXHOME\HitFilm Express
WinActivate ahk_class Qt5QWindowIcon
Return

NumpadLeft::
IfWinNotExist, ahk_class Qt5QWindowIcon
    Run, C:\Program Files\FXHOME\HitFilm Express
WinActivate ahk_class Qt5QWindowIcon
Return

PrintScreen::RButton
NumpadHome::F13
NumpadRight::^F1
NumpadClear::^F2

 

A guy asking and answering in his bedroom since he has nothing else to do

Link to comment
Share on other sites

Link to post
Share on other sites

The class Chrome_WidgetWin1 is used by a variety of software. You may hit this roadblock in the future again, so it's a good exercice to learn other methods.

 

The AutoHotKey installation folder (should be: C:\Program Files\AutoHotkey) contains a veyr useful ahk script called "window spy".

You can use it to easily find the ahk_class of a window, but also:

its title (usually the same as the one in the top bar of the window)

its exe (the .exe that spawned it)

And much more.

 

For the simple scenario that you are describing and since we're talking about two different programs, you could replace instances of ahk_class Chrome_WidgetWin_1 to ahk_exe your_program.exe.

 

Note that if the programs in question have multiple windows open at the same time, AutoHotKey will, depending on the script's settings, either apply the instructions to the first window it finds that belongs to the indicated .exe (usually searching from the foremost windows and going down the pile), or to all of them.

 

If the programs you use have multiple windows open at one time then, using their title would be better. For that, just type the title literally, without enclosing quotes.

 

Examples:

 

currently:

intended for one program

WinActivate, ahk_class Chrome_WidgetWin_1

WinWaitActive, ahk_class Chrome_WidgetWin_1

Send, Hello{Enter}

 

intended for another one

WinActivate, ahk_class Chrome_WidgetWin_1

WinWaitActive, ahk_class Chrome_WidgetWin_1

Send, +{Tab}{Space}

 

This solution may be problematic, whereas this one

 

new script:

intended for one program

WinActivate, ahk_exe program_1.exe

WinWaitActive, ahk_exe program_1.exe

Send, Hello{Enter}

 

intended for another one

WinActivate, program_2.exe

WinWaitActive, program_2.exe

Send, +{Tab}{Space}

 

should work better, as long as these programs don't have multiple windows, in which case it may or may not work depending on several factors.

 

Try that method, and come back to let us know how it went. There are many more solutions if your use case require

Link to comment
Share on other sites

Link to post
Share on other sites

@JuliaAlphaDeltaEcho Thank you so much! I tried the solution you suggested and it worked perfectly fine! Again, thank you. You have saved me from troubleshooting it for hours!

A guy asking and answering in his bedroom since he has nothing else to do

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, George Vella said:

@JuliaAlphaDeltaEcho Thank you so much! I tried the solution you suggested and it worked perfectly fine! Again, thank you. You have saved me from troubleshooting it for hours!

Glad I could help 🙂

Don't forget to mark the thread as solved (if that's a thing here, don't know, just registered).

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×