It is currently April 19th, 2024, 6:43 pm

Focus-stealing problem launching VBS

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Focus "stealing"

Post by Yincognito »

Nightblade wrote: August 6th, 2020, 2:27 am Doesn't help with focus-stealing sadly.

Code: Select all

[RunVBS]
Measure=Plugin
Plugin=RunCommand
State=Hide
Parameter=#@#Scripts\ABB-Usage.vbs #CURRENTCONFIG# #CURRENTFILE#
Edit: The VBS has no output other than MsgBox for errors. Running it via Task Scheduler does not steal focus.
Try this, and see if a different handler changes things (it automatically runs either directly or hidden the script above, depending on the commented line):

Code: Select all

[Variables]
UpdateCount=60
Handler=wscript.exe
;Handler=cscript.exe

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

[MeasureRunHidden]
Measure=Plugin
Plugin=RunCommand
Parameter=#Handler# #@#Scripts\HelloWorld.vbs
State=Hide
OutputType=ANSI
Timeout=5000

[MeasureCounter]
Measure=Calc
Formula=(MeasureCounter+1)
IfCondition=(MeasureCounter=#UpdateCount#)
IfTrueAction=["#Handler#" "#@#Scripts\HelloWorld.vbs"]
;IfTrueAction=[!CommandMeasure MeasureRunHidden "Run"]
IfConditionMode=1
DynamicVariables=1

---Meters---

[MeterRunCounter]
Meter=String
FontSize=16
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
Y=0R
AntiAlias=1
MeasureName=MeasureCounter
Text=Update Counter (Run at #UpdateCount#): %1 updates

[MeterRunHidden]
Meter=String
FontSize=16
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
Y=0R
AntiAlias=1
Text=Click to Run using RunCommand - hidden
LeftMouseUpAction=[!CommandMeasure MeasureRunHidden "Run"]

[MeterRunDirectly]
Meter=String
FontSize=16
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
Y=0R
AntiAlias=1
Text=Click to Run directly - briefly visible
LeftMouseUpAction=["#Handler#" "#@#Scripts\HelloWorld.vbs"]
In my case, this only stole focus when the handler was cscript.exe and it ran directly, in Fifa 09 and Euro Truck Simulator 2, but stole focus even when the handler was wscript.exe and it ran hidden, in Civilization 4 BTS. In other words, most of the time it didn't steal the focus (Civ 4 is not an actuall full screen application, by the way). I believe it depends on the game as well.

Maybe one could deal with it in VBS itself. Take a look here for details.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Nightblade
Posts: 20
Joined: August 21st, 2012, 5:17 am

Re: Focus-stealing problem launching VBS

Post by Nightblade »

Tried your suggestions didn't help :\
User avatar
Yincognito
Rainmeter Sage
Posts: 7127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Focus-stealing problem launching VBS

Post by Yincognito »

Nightblade wrote: August 6th, 2020, 11:33 am Tried your suggestions didn't help :\
Have you tried different games? Does it happen for all of them?
Also, have you tried the code I posted or just integrated it into your own code?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Nightblade
Posts: 20
Joined: August 21st, 2012, 5:17 am

Re: Focus-stealing problem launching VBS

Post by Nightblade »

Yes, it happens with different games running in fullscreen.

I integrated your suggestions into the existing code (it's not mine though).
User avatar
Yincognito
Rainmeter Sage
Posts: 7127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Focus-stealing problem launching VBS

Post by Yincognito »

Nightblade wrote: August 7th, 2020, 1:37 am Yes, it happens with different games running in fullscreen.

I integrated your suggestions into the existing code (it's not mine though).
I strongly believe it's something else in your script that's stealing focus, and not the fact that a script is run by Rainmeter, and my tests seem to confirm that. However, since you only tried to integrate my suggestions in your skin and didn't ran my last posted code (along with the simple HelloWorld.vbs script) separately (so we could confirm it), I guess we'll never know for sure. I would try to tackle this into a VBS forum or contact the skin author, because as I said, I doubt it's about Rainmeter, RunCommand or the execution bang itself, otherwise it would have happened all the time for me and my basic code too (which it didn't).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Nightblade
Posts: 20
Joined: August 21st, 2012, 5:17 am

Re: Focus-stealing problem launching VBS

Post by Nightblade »

Thank you for trying to be helpful Yincognito.

The authors of the skin area unable to reproduce the problem and suggested I seek support here.

deflore08, do you have an example of something that steals focus like this?