Login Page - Create Account

Support Board

Date/Time: Thu, 07 Jul 2022 16:51:06 +0000

[Programming Help] - [Programming Help] - Is there a way to detect Sierra program window is not focused?

View Count: 136

[2022-05-20 22:55:53]
Tony - Posts: 230
Similar to sc.ChartWindowIsActive which only works within Sierra.

[2022-05-21 04:08:49]
User462086 - Posts: 173
If you're looking for a way to detect the status of the SC window from outside a custom study then have a look at AutoHotkey & it's functions like 'WinActive'.

Otherwise, this is not exactly what you're asking for, but it might help you get started. It detects when the SC window IS focused.

'scHasFocus' returns true when the chart the study is applied to has input focus (hence the SC program window is active & has focus).

bool   scHasFocus     = sc.ChartWindowHandle == GetFocus();
bool   wdwIsActive    = sc.ChartWindowIsActive;
bool   chartIsActive  = (scHasFocus) && (wdwIsActive);

if (chartIsActive)
//do something

GetFocus() "Retrieves the handle to the window that has the keyboard focus, if the window is attached to the calling thread's message queue."

[2022-05-21 04:34:03]
Tony - Posts: 230
Thanks so much! It works great!

scHasFocus alone gave me the behavior I want, when I read the
documentation of sc.ChartWindowHandle a while ago, I was intimidated
by the sentence "This is for advanced programming only.", looks like
it's really worth the time to dig it deeper.

Thanks again.

P.S. I've never heard of AutoHotKey, just checked their web site,
looks really handy, not sure if it would work on Linux, I will find out.
Date Time Of Last Edit: 2022-05-21 04:41:52
[2022-05-21 05:20:10]
User462086 - Posts: 173
Hi Tony, glad it worked out for you :)

To post a message in this thread, you need to log in with your Sierra Chart account:


Login Page - Create Account