cm_SwitchInternalAssociations

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

KozakMak
Senior Member
Senior Member
Posts: 362
Joined: 2021-05-24, 12:39 UTC
Location: UA

cm_SwitchInternalAssociations

Post by *KozakMak »

By analogy with cm_SwitchDarkmode.
When the button on toolbar is pressed they are on, when not - they are off.
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: cm_SwitchInternalAssociations

Post by *Fla$her »

Support. Although my script is enough for me:

Code: Select all

'——————————————————————— VBS ———————————————————————
' Purpose: On/off internal associations in TC
'—————————————————— Path to ТСFS2 ——————————————————
TCFS2 = """%COMMANDER_PATH%\Utils\TCFS2\TCFS2.exe"""
'——————————————————————————————— Author: Flasher © —
Set WSS = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
INI = WSS.Environment("PROCESS")("COMMANDER_INI")
Text = FSO.OpenTextFile(INI, 1,, -2).ReadAll
Find1 = InStr(Text, vbLf & "[Associations]")
Find2 = InStr(Text, vbLf & "[-Associations]")
If Find1 Then
   If Mid(Text, Find1 + 17, 16) = "RedirectSection=" Then
      Str = Split(Mid(Text, Find1 + 33, 260), vbCr)(0)
      Select Case True
         Case Str = "0" Or Str = ""
         Case Str = "1"
            Str = WSS.ExpandEnvironmentStrings(Split(Mid(Text, _
            InStr(Text, vbLf & "AlternateUserIni=") + 18, 260), vbCr)(0))
            If FSO.FileExists(Str) Then
               INI  = Str
               Text = FSO.OpenTextFile(INI, 1,, -2).ReadAll
               Find1 = InStr(Text, vbLf & "[Associations]")
               Find2 = InStr(Text, vbLf & "[-Associations]")
               If Find1 Then
                  Text = Left(Text, Find1 + 1) & "-" & Mid(Text, Find1 + 2)
               ElseIf Find2 Then
                  Text = Left(Text, Find2 + 1) & Mid(Text, Find2 + 3)
               End If
            End If
         Case Else
            Str = WSS.ExpandEnvironmentStrings(Str)
            If FSO.FileExists(Str) Then
               INI = Str
               Set Text = FSO.OpenTextFile(INI, 1,, -2)
               If Not Text.AtEndOfStream Then
                  Select Case Text.ReadLine
                     Case "[Associations]" Dash = "-"
                     Case "[-Associations]"
                     Case Else WSH.Quit
                  End Select
                  Text = "[" & Dash & "Associations]" & vbCrLf & Text.ReadAll
               Else WSH.Quit() End If
            End If
      End Select
   Else Text = Left(Text, Find1 + 1) & "-" & Mid(Text, Find1 + 2)
   End If
ElseIf Find2 Then
   Text = Left(Text, Find2 + 1) & Mid(Text, Find2 + 3)
End If
If Find1 + Find2 Then
   With FSO.OpenTextFile(INI,2,,-2) .Write Text: .Close: End With
   WSS.Run TCFS2 & " /ef msg(147,0,1302100) tcm(2958)",, 1
End If
Set WSS = Nothing: Set FSO = Nothing
Last edited by Fla$her on 2022-11-05, 04:10 UTC, edited 3 times in total.
Overquoting is evil! 👎
yanch
Junior Member
Junior Member
Posts: 30
Joined: 2015-06-06, 21:17 UTC

Re: cm_SwitchInternalAssociations

Post by *yanch »

Vote +1

2Fla$her
Is it possible to use this script with custom View Modes (Auto-run commands)?
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: cm_SwitchInternalAssociations

Post by *Fla$her »

2yanch
Create an em_ command with a path to .vbs and call it.
Overquoting is evil! 👎
yanch
Junior Member
Junior Member
Posts: 30
Joined: 2015-06-06, 21:17 UTC

Re: cm_SwitchInternalAssociations

Post by *yanch »

2Fla$her
Could you please paste "bar button" or "em_command" here? I do smth wrong and it doesn`t work.
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: cm_SwitchInternalAssociations

Post by *Fla$her »

Except the path to .vbs there is nothing there.
In the header of the script there is a path to TCFS2. Did you fix it to yours?
Overquoting is evil! 👎
yanch
Junior Member
Junior Member
Posts: 30
Joined: 2015-06-06, 21:17 UTC

Re: cm_SwitchInternalAssociations

Post by *yanch »

Sorry, there is another fail. Redirections are set in wincmd.ini file.
screen
So how to edit this script for my case?
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: cm_SwitchInternalAssociations

Post by *Fla$her »

yanch wrote: 2022-11-04, 09:55 UTCSorry, there is another fail.
What exactly is the fail?
Overquoting is evil! 👎
yanch
Junior Member
Junior Member
Posts: 30
Joined: 2015-06-06, 21:17 UTC

Re: cm_SwitchInternalAssociations

Post by *yanch »

Fla$her wrote: 2022-11-04, 10:12 UTC What exactly is the fail?
Redirections are set in my wincmd.ini. So [Associations] section is placed in separate "associations-searches.INI" file.
Look at the screenshot
screen
And the script fails to run in this situation. It works only if I move [Associations] section back to the standard place - wincmd.ini. Is it possible to modify the script in order to work within my case?
KozakMak
Senior Member
Senior Member
Posts: 362
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: cm_SwitchInternalAssociations

Post by *KozakMak »

2yanch
easier to use TCASwitcher
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: cm_SwitchInternalAssociations

Post by *Fla$her »

yanch wrote: 2022-11-04, 11:06 UTCAnd the script fails to run in this situation.
I was just asking about that.

For some reason I was sure that TC first reads the name of the section, but it turned out that it keeps information about the redirection in memory.
OK, I'll fix it a bit later.

2KozakMak
No. It's a legacy solution through confirmation in dialogue.
Overquoting is evil! 👎
KozakMak
Senior Member
Senior Member
Posts: 362
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: cm_SwitchInternalAssociations

Post by *KozakMak »

Fla$her wrote: 2022-11-04, 11:32 UTC No. It's a legacy solution through confirmation in dialogue.
...but it has colorful button to identify its on or off
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: cm_SwitchInternalAssociations

Post by *Fla$her »

Fla$her wrote: 2022-11-04, 11:32 UTCOK, I'll fix it a bit later.
Done.
KozakMak wrote: 2022-11-04, 12:47 UTC ...but it has colorful button to identify its on or off
It does this by default in Default.bar, i.e. when called from another bar, instead of updating the icon for the current toolbar, it will switch to Default.bar, where the icon will change, which is unacceptable. And even if you make an edit for em_RefreshBar manually, the icon will change only for a single bar, and not at all for the current one. In addition, when restarting TC, there is no re-reading of the value and the button may not correspond to the current status if the switch was made in another way, including manual editing of ini files.
But since it is planned to read/write files in Autorun, this problem can be solved completely (without third-party tools) already there. When such an opportunity arises, I will post the solution here.
Overquoting is evil! 👎
KozakMak
Senior Member
Senior Member
Posts: 362
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: cm_SwitchInternalAssociations

Post by *KozakMak »

Fla$her wrote: 2022-11-04, 19:50 UTC I will post the solution here.
wow :shock:
I'll be waiting!
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: cm_SwitchInternalAssociations

Post by *Fla$her »

Fla$her wrote: 2022-11-04, 19:50 UTCwithout third-party tools
A little hasty. This will solve the icon problem after restarting, but not when the button is pressed. To click, we'll need TCFS2.
Overquoting is evil! 👎
Post Reply