Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Suggestion - Change directory using windows message

 
Post new topic   Reply to topic    Total Commander Forum Index -> TC suggestions (English) Printable version
View previous topic :: View next topic  
Author Message
majkinetor !
Power Member
Power Member


Joined: 18 Jan 2006
Posts: 1571

PostPosted: Fri Nov 17, 2006 8:02 am    Post subject: Suggestion - Change directory using windows message Reply with quote

I want to suggest changing the directory using WM_COPY message.
This message should respond to this acction the very same as integrated "directory menu" (that is, it should support plugins, executables, cm's, ftps etc...)

This will be good step forward for blind users and automatition scripters as there are many situation where this interaction is requrired - for instance connecting some 3th party searcher like Locate or any other tool that returns information about files (like sysinternals handle.exe for locked files, external compare tools, information organizers etc...)

Currently the one must use "current directory" header, isue edit and paste the text here and still it doesn't support ftps and some other things, the most important drawback to be that it will not change directory in 100% of situation due to the possible CPU hog, user interference etc..


I would really appreaciate if such mechanism exists in TC7 along with already added LB_XXX messages.
_________________

             Habemus majkam!


www.r-moth.com               http://r-moth.deviantart.com
Back to top
View user's profile Send private message Visit poster's website
Lefteous
Power Member
Power Member


Joined: 08 Feb 2003
Posts: 7671
Location: Germany

PostPosted: Fri Nov 17, 2006 8:32 am    Post subject: Reply with quote

Command line parameters or WM_COPYDATA should do this job, right?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
majkinetor !
Power Member
Power Member


Joined: 18 Jan 2006
Posts: 1571

PostPosted: Sat Nov 18, 2006 4:54 pm    Post subject: Reply with quote

NOt the command line params. It should work while TC is open. So only solution is WM_COPYDATA as string needs to be sent to TC. Paramter value of message can signify that directory change is in question
_________________

             Habemus majkam!


www.r-moth.com               http://r-moth.deviantart.com
Back to top
View user's profile Send private message Visit poster's website
icfu
Power Member
Power Member


Joined: 10 Sep 2003
Posts: 6059

PostPosted: Sun Nov 19, 2006 6:48 am    Post subject: Reply with quote

Just to make that clear again and to prevent misunderstandings:
You are already using WM_COPYDATA to send CD in the Locate script which I had adjusted in the AHK forum! Have you overlooked that?

The AHK code I created a while ago to pass two directories (plus parameters) to TC:
Code:
; *** Konfig-Start
left := "%windir%"
right := "%programfiles%"
parameter := "ST"
; *** Konfig-Ende

Transform, left, Deref, %left%
Transform, right, Deref, %right%
paths := left "`r" right

Send_WM_COPYDATA(paths, parameter)

Send_WM_COPYDATA(ByRef SentPaths, ByRef SentParameters)
{
  VarSetCapacity( CopyDataStruct, 12 )
  InsertInteger( Asc( "C" ) + 256 * Asc( "D" ), CopyDataStruct )
  InsertInteger( StrLen( SentPaths ) + 5, CopyDataStruct, 4 )
  InsertInteger( &SentPaths, CopyDataStruct, 8 )
  Loop, Parse, SentParameters
  {
    InsertInteger( Asc( A_LoopField ), SentPaths, StrLen( SentPaths ) + A_Index, 1)
  }
  SendMessage, 0x4A, , &CopyDataStruct, , ahk_class TTOTAL_CMD
}

InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
{
  mask := 0xFF
  Loop %pSize%
  {
    DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index - 1, UInt, 1, UChar, (pInteger & mask) >> 8 * (A_Index - 1))
    mask := mask << 8
  }
}


Icfu
_________________
This account is for sale
Back to top
View user's profile Send private message Send e-mail
majkinetor !
Power Member
Power Member


Joined: 18 Jan 2006
Posts: 1571

PostPosted: Sun Nov 19, 2006 1:24 pm    Post subject: Reply with quote

It seems that this is the thing I want.
I will check it out.

Thx.
_________________

             Habemus majkam!


www.r-moth.com               http://r-moth.deviantart.com
Back to top
View user's profile Send private message Visit poster's website
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24590
Location: Switzerland

PostPosted: Sun Nov 19, 2006 5:42 pm    Post subject: Reply with quote

You can set only one path of the two by leaving it empty (the 0x13 ENTER char must be present, though).

There are also two parameters after the final 0x00 character (second path end):
T causes the path to be opened in a new tab
S causes the path to be seen as source and target instead of left+right
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
majkinetor !
Power Member
Power Member


Joined: 18 Jan 2006
Posts: 1571

PostPosted: Mon Nov 20, 2006 2:05 am    Post subject: Reply with quote

Thx
_________________

             Habemus majkam!


www.r-moth.com               http://r-moth.deviantart.com
Back to top
View user's profile Send private message Visit poster's website
m^2
Power Member
Power Member


Joined: 12 Jul 2006
Posts: 1414
Location: Poland

PostPosted: Sun Nov 26, 2006 6:46 am    Post subject: Reply with quote

icfu wrote:
Code:
; *** Konfig-Start
left := "%windir%"
right := "%programfiles%"
parameter := "ST"
; *** Konfig-Ende

Transform, left, Deref, %left%
Transform, right, Deref, %right%
paths := left "`r" right

Send_WM_COPYDATA(paths, parameter)

Send_WM_COPYDATA(ByRef SentPaths, ByRef SentParameters)
{
  VarSetCapacity( CopyDataStruct, 12 )
  InsertInteger( Asc( "C" ) + 256 * Asc( "D" ), CopyDataStruct )
  InsertInteger( StrLen( SentPaths ) + 5, CopyDataStruct, 4 )
  InsertInteger( &SentPaths, CopyDataStruct, 8 )
  Loop, Parse, SentParameters
  {
    InsertInteger( Asc( A_LoopField ), SentPaths, StrLen( SentPaths ) + A_Index, 1)
  }
  SendMessage, 0x4A, , &CopyDataStruct, , ahk_class TTOTAL_CMD
}

InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
{
  mask := 0xFF
  Loop %pSize%
  {
    DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index - 1, UInt, 1, UChar, (pInteger & mask) >> 8 * (A_Index - 1))
    mask := mask << 8
  }
}

Icfu

Can anybody translate it to C / C++ ?
I tried to do this and I have:
Code:

COPYDATASTRUCT copyStruct;
HWND TC;

if((TC = FindWindow ("TTOTAL_CMD", NULL)) != INVALID_HANDLE_VALUE)
    return;

ZeroMemory (&copyStruct, sizeof (COPYDATASTRUCT));
copyStruct.dwData = 'C' + ('D'*256);
copyStruct.cbData = strlen("%windir%\r%programfiles%\0S") + 1;
copyStruct.lpData = "%windir%\r%programfiles%\0S";
SendMessage (TC, WM_COPYDATA, 0, (LPARAM)&copyStruct);

But it doesn't work? What do I do wrong?
_________________
Image: http://img201.imageshack.us/img201/2110/pcbsdec7.jpg
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Stance
Power Member
Power Member


Joined: 29 Mar 2005
Posts: 1038

PostPosted: Sun Nov 26, 2006 8:26 am    Post subject: Reply with quote

m^2 wrote:
Can anybody translate it to C / C++ ?

Please take a look at Lefteous posting in: [Question] about em_cmds
Back to top
View user's profile Send private message Send e-mail
m^2
Power Member
Power Member


Joined: 12 Jul 2006
Posts: 1414
Location: Poland

PostPosted: Sun Nov 26, 2006 8:39 am    Post subject: Reply with quote

Stance wrote:
m^2 wrote:
Can anybody translate it to C / C++ ?

Please take a look at Lefteous posting in: [Question] about em_cmds

As you can see, his code is similar to mine-and it does the same. I used it to send EM messages and everything worked perfectly. As I understand the ahk code above, the only important differences are CD instead of EM and optional parameters after '\0'. But it doesn't work - TC ignores my message.
_________________
Image: http://img201.imageshack.us/img201/2110/pcbsdec7.jpg
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Lefteous
Power Member
Power Member


Joined: 08 Feb 2003
Posts: 7671
Location: Germany

PostPosted: Sun Nov 26, 2006 9:46 am    Post subject: Reply with quote

2m^2
I didn't really test your code but this cannot work:
Code:
if((TC = FindWindow ("TTOTAL_CMD", NULL)) != INVALID_HANDLE_VALUE)

FindWindow returns NULL if no window could be found and this not the same as INVALID_HANDLE_VALUE.

Anyway here is a working example:
Code:
HWND targetWindow = FindWindow ("TTOTAL_CMD", NULL);
if (!targetWindow)
{
   return;
}
COPYDATASTRUCT copyStruct;
ZeroMemory (&copyStruct, sizeof (COPYDATASTRUCT));      
copyStruct.dwData = 'C' + 256 * 'D';
const char* commandLine = "%windir%\r%programfiles%\0S";
copyStruct.cbData = strlen(commandLine) +1;
copyStruct.lpData = (PVOID)commandLine;
SendMessage (targetWindow, WM_COPYDATA, NULL, (LPARAM)&copyStruct);
Back to top
View user's profile Send private message Send e-mail Visit poster's website
m^2
Power Member
Power Member


Joined: 12 Jul 2006
Posts: 1414
Location: Poland

PostPosted: Mon Nov 27, 2006 3:51 am    Post subject: Reply with quote

Thanks Lefteous.
You're right, this is incorrect - FindWindow doesn't return INVALID_HANDLE_VALUE. And I have this in several programs :/
But this isn't a big problem - Windows ignores messages sent to NULL.
There was a really stupid bug: != instead of ==. Embarassed
And that's it.
_________________
Image: http://img201.imageshack.us/img201/2110/pcbsdec7.jpg
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
9kvD38n6
Junior Member
Junior Member


Joined: 03 Sep 2010
Posts: 35

PostPosted: Tue Jul 03, 2012 2:36 pm    Post subject: Improvement to fully replace command line Reply with quote

Could TC's reception be improved so that it also selects the give file in the ListBox? Command line does this. E.g.
Code:
TOTALCMD.EXE /l=c:\temp\test.txt /p=l
will go to the temp folder and put the caret on the file. If I'm not mistaken, this can't be achieved using WM_COPYDATA?

By the way, someone has posted a working version for unicode AHK over at http://www.autohotkey.com/community/viewtopic.php?t=74570.
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 4528
Location: Russian Federation

PostPosted: Wed Jul 04, 2012 6:57 am    Post subject: Reply with quote

9kvD38n6, it already works as you wish. If you pass full path to a file instead of folder, TC focuses it. It works with both WM_COPYDATA and with command line parameters.
_________________
VirtualPanel plugin: Temporary panel for TC (forum)
TOTALCMD.NET: TCFS2, NTLinks, CopyTree, AskParam, ConPaste, Sudo…
Back to top
View user's profile Send private message Send e-mail
9kvD38n6
Junior Member
Junior Member


Joined: 03 Sep 2010
Posts: 35

PostPosted: Fri Jul 27, 2012 9:34 am    Post subject: Reply with quote

So it does - only if you use the "S" parameter, of course, which I had very foolishly omitted in my testing. Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> TC suggestions (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group