Why get wrong file path?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
amnesiac
Posts: 186
Joined: 22 Nov 2013, 03:08
Location: Egret Island, China
Contact:

Why get wrong file path?

15 Mar 2014, 21:44

Code: Select all

Dir := "c:\WINDOWS\"
Loop, %Dir%\*.*
	MsgBox, %A_LoopFileFullPath%
Why is it a wrong file path in the MsgBox? I mean why Msgbox here can be executed.
I know the following is correct:

Code: Select all

; the backslash in the end of Dir has been trimmed.
Dir := "c:\WINDOWS"
Loop, %Dir%\*.*
	MsgBox, %A_LoopFileFullPath%
Is it a bug?
AutoHotkey 学习指南(Beauty of AutoHotkey)
I do not make codes, and only a porter of AutoHotkey: from official to Chinese, from other languages to AutoHotkey, and show AutoHotkey to ordinary users sometimes.
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: Why get wrong file path?

16 Mar 2014, 04:26

sorry , have no answer, only a small test-script
(wishing a nice sunday)
first example is wrong ( as you mentioned ) , autohotkey works fine, just avoid the second backlash
a small test - script to compare , first example shows the same files with 2-backlash ( as it is in the script also )

Code: Select all

;-------- http://ahkscript.org/boards/viewtopic.php?f=5&t=2757 ---
f1=%a_scriptdir%\test55.txt
f2=%a_scriptdir%\test66.txt
ifexist,%f1%
  filedelete,%f1%
ifexist,%f2%
  filedelete,%f2%

Dir := "c:\WINDOWS\"
Loop, %Dir%\*.*
    e .= A_LoopFileFullPath "`r`n"
fileappend,%e%,%f1%
run,%f1%

Dir := "c:\WINDOWS"
Loop, %Dir%\*.*
    h .= A_LoopFileFullPath "`r`n"
fileappend,%h%,%f2%
run,%f2%
e=
h=
exitapp
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Why get wrong file path?

16 Mar 2014, 06:36

You asked for the files in C:\Windows\\, so you got the files in C:\Windows\\.

Try running C:\\\\Windows\\\\notepad.exe outside of AutoHotkey. I think you'll find that it works, just like your script worked.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: peter_ahk and 355 guests