It is currently May 6th, 2024, 1:56 pm

Text editor skin?

Get help with creating, editing & fixing problems with skins
User avatar
Active Colors
Moderator
Posts: 1255
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Text editor skin?

Post by Active Colors »

Yincognito wrote: March 17th, 2022, 11:14 am Well, since it's the only one that's left, the one with copy pasting duplicating lines - number 1) here.
Gotcha.
Yincognito wrote: March 17th, 2022, 11:14 am Also, care to share how you managed to make InputText use the previously saved content after pressing ENTER?
And yes, I know the text remains selected - I did a bunch of tests the other day on this whole thing. My idea is to take things one at a time: first, using the previously saved content after pressing enter (which it seems that you succeeded in doing), and only then bother with the need for a DOWN key or CLICK to unselect text. In other words, I saw the first issue the most difficult. Now if you share your method, maybe we'll find a solution to the selection as well... :D
Gotcha. Add/change these:

Code: Select all

[Rainmeter]
OnRefreshAction=[!CommandMeasure TextInput "ExecuteBatch All"]

[TextInput]
DefaultValue=[#DefaultText][\13][\10]
Command2=[!UpdateMeasure *][!UpdateMeter *][!Refresh]
User avatar
Yincognito
Rainmeter Sage
Posts: 7206
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Text editor skin?

Post by Yincognito »

Active Colors wrote: March 17th, 2022, 11:43 am

Code: Select all

[Rainmeter]
OnRefreshAction=[!CommandMeasure TextInput "ExecuteBatch All"]

[TextInput]
DefaultValue=[#DefaultText][\13][\10]
Command2=[!UpdateMeasure *][!UpdateMeter *][!Refresh]
Oh, I see - thanks. I was thinking of a way that doesn't involve refreshing the skin though, something like an infinite cycle in either the InputText measure commands, e.g. last command executes the first or something similar (doesn't seem to work, unfortunately) or using another initially disabled measure that is enabled and updated to command the InputText measure to execute its batch commands again (doesn't seem to work either). Hmm... I don't know what to do now, use your method and see if a solution to unselect the text can be found, or keep trying to produce an infinite cycle of InputText batch commands without refreshing the skin and bother with the unselecting later. Looks like a cigar is needed for new ideas... :???: The latter looks like trying to make fusion power for civilian purposes work, LMAO.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7206
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Text editor skin?

Post by Yincognito »

Active Colors wrote: March 17th, 2022, 11:43 amGotcha. Add/change these:

Code: Select all

[Rainmeter]
OnRefreshAction=[!CommandMeasure TextInput "ExecuteBatch All"]

[TextInput]
DefaultValue=[#DefaultText][\13][\10]
Command2=[!UpdateMeasure *][!UpdateMeter *][!Refresh]
Ok, combining my previous InputBox skin and this one, I found a relatively reasonable way of endlessly commanding the input text measure to run its batch AND a way to stop it from happening and revert to the normal behavior where ENTER will commit changes in the edit box, all this within the same skin loading cycle, aka no refresh needed. I say relatively reasonable because it involves estimating how much time will the batch operations take (below, this is set to 200 ms, but it's adjustable from [Variables]), so that the Hotkey plugin events, which normally happen before the InputText plugin ones, get the chance to happen after the latter. I initially added the State variable just to have a way of logging whether the "return mode" or the "commit mode" was active when pressing ENTER, but in the end it proved useful to correct adding the ENTER sequence at all times in this scenario, so now it will add it only when the "return mode" is active. I used TAB to toggle between these 2 modes, since it doesn't seem to do anything at all when editing in the input text box. The code is as follows:

Code: Select all

[Variables]
Suffix0=
; Empty suffix for an original UserInput
Suffix1=[*\13*][*\10*]
; ENTER suffix for a returning UserInput
State=0
; State = 0 if commits, State = 1 if returns
Delay=200
; Delay to run HotKey after the InputText things
DefaultText="Hello There![\13][\10]How Are You?"
; ENTER for a new line, TAB then ENTER to commit

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
SkinWidth=600
SkinHeight=600

---Measures---

[InitInputs]
Measure=Calc
IfCondition=1
IfTrueAction=[!SetOptionGroup InputTextGroup FontFace "Consolas"][!SetOptionGroup InputTextGroup SolidColor "0,0,0,255"][!SetOptionGroup InputTextGroup FontColor "255,255,255,255"][!SetOptionGroup InputTextGroup FontSize 16][!SetOptionGroup InputTextGroup AntiAlias 1][!SetOptionGroup InputTextGroup ClipString 1]
UpdateDivider=-1
DynamicVariables=1

[TextInput]
Group=InputTextGroup
Measure=Plugin
Plugin=InputText
X=[Text:X]
Y=[Text:Y]
W=[Text:W]
H=[Text:H]
DefaultValue="#DefaultText#"
UpdateDivider=-1
Command1=[!SetVariable DefaultText """$UserInput$[#Suffix[#State]]"""][!WriteKeyValue Variables DefaultText """"[#CURRENTSECTION#]""""]
Command2=[!UpdateMeasure #CURRENTSECTION#][!UpdateMeter Text][!Redraw]
OnDismissAction=[!SetVariable State (1-#State#)][!CommandMeasure ENTER Toggle][!Log "ENTER commits = #State#"]
RegExpSubstitute=1
Substitute="\r\n":"#Suffix1#"
DynamicVariables=1

[ENTER]
Measure=Plugin
Plugin=HotKey
HotKey=#CURRENTSECTION#
KeyDownAction=[!Delay #Delay#][!CommandMeasure TextInput "ExecuteBatch All"][!Log "ENTER returns = #State#"]
DynamicVariables=1

[TAB]
Measure=Plugin
Plugin=HotKey
HotKey=#CURRENTSECTION#
KeyDownAction=[!SetVariable State (1-#State#)][!CommandMeasure ENTER Toggle][!Log "ENTER commits = #State#"]
DynamicVariables=1

---Meters---

[Text]
Meter=String
X=10
Y=10
W=580
H=580
SolidColor=0,0,0,255
FontFace=Consolas
FontColor=255,255,255,255
FontSize=16
AntiAlias=1
ClipString=1
Text="#DefaultText#"
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable State 1][!CommandMeasure ENTER Start][!CommandMeasure TextInput "ExecuteBatch All"]
DynamicVariables=1
There is a small bug where dismissing the input text will keep all but the last change to the content, due to the system used, but I let it there since there might be times when ones wants this to happen. For now, the unselecting is more or less the last issue standing, though it could probably be easily corrected if the devs would accept and be able to add an additional option to the measure that controls whether the text is selected or not when the input text is clicked for editing. Of course, they could have added the possiblity to use ENTER as the newline if they wanted or were able to by now, but that's nother matter.

Anyway, I'm sure the unselecting can be done as well through a "hack" of some sort, but for now I'll temporarily put this to pause for some relax - I'll probably take a look at it later on, after I deal with the little bug mentioned earlier. Apparently things work out anyway, one way or another, irrespective if there is someone to tell you whether it can be done or not.

P.S. In an usage scenario, I'd probably use the normal CTRL+ENTER newline, since although inconvenient to the hand, is convenient when it comes to code and its simplicity. But you know, I can't resist challenges, man must beat the machine... :D
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Active Colors
Moderator
Posts: 1255
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Text editor skin?

Post by Active Colors »

Yincognito wrote: March 17th, 2022, 11:55 am something like an infinite cycle in either the InputText measure commands, e.g. last command executes the first or something similar (doesn't seem to work, unfortunately)
Yeah that's what I tried first and it didn't work for me either.

I think you can include two similar InputText measures which would execute each other :D

Code: Select all

[TextInput1]
Command3=[!CommandMeasure TextInput2 "ExecuteBatch All"]

[TextInput2]
Command3=[!CommandMeasure TextInput1 "ExecuteBatch All"]
User avatar
Yincognito
Rainmeter Sage
Posts: 7206
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Text editor skin?

Post by Yincognito »

Active Colors wrote: March 17th, 2022, 3:31 pm Yeah that's what I tried first and it didn't work for me either.

I think you can include two similar InputText measures which would execute each other :D

Code: Select all

[TextInput1]
Command3=[!CommandMeasure TextInput2 "ExecuteBatch All"]

[TextInput2]
Command3=[!CommandMeasure TextInput1 "ExecuteBatch All"]
Well ... it works! :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7206
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Text editor skin?

Post by Yincognito »

Active Colors wrote: March 17th, 2022, 10:51 am GIF 17-03-2022 11-52-40.gif
Which one are you referring to?
Ok, so I tried using WindowsMessagePlugin to simulate an arrow down key press in the input text window / control (which is actually a Windows input box) in order to unselect the content after pressing ENTER, but while I've been able to find the window name, class, even the control name which is not used as an option in the said plugin, I didn't find the right window message and wparam or lparam, so I'm currently stuck. I'm sure this is possible, but I wouldn't want to use an ahk/exe for it, if it can work via windows messages. I post it here for reference, the thing to do is to correctly set up the !CommandMeasure in the [ENTER] HotKey measure:

Code: Select all

[Variables]
Suffix0=
; Empty suffix for an original UserInput
Suffix1=[*\13*][*\10*]
; ENTER suffix for a returning UserInput
State=0
; State = 0 if commits, State = 1 if returns
Delay=200
; Delay to run HotKey after the InputText things
DefaultText="Hello There![\13][\10]How Are You?"
; ENTER for a new line, TAB then ENTER to commit

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
SkinWidth=600
SkinHeight=600

---Measures---

[InitInputs]
Measure=Calc
IfCondition=1
IfTrueAction=[!SetOptionGroup InputTextGroup FontFace "Consolas"][!SetOptionGroup InputTextGroup SolidColor "0,0,0,255"][!SetOptionGroup InputTextGroup FontColor "255,255,255,255"][!SetOptionGroup InputTextGroup FontSize 16][!SetOptionGroup InputTextGroup AntiAlias 1][!SetOptionGroup InputTextGroup ClipString 1]
UpdateDivider=-1
DynamicVariables=1

[TextInput]
Group=InputTextGroup
Measure=Plugin
Plugin=InputText
X=[Text:X]
Y=[Text:Y]
W=[Text:W]
H=[Text:H]
DefaultValue="#DefaultText#"
UpdateDivider=-1
Command1=[!SetVariable DefaultText """$UserInput$[#Suffix[#State]]"""][!WriteKeyValue Variables DefaultText """"[#CURRENTSECTION#]""""]
Command2=[!UpdateMeasure #CURRENTSECTION#][!UpdateMeter Text][!Redraw]
OnDismissAction=[!SetVariable State (1-#State#)][!CommandMeasure ENTER Toggle][!Log "ENTER commits = #State#"]
RegExpSubstitute=1
Substitute="\r\n":"#Suffix1#"
DynamicVariables=1

[ENTER]
Measure=Plugin
Plugin=HotKey
HotKey=#CURRENTSECTION#
KeyDownAction=[!Delay #Delay#][!CommandMeasure TextInput "ExecuteBatch All"][!Log "ENTER returns = #State#"][!Delay 2000][!CommandMeasure Unselect "SendMessage 514 0 40"]
;[!CommandMeasure Unselect "SendMessage 0x202 0 0"]
;[!CommandMeasure Unselect "SendMessage WM_KEYDOWN 0 40"]
;[!CommandMeasure Unselect "SendMessage 514 0 40"]
DynamicVariables=1

[TAB]
Measure=Plugin
Plugin=HotKey
HotKey=#CURRENTSECTION#
KeyDownAction=[!SetVariable State (1-#State#)][!CommandMeasure ENTER Toggle][!Log "ENTER commits = #State#"]
DynamicVariables=1

[Unselect]
Measure=Plugin
Plugin=WindowMessagePlugin
WindowName=InputBox
;Control=WindowsForms10.EDIT.app.0.fd24ec_r42_ad11
;WindowClass=WindowsForms10.Window.8.app.0.fd24ec_r42_ad1
;WindowMessage=0x202

---Meters---

[Text]
Meter=String
X=10
Y=10
W=580
H=580
SolidColor=0,0,0,255
FontFace=Consolas
FontColor=255,255,255,255
FontSize=16
AntiAlias=1
ClipString=1
Text="#DefaultText#"
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable State 1][!CommandMeasure ENTER Start][!CommandMeasure TextInput "ExecuteBatch All"]
DynamicVariables=1
How I found out the window / class name, via Pullover Macro Creator:
WinMessage.jpg
I tried different tools to find out those MSG WPARAM LPARAM values, but either I'm not yet good at that or the issue is complicated by the fact that the input text window exists only after triggering it via $UserInput$ in its batch commands, and since the input text is in edit mode then, it's difficult to use these "window spy" programs to find out the messages properties at that time since it cancels the measure's edit mode due to dismissing / unfocusing. If you or anyone else finds what's needed here, let me know.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7206
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Text editor skin?

Post by Yincognito »

I kept trying with WindowsMessagePlugin and I'm getting "some" results, but they dismiss the input text as well:

Code: Select all

[Variables]
Suffix0=
; Empty suffix for an original UserInput
Suffix1=[*\13*][*\10*]
; ENTER suffix for a returning UserInput
State=0
; State = 0 if commits, State = 1 if returns
Delay=200
; Delay to run HotKey after the InputText things
DefaultText="Hello There![\13][\10]How Are You?"
; ENTER for a new line, TAB then ENTER to commit

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
SkinWidth=600
SkinHeight=600

---Measures---

[InitInputs]
Measure=Calc
IfCondition=1
IfTrueAction=[!SetOptionGroup InputTextGroup FontFace "Consolas"][!SetOptionGroup InputTextGroup SolidColor "0,0,0,255"][!SetOptionGroup InputTextGroup FontColor "255,255,255,255"][!SetOptionGroup InputTextGroup FontSize 16][!SetOptionGroup InputTextGroup AntiAlias 1][!SetOptionGroup InputTextGroup ClipString 1]
UpdateDivider=-1
DynamicVariables=1

[TextInput]
Group=InputTextGroup
Measure=Plugin
Plugin=InputText
X=[Text:X]
Y=[Text:Y]
W=[Text:W]
H=[Text:H]
DefaultValue="#DefaultText#"
UpdateDivider=-1
Command1=[!SetVariable DefaultText """$UserInput$[#Suffix[#State]]"""]
;[!WriteKeyValue Variables DefaultText """"[#CURRENTSECTION#]""""]
Command2=[!UpdateMeasure #CURRENTSECTION#][!UpdateMeter Text][!Redraw]
OnDismissAction=[!SetVariable State (1-#State#)][!CommandMeasure ENTER Toggle][!Log "ENTER commits = #State#"]
RegExpSubstitute=1
Substitute="\r\n":"#Suffix1#"
DynamicVariables=1

[ENTER]
Measure=Plugin
Plugin=HotKey
HotKey=#CURRENTSECTION#
KeyDownAction=[!Delay #Delay#][!CommandMeasure TextInput "ExecuteBatch All"][!Log "ENTER returns = #State#"][!Delay 1000][!CommandMeasure Unselect "SendMessage 256 40 3243245569"][!CommandMeasure Unselect "SendMessage 257 40 3243245569"]
DynamicVariables=1

[TAB]
Measure=Plugin
Plugin=HotKey
HotKey=#CURRENTSECTION#
KeyDownAction=[!SetVariable State (1-#State#)][!CommandMeasure ENTER Toggle][!Log "ENTER commits = #State#"]
DynamicVariables=1

[Unselect]
Measure=Plugin
Plugin=WindowMessagePlugin
WindowName=InputBox

---Meters---

[Text]
Meter=String
X=10
Y=10
W=580
H=580
SolidColor=0,0,0,255
FontFace=Consolas
FontColor=255,255,255,255
FontSize=16
AntiAlias=1
ClipString=1
Text="#DefaultText#"
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable State 1][!CommandMeasure ENTER Start][!CommandMeasure TextInput "ExecuteBatch All"]
DynamicVariables=1
The [!Delay 1000][!CommandMeasure Unselect "SendMessage 256 40 3243245569"][!CommandMeasure Unselect "SendMessage 257 40 3243245569"] part is sending a WM_KEYDOWN followed by a WMKEYUP message of VK_DOWN (aka down arrow) to the input text window, defined as the one having the title InputBox as per Pullover Macro Creator's window indentification, and confirmed by the Rainmeter log for the measure, which displays the window name while the InputText is in edit mode. The 256 and 257 values appear to be the Message values for WM_KEYDOWN and WMKEYUP, according to the AutoHotKey help. In agreement with what Microsoft says, the Microsoft Spy++ provided the wParam and lParam values for VK_DOWN when monitoring window messages after clicking the Log button, as hexadecimal 28 and C1500001, respectively, which translate to the decimal 40 and 3243245569 above.

Bottom line, while I got an effect, it wasn't exactly the desired one. It's possible that sending messages to deactivate previous window and activate the current one might be needed in order for the keystrokes to have the said effect. Or, there might be a window message that simply selects or unselects all, instead. In any case, this is for sure doable, just not 100% sure what messages should be sent to the window.

EDIT: For the record, using [!Delay 1000][!CommandMeasure Unselect "SendMessage 516 0 38142535"][!CommandMeasure Unselect "SendMessage 517 0 38142535"] in the [ENTER] measure and WindowName=#CURRENTPATH##CURRENTFILE# in the [Unselect] one successfully sends a right click action to the skin window, triggering the Rainmeter context menu at that position, so the process works in this case.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth