cm_SwitchInternalAssociations
Moderators: Hacker, petermad, Stefan2, white
cm_SwitchInternalAssociations
By analogy with cm_SwitchDarkmode.
When the button on toolbar is pressed they are on, when not - they are off.
When the button on toolbar is pressed they are on, when not - they are off.
OS: Win10 | TC: latest x64
Re: cm_SwitchInternalAssociations
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! 👎
Re: cm_SwitchInternalAssociations
Vote +1
2Fla$her
Is it possible to use this script with custom View Modes (Auto-run commands)?
2Fla$her
Is it possible to use this script with custom View Modes (Auto-run commands)?
Re: cm_SwitchInternalAssociations
2yanch
Create an em_ command with a path to .vbs and call it.
Create an em_ command with a path to .vbs and call it.
Overquoting is evil! 👎
Re: cm_SwitchInternalAssociations
2Fla$her
Could you please paste "bar button" or "em_command" here? I do smth wrong and it doesn`t work.
Could you please paste "bar button" or "em_command" here? I do smth wrong and it doesn`t work.
Re: cm_SwitchInternalAssociations
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?
In the header of the script there is a path to TCFS2. Did you fix it to yours?
Overquoting is evil! 👎
Re: cm_SwitchInternalAssociations
Sorry, there is another fail. Redirections are set in wincmd.ini file.
So how to edit this script for my case?
Re: cm_SwitchInternalAssociations
Redirections are set in my wincmd.ini. So [Associations] section is placed in separate "associations-searches.INI" file.
Look at the screenshot 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?
Re: cm_SwitchInternalAssociations
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! 👎
Re: cm_SwitchInternalAssociations
...but it has colorful button to identify its on or off
OS: Win10 | TC: latest x64
Re: cm_SwitchInternalAssociations
Done.
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! 👎
Re: cm_SwitchInternalAssociations
OS: Win10 | TC: latest x64
Re: cm_SwitchInternalAssociations
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! 👎