Example for TCScript Editor

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

User avatar
franck8244
Power Member
Power Member
Posts: 704
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

i need to focus onto tc or some cases the last opend lister...
To focus on TC is feasible but not on the lister window ...
i would like to define some hotkeys in the querry...
If you have differente 1st letter, simply press them otherwise it can not be done...
SendVKey(67,2); //'c'
StrCopy(str,"d ");
use StrCopy(str,"cd ") instead :wink:
SendVKey(VK_LCONTROL,1);
SendVKey(86,2);
SendVKey(VK_LCONTROL,2);
SendVKey : 0=key pressed, 1: key released, 2, key pressed the released...modify it a bit, it will work better...

You can also create a script to select files only with some criteria and then move them ( it's easy :) )...
TC#88260 -
heron
Junior Member
Junior Member
Posts: 8
Joined: 2004-01-24, 22:29 UTC

Post by *heron »

use StrCopy(str,"cd ") instead
tryed it this way, didn't work... one character-key-hit ist needed to focus onto the commandline (nay better ideas fir that?)
SendVKey : 0=key pressed, 1: key released, 2, key pressed the released...modify it a bit, it will work better...
thx i looked for this in the docs ...
You can also create a script to select files only with some criteria and then move them ( it's easy Smile )
jepp like in "\skripts\Select Filter.tcs"...

there is nothing like some while -loop thing around :( this way the hotkeys could be done way easier... well guess i have do some Exec(TCSkript ... again)...
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

I have a problem: I use the following script to change my menu file:

Code: Select all

#include "Scripts\VKeys.h"
#define VK_P 80

PostCmd(cm_LanguageConfig);
SendVKey(VK_TAB, 2);
//SendVKey(VK_SPACE, 2);
SendText("Stefan deutsch");
SendVKey(VK_RETURN,2); 
I works very well. But if I have opened 2 (or more) instances of TC it happens, that the cm_languageConfig is executed in the active TC instance but all of the other commands are executed in the last opened instance.

Is there a way to prevent this?

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Sending one TAB is not enough. Use this code:

Code: Select all

#include "Scripts\VKeys.h" 
#define VK_P 80 

PostCmd(cm_LanguageConfig); 
SendVKey(VK_TAB, 2); 
SendVKey(VK_TAB, 2); 
//SendVKey(VK_SPACE, 2); 
SendText("Stefan deutsch"); 
SendVKey(VK_RETURN,2);
Edit: Ah, that's not the problem cause obviously. I can confirm the bug. You can do the same with AutoHotkey if that is an option for you.

Icfu
This account is for sale
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

Thanks for your try, but this doesn't work. Moreover this doesn't even work when I start the command in the 'right' TC instance.

As I wrote above: The script works very well. But if there are more than one instances of TC and I do not execute it on the last opened the language Config Dialog is opened on the active TC. But then the last opened TC instance gets the focus and all 'keystrokes' are executed on this TC instance.


sheepdog

[edit]
I think I should give Autohotkey a try ;)
[/edit]
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Curious, the two TABs are definetely needed here because after calling the dialog the focus is in the left command list. First TAB activates the language box, second TAB activates the path box.

Here is the AutoHotkey script:

Code: Select all

~^!M::
IfWinActive, ahk_class TTOTAL_CMD
{
  PostMessage, 1075, 499
  Send, {TAB}{TAB}
  SendRaw, Stefan deutsch
  Send, {ENTER}
}
Return
This would change the menu file on pressing Ctrl+Alt+M. If you need another combination just tell me or look here:
http://www.autohotkey.com/docs/Hotkeys.htm

You can also use this one, it's more reliable because it waits till the language configuration appears and it directly accesses the control without the need to navigate with TABs:

Code: Select all

~^!M::
IfWinActive, ahk_class TTOTAL_CMD
{
  PostMessage, 1075, 499
  WinWaitActive, ahk_class TDLGCONFIGALL
  ControlSetText, TEdit1, Stefan deutsch
  Send, {ENTER}
}
Return
Icfu
This account is for sale
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

Okay, that's my fault.

For my own menu I always create a language file corresponding to the menu-name e.g.: Wcmd_deu_step.lng Wcmd_deu_step.mnu
Then I put in the first line of the Language file a appropriate description 'Stefan deutsch'. This first line is displayed in the language list
Stefan deutsch (Wcmd_deu_step.lng).

When you select this language file automatically the menu with corresponding name is selceted, too.

Thus I do only need one TAB.

I edited your script like this and get a strange behavior.

The Hotkey works, but just only each second time. First time the focus switches to another program, but no menu is changed.

sheepdog

edit

And each time I use it one of the tasks isn't visible anymore if I press [alt]+[Tab]. But I see them in the taskmanager as well as in the "Taskleiste" whatever this is called in english.

/edit
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Use the alternative script please. If you have changed something in the script please post it so I can check what's wrong.

Icfu
This account is for sale
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

The alternative script doesn't work either.

Code: Select all

~^!M::
PostMessage, 1075, 499, , , ahk_class TTOTAL_CMD
Send, {TAB}
SendRaw, Stefan deutsch
Send, {ENTER}
Return
That is the script I altered.

What does the "1075" mean in PostMessage (499 is cm_LanguageConfig I understand)

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

It seems that my system does not like the [alt]+[ctrl]+[m].

When I change the M to N in the script it works very well. Strange. Maybe because of the german keyboard layout? There is [alt]+[ctrl]+[m]="µ".

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

I have that µ on my keyboard, too, but I can't create it pressing Ctrl-Alt-M, German keyboard layout, too.

Well, what happens when you press Ctrl-Alt-M now after you changed the hotkey, is the µ painted or is still something strange happening?

Are you running some other application that has hijacked the Ctrl-Alt-M shortcut? It sounds a little bit strange that some other task is activated when pressing the hotkey, maybe you are running TaskSwitchXP and you have set that hotkey there?

The 1075 is a message that has to be sent to Total Commander to make it react on commands, nothing you should worry about, it just has to be there. ;)

Icfu
This account is for sale
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3377
Joined: 2003-05-06, 11:46 UTC

Post by *Sir_SiLvA »

I also get that µ by pressing ctrl+alt+m
Hoecker sie sind raus!
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

icfu wrote:I have that µ on my keyboard, too, but I can't create it pressing Ctrl-Alt-M, German keyboard layout, too.
I get this 'µ'
Well, what happens when you press Ctrl-Alt-M now after you changed the hotkey, is the µ painted or is still something strange happening?
It happens nothing strange. Only my 'µ'. Or not within a textfield - nothing.
Are you running some other application that has hijacked the Ctrl-Alt-M shortcut? It sounds a little bit strange that some other task is activated when pressing the hotkey, maybe you are running TaskSwitchXP and you have set that hotkey there?
No, no other App that catches the hotkey (as far as I can check it). But I have seen another strabge behavior: If I use the Alt Ctrl M sometimes I open the Dialog with Language highlited and then switching to 'Edit view' before closing it. Dont know what happens.

But anyway I used to use F11/F12 (english/german) and when I use them it works fine. I did advance the script with "IfWinActive " so the hotkey only work for TC and not for other Apps. And I put both parts english german into one script - and now I'm happy.

Code: Select all

~F12::
IfWinActive ahk_class TTOTAL_CMD
{
PostMessage, 1075, 499, , , ahk_class TTOTAL_CMD
Send, {TAB}
SendRaw, Stefan deutsch
Send, {ENTER}
}
Return
~F11::
IfWinActive ahk_class TTOTAL_CMD
{
PostMessage, 1075, 499, , , ahk_class TTOTAL_CMD
Send, {TAB}
SendRaw, Stefan englisch
Send, {ENTER}
}
return
Thank you for your help. Maybe I find out something new tomorrow but now I go to bed.

Good night.

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Ah, yep. I had that shortcut assigned to an app myself...

If you wanna override that shortcut, just remove the ~ in the script, then the µ is not painted.

Edit:
Good night ;)

Icfu
This account is for sale
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

Funny. After removing the '~' the script works with [Alt]+[Ctrl[+[M] like a charm.

Can you tell me please what the 1075means?


sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
Post Reply