Support Board
Date/Time: Wed, 12 Mar 2025 17:07:44 +0000
[Programming Help] - [Programming Help] - Is there a way to detect Sierra program window is not focused?
View Count: 653
[2022-05-20 22:55:53] |
Tony - Posts: 553 |
Similar to sc.ChartWindowIsActive which only works within Sierra. Thanks! |
[2022-05-21 04:08:49] |
User462086 - Posts: 196 |
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." https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getfocus |
[2022-05-21 04:34:03] |
Tony - Posts: 553 |
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: 196 |
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: