We have multiple TVs each connected to a different computer. The goal is to display/setfocus on a continuous loop cycling through two applications. This has to be synchronized across all TVs. Originally i had set it up cycle through all the apps in the task bar by sending the alt+esc key. Which worked fine but had a hard time synchronizing it across all TVs. So i used the AppActivate to setfocus and switch between windows based on even/odd minute. It is now synchronized, but the screen seems to try to setfocus to the window every second therby causing the screen to flicker all the time. How can i avoid it??? Any suggestions??? Here is the part of the code.
' Loop lasts 1 second
intSleep = 1000
Set wshShell = CreateObject("WScript.Shell")
'repeat process indefinetly
Do while infiniteloop=0
a = minute(time())
intResult = a Mod 2 ' to check for even/odd minute
If intResult = 0 Then
'display window1
if wshShell.AppActivate "Display - [Dashboard]" = false then
wshShell.AppActivate "Display - [Dashboard]"
end if
ElseIf intResult = 1 Then
'display window2
if wshShell.AppActivate "Display - [TEST]" = false then
wshShell.AppActivate "Display - [TEST]"
end if
End If
Wscript.Sleep intSleep
Loop
It flickers every second because the variable intResult
equals 0
for the entire even minute. What you need is another variable, like "intLastResult"
.
At the end of your loop, you would set intLastResult=intResult
, and re-do your IF statements for changing focus so they only execute when the current result differs from the previous result.
I.E. "If intResult=0 AND intLastResult=1 Then" or "If intResult=1 AND intLastResult=0 Then"
This way they should only fire once per minute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With