It is currently November 30th, 2022, 6:24 pm

Focus stealing without clicking the skin

Get help with creating, editing & fixing problems with skins
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Focus stealing without clicking the skin

Post by CoffeeJoe »

I know there are functions in Rainmeter intended to prevent skins from stealing the focus or having the focus stolen...
I have a skin that has the Action "OnUnFocusAction=[!DeActivateConfig "My path" "My Config"] Works fine if the skin has focus to start with.

If the Skin never had nor ever gets focus it just sits there.
I have an example of the issue, its basic, just annoying I can't find a solution directly.

The skin opens a shape with a single link, clicking to open the link opens the menu skin...
If you click the skin (ie choose any option) it will close when that option opens or you click away from the skin.
If you never click the option panel ... it sits there waiting...
I want the skin to get focus first without being clicked... when the other skin activates it ... and vanish if it loses focus
Staging.png
This is just a mock up to show the issue so the links on the menu panel don't do anything, thats not the problem.
You do not have the required permissions to view the files attached to this post.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4881
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Focus stealing without clicking the skin

Post by eclectic-tech »

RainFocus should help you do what you want...
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Focus stealing without clicking the skin

Post by CoffeeJoe »

Looks like just the thing - thanks I'll give it a go
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Focus stealing without clicking the skin

Post by CoffeeJoe »

That is a good workaround and it works perfectly as advertised... but it still is only a workaround. is there a native way, within Rainmeter or with LUA that can accomplish this? is there someone who is capable of making a plugin version of this Autoit Script?
This feels Kludgy and presents issues with the AutoIt script playing nice with Security Software - Sophos automatically deletes all AutoIt exes on my machine - no sooner the compiler finishes, its gone, whisked away and deleted outright. per the logs, it's a potentially dangerous piece of software.

Code: Select all

LeftMouseUpAction=[!ActivateConfig "Staging\Menu" "Menu.ini"][#@#Addons\RainFocus\RainFocus.exe "Staging\Menu"]
Any other thoughts on the focus problem? I won't get bogged down in the AutoIt issue other than to avoid using it where i can...
User avatar
jsmorley
Developer
Posts: 22551
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Focus stealing without clicking the skin

Post by jsmorley »

Check this:

https://forum.rainmeter.net/viewtopic.php?f=23&t=15564&p=170843&hilit=focus#p170843

Uses compiled AutoHotKey, which your virus app may like better.
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Focus stealing without clicking the skin

Post by CoffeeJoe »

Thanks
User avatar
Yincognito
Rainmeter Sage
Posts: 4817
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Focus stealing without clicking the skin

Post by Yincognito »

CoffeeJoe wrote: February 24th, 2020, 5:57 am That is a good workaround and it works perfectly as advertised... but it still is only a workaround. is there a native way, within Rainmeter or with LUA that can accomplish this? is there someone who is capable of making a plugin version of this Autoit Script?
This feels Kludgy and presents issues with the AutoIt script playing nice with Security Software - Sophos automatically deletes all AutoIt exes on my machine - no sooner the compiler finishes, its gone, whisked away and deleted outright. per the logs, it's a potentially dangerous piece of software.

Code: Select all

LeftMouseUpAction=[!ActivateConfig "Staging\Menu" "Menu.ini"][#@#Addons\RainFocus\RainFocus.exe "Staging\Menu"]
Any other thoughts on the focus problem? I won't get bogged down in the AutoIt issue other than to avoid using it where i can...
Both eclectic-tech and jsmorley already provided excellent solutions, so the matter is pretty much settled. I'll add mine here as well, so you can have plenty of options to choose from. ;-)

If you don't particularly want the "menu skin" (named Menu.ini below) to open on mouse click and you're ok with it opening on mouse hover instead, then my custom tooltip skin that I built here can be easily adapted to suit your needs, just by removing or commenting the MouseLeaveAction=[!SetVariable TooltipStatus 0][!DeactivateConfig "#ROOTCONFIG#\Tooltip"] line in Skin.ini and "moving" it into [Rainmeter] section of the "submenu skin" (named Submenu.ini below) accordingly:

Menu.ini

Code: Select all

[Variables]
SubmenuStatus=0

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

---Measures Submenu---

[MS_Rainmeter_PopulateSubmenu]
Measure=Calc
IfCondition=(#SubmenuStatus#=1)
IfTrueAction=[!SetOption MT_Rainmeter_SubmenuItem1 Text "Submenu Item 1.1" "#ROOTCONFIG#\Submenu"][!SetOption MT_Rainmeter_SubmenuItem2 Text "Submenu Item 1.2" "#ROOTCONFIG#\Submenu"][!SetOption MT_Rainmeter_SubmenuItem3 Text "Submenu Item 1.3" "#ROOTCONFIG#\Submenu"][!UpdateMeterGroup SubmenuGroup "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentX Formula #CURRENTCONFIGX# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentY Formula #CURRENTCONFIGY# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentWidth Formula #CURRENTCONFIGWIDTH# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentHeight Formula #CURRENTCONFIGHEIGHT# "#ROOTCONFIG#\Submenu"][!UpdateMeasureGroup SubmenuGroup "#ROOTCONFIG#\Submenu"][!Redraw "#ROOTCONFIG#\Submenu"]
IfCondition2=(#SubmenuStatus#=2)
IfTrueAction2=[!SetOption MT_Rainmeter_SubmenuItem1 Text "Submenu Item 2.1" "#ROOTCONFIG#\Submenu"][!SetOption MT_Rainmeter_SubmenuItem2 Hidden "1" "#ROOTCONFIG#\Submenu"][!SetOption MT_Rainmeter_SubmenuItem3 Hidden "1" "#ROOTCONFIG#\Submenu"][!UpdateMeterGroup SubmenuGroup "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentX Formula #CURRENTCONFIGX# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentY Formula #CURRENTCONFIGY# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentWidth Formula #CURRENTCONFIGWIDTH# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentHeight Formula #CURRENTCONFIGHEIGHT# "#ROOTCONFIG#\Submenu"][!UpdateMeasureGroup SubmenuGroup "#ROOTCONFIG#\Submenu"][!Redraw "#ROOTCONFIG#\Submenu"]
IfCondition3=(#SubmenuStatus#=3)
IfTrueAction3=[!SetOption MT_Rainmeter_SubmenuItem1 Text "Submenu Item 3.1" "#ROOTCONFIG#\Submenu"][!SetOption MT_Rainmeter_SubmenuItem2 Text "Submenu Item 3.2" "#ROOTCONFIG#\Submenu"][!SetOption MT_Rainmeter_SubmenuItem3 Hidden "1" "#ROOTCONFIG#\Submenu"][!UpdateMeterGroup SubmenuGroup "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentX Formula #CURRENTCONFIGX# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentY Formula #CURRENTCONFIGY# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentWidth Formula #CURRENTCONFIGWIDTH# "#ROOTCONFIG#\Submenu"][!SetOption MS_Rainmeter_ParentHeight Formula #CURRENTCONFIGHEIGHT# "#ROOTCONFIG#\Submenu"][!UpdateMeasureGroup SubmenuGroup "#ROOTCONFIG#\Submenu"][!Redraw "#ROOTCONFIG#\Submenu"]
IfConditionMode=1
DynamicVariables=1

---Styles---

[ElementStyle]
W=100
H=60
FontColor=FFFFFFFF
FontSize=18
FontWeight=500
SolidColor=00000001
Padding=1,1,1,1
InlineSetting=Shadow | 1 | 1 | 1 | 000000FF
StringAlign=LeftCenter
AntiAlias=1

---Meters---

[MeterBase]
Meter=Shape
Shape=Rectangle 0,0,175,180,10 | Fill Color FF6000 | StrokeWidth 0

[MT_Rainmeter_MenuItem1]
Meter=String
MeterStyle=ElementStyle
X=20
Y=20
Text="Menu Item 1"
MouseOverAction=[!DeactivateConfig "#ROOTCONFIG#\Submenu"][!SetVariable SubmenuStatus 1][!WriteKeyValue "#ROOTCONFIG#\Submenu" StartHidden 1 "#SETTINGSPATH#Rainmeter.ini"][!ActivateConfig "#ROOTCONFIG#\Submenu"][!ZPos "2" "#ROOTCONFIG#\Submenu"][!UpdateMeasure "MS_Rainmeter_PopulateSubmenu"]
DynamicVariables=1

[MT_Rainmeter_MenuItem2]
Meter=String
MeterStyle=ElementStyle
X=0r
Y=5R
Text="Menu Item 2"
MouseOverAction=[!DeactivateConfig "#ROOTCONFIG#\Submenu"][!SetVariable SubmenuStatus 2][!WriteKeyValue "#ROOTCONFIG#\Submenu" StartHidden 1 "#SETTINGSPATH#Rainmeter.ini"][!ActivateConfig "#ROOTCONFIG#\Submenu"][!ZPos "2" "#ROOTCONFIG#\Submenu"][!UpdateMeasure "MS_Rainmeter_PopulateSubmenu"]
DynamicVariables=1

[MT_Rainmeter_MenuItem3]
Meter=String
MeterStyle=ElementStyle
X=0r
Y=5R
Text="Menu Item 3"
MouseOverAction=[!DeactivateConfig "#ROOTCONFIG#\Submenu"][!SetVariable SubmenuStatus 3][!WriteKeyValue "#ROOTCONFIG#\Submenu" StartHidden 1 "#SETTINGSPATH#Rainmeter.ini"][!ActivateConfig "#ROOTCONFIG#\Submenu"][!ZPos "2" "#ROOTCONFIG#\Submenu"][!UpdateMeasure "MS_Rainmeter_PopulateSubmenu"]
DynamicVariables=1
Submenu.ini

Code: Select all

[Variables]
SubmenuWasHovered=0
SecondsToDeactivate=3
MouseCursorSize=24

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
MouseOverAction=[!SetVariable SubmenuWasHovered 1]
MouseLeaveAction=[!DeactivateConfig]

---Measures Rainmeter---

[MS_Rainmeter_Counter]
Measure=Calc
Formula=(MS_Rainmeter_Counter+1)
UpdateDivider=1
IfCondition=(MS_Rainmeter_Counter>#SecondsToDeactivate#) && (#SubmenuWasHovered#=0)
IfTrueAction=[!DeactivateConfig]
IfConditionMode=1
DynamicVariables=1

[MS_Rainmeter_ParentX]
Group=SubmenuGroup
Measure=Calc
Formula=0
UpdateDivider=-1
DynamicVariables=1

[MS_Rainmeter_ParentY]
Group=SubmenuGroup
Measure=Calc
Formula=0
UpdateDivider=-1
DynamicVariables=1

[MS_Rainmeter_ParentWidth]
Group=SubmenuGroup
Measure=Calc
Formula=0
UpdateDivider=-1
DynamicVariables=1

[MS_Rainmeter_ParentHeight]
Group=SubmenuGroup
Measure=Calc
Formula=0
UpdateDivider=-1
DynamicVariables=1

[MS_Rainmeter_MoveSubmenu]
Group=SubmenuGroup
Measure=Calc
UpdateDivider=-1
IfCondition=(#CURRENTCONFIGWIDTH#>10)
IfTrueAction=[!Move "((([MS_Rainmeter_ParentX]+#CURRENTCONFIGWIDTH#)>(#WORKAREAX#+#WORKAREAWIDTH#))?([MS_Rainmeter_ParentX]-(#CURRENTCONFIGWIDTH#-[MS_Rainmeter_ParentWidth])):([MS_Rainmeter_ParentX]))" "((([MS_Rainmeter_ParentY]+[MS_Rainmeter_ParentHeight]+#MouseCursorSize#+#CURRENTCONFIGHEIGHT#)>(#WORKAREAY#+#WORKAREAHEIGHT#))?([MS_Rainmeter_ParentY]-#MouseCursorSize#-#CURRENTCONFIGHEIGHT#):([MS_Rainmeter_ParentY]+[MS_Rainmeter_ParentHeight]+#MouseCursorSize#))"][!Delay 24][!Show]
IfConditionMode=1
DynamicVariables=1

---Styles---

[ElementStyle]
W=300
H=20
FontColor=C0C0C0FF
FontSize=18
FontWeight=500
SolidColor=00000001
Padding=1,1,1,1
InlineSetting=Shadow | 1 | 1 | 1 | 000000FF
StringAlign=LeftCenter
Container=MeterCont
AntiAlias=1

---Meters---

[MeterBG]
Meter=Shape
Shape=Rectangle 0,0,320,120,20 | Fill Color 000000A0 | StrokeWidth 0

[MeterCont]
Meter=Shape
Shape=Rectangle 0,0,320,120,20 | Fill Color FFFFFF | StrokeWidth 0

[MT_Rainmeter_SubmenuItem1]
Group=SubmenuGroup
Meter=STRING
MeterStyle=ElementStyle
X=20r
Y=30r
Text=
UpdateDivider=-1

[MT_Rainmeter_SubmenuItem2]
Group=SubmenuGroup
Meter=STRING
MeterStyle=ElementStyle
X=r
Y=10R
Text=
UpdateDivider=-1

[MT_Rainmeter_SubmenuItem3]
Group=SubmenuGroup
Meter=STRING
MeterStyle=ElementStyle
X=r
Y=10R
Text=
UpdateDivider=-1
Preview
ezgif.com-optimize.gif
You do not have the required permissions to view the files attached to this post.