| View previous topic :: View next topic |
| Author |
Message |
majkinetor ! Power Member


Joined: 18 Jan 2006 Posts: 1571
|
Posted: Fri Nov 17, 2006 8:02 am Post subject: Suggestion - Change directory using windows message |
|
|
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 |
|
 |
Lefteous Power Member


Joined: 08 Feb 2003 Posts: 7671 Location: Germany
|
Posted: Fri Nov 17, 2006 8:32 am Post subject: |
|
|
| Command line parameters or WM_COPYDATA should do this job, right? |
|
| Back to top |
|
 |
majkinetor ! Power Member


Joined: 18 Jan 2006 Posts: 1571
|
Posted: Sat Nov 18, 2006 4:54 pm Post subject: |
|
|
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 |
|
 |
icfu Power Member

Joined: 10 Sep 2003 Posts: 6059
|
Posted: Sun Nov 19, 2006 6:48 am Post subject: |
|
|
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 |
|
 |
majkinetor ! Power Member


Joined: 18 Jan 2006 Posts: 1571
|
|
| Back to top |
|
 |
ghisler(Author) Site Admin


Joined: 04 Feb 2003 Posts: 24590 Location: Switzerland
|
Posted: Sun Nov 19, 2006 5:42 pm Post subject: |
|
|
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 |
|
 |
majkinetor ! Power Member


Joined: 18 Jan 2006 Posts: 1571
|
|
| Back to top |
|
 |
m^2 Power Member


Joined: 12 Jul 2006 Posts: 1414 Location: Poland
|
Posted: Sun Nov 26, 2006 6:46 am Post subject: |
|
|
| 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 (©Struct, 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)©Struct); |
But it doesn't work? What do I do wrong? _________________ Image: http://img201.imageshack.us/img201/2110/pcbsdec7.jpg |
|
| Back to top |
|
 |
Stance Power Member


Joined: 29 Mar 2005 Posts: 1038
|
Posted: Sun Nov 26, 2006 8:26 am Post subject: |
|
|
| 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 |
|
 |
m^2 Power Member


Joined: 12 Jul 2006 Posts: 1414 Location: Poland
|
Posted: Sun Nov 26, 2006 8:39 am Post subject: |
|
|
| 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 |
|
 |
Lefteous Power Member


Joined: 08 Feb 2003 Posts: 7671 Location: Germany
|
Posted: Sun Nov 26, 2006 9:46 am Post subject: |
|
|
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 (©Struct, 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)©Struct); |
|
|
| Back to top |
|
 |
m^2 Power Member


Joined: 12 Jul 2006 Posts: 1414 Location: Poland
|
Posted: Mon Nov 27, 2006 3:51 am Post subject: |
|
|
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 ==.
And that's it. _________________ Image: http://img201.imageshack.us/img201/2110/pcbsdec7.jpg |
|
| Back to top |
|
 |
9kvD38n6 Junior Member

Joined: 03 Sep 2010 Posts: 35
|
Posted: Tue Jul 03, 2012 2:36 pm Post subject: Improvement to fully replace command line |
|
|
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 |
|
 |
MVV Power Member


Joined: 03 Aug 2008 Posts: 4528 Location: Russian Federation
|
|
| Back to top |
|
 |
9kvD38n6 Junior Member

Joined: 03 Sep 2010 Posts: 35
|
Posted: Fri Jul 27, 2012 9:34 am Post subject: |
|
|
| 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 |
|
 |
|
|
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
|
|