a little bug of param %2 in internal association

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
fallmq
Junior Member
Junior Member
Posts: 19
Joined: 2012-06-28, 16:47 UTC

a little bug of param %2 in internal association

Post by *fallmq »

the problem happened when there is a SPACE inside file path.
when I select more than one file, it is OK, tc can split multiple files correctly even if there is SPACE in file path.

but if I use %2 and I only select one file, if there is SPACE in the file path, TC will split the file path to different parameters.

Test under 8.01 rc5.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Did you put quotes around your %2 parameter?

e.g. Example for .exe
Actions:
Open *
Echo All -----> cmd.exe /k echo "%2"
Echo Mult ---> cmd.exe /k echo "%1"
fallmq
Junior Member
Junior Member
Posts: 19
Joined: 2012-06-28, 16:47 UTC

Post by *fallmq »

It is funny.
when I use "%2" instead of %2, it is OK when select single file when SPACE in the path, however when I try to select multiple files, it failed, so there is still some problem.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Can't confirm, with neither x32 or x64

I have 2 files, in the path:

c:\Users\FOO\Downloads\__FOLDER SPACES__\*.*
Winpad2.exe
XCacls_Installer.exe

When I select them and choose,
1) Echo All --> A single cmd.exe window opens all the files with full paths are echo'd and quoted.
2) Echo Mult --> Multiple cmd.exe windows open, each file with full paths are echo'd and quoted.
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
fallmq
Junior Member
Junior Member
Posts: 19
Joined: 2012-06-28, 16:47 UTC

Post by *fallmq »

yes, you are right, a lot applications can support the files with SPACE in the path.

I found this problem because I try to write some scripts by Autohotkey.
I use %2 to send the path information into the script.

When I try to get these parameters in my script, I found the problem, when click single file, the path information has been splitted into multiple parameters if there is SPACE in the path.

I am curious that, when I select multiple files, TC can correctly split file path into parameters, one file path into one parameter, even if there is SPACE in the path.

So I think TC has the mechanism to avoid this problem, but it seems this mechanism doesn't take effect when select single file.

I think a lot applications can support this kind of parameters because they do some compatibility process in the program, such as, check whether a parameter is started with a drive letter.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

I think yer not retrieving the args correctly via AHK,

This will do so, and AHK v2 (beta) has an internal variable (array I believe) for passed parameters (arguments).

Code: Select all

Loop, %0%
{
	args:=%A_Index%
	MsgBox, % args
}
In my example above, changing the internal association to

AHK Message | %AHK%\TC_TestInput.ahk "%2"

I get both programs and their paths in 2 Message Boxes.

(Where %AHK% is an environment variable)

Code: Select all

C:\$M$>set ahk
AHK="C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\Users\FOO\Documents\AutoH
otkey"
AHKDir=C:\Program Files\AutoHotkey
AHKICO=C:\Program Files\AutoHotkey\Extras\AutoHotkey_AHK1.icl
fallmq
Junior Member
Junior Member
Posts: 19
Joined: 2012-06-28, 16:47 UTC

Post by *fallmq »

maybe you are right, it may be AHK's problem when getting parameters.
I will modify my AHK file to compatible it.
It is not necessary to modify TC if many other applications can work well.
Post Reply