请问如何判断由InputBox,UserPath输入的路径是否存在? Topic is solved

遇到了问题?请先进行搜索(中文和英文),然后在此提问

Moderators: tmplinshi, arcticir

944705050
Posts: 1
Joined: 29 Mar 2015, 04:51
Contact:

请问如何判断由InputBox,UserPath输入的路径是否存在?

29 Mar 2015, 04:59

Code: Select all

InputBox,UserPath
Run,%UserPath%
如何判断UserPath是否为有效路径?
如果无效则提示重新输入。 :?
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: 请问如何判断由InputBox,UserPath输入的路径是否存在?  Topic is solved

29 Mar 2015, 12:33

Code: Select all

Loop
    InputBox, UserPath
Until, FileExist(UserPath)

Run, %UserPath%
garry
Posts: 3768
Joined: 22 Dec 2013, 12:50

Re: 请问如何判断由InputBox,UserPath输入的路径是否存在?

01 Apr 2015, 02:32

maybe can use a GUI with edit or listbox or use Fileselectfile /folder

Code: Select all

Gui,2:font,s10,Verdana
Gui,2:add,button , x10 y45  h25  w100 gA1,Run
Gui,2:add,edit   , x10 y5   h30  w350 ve1 ,c:\test\test.mp3
Gui,2:show, x10 y10 h75 w400 ,Select File Test
return
2Guiclose:
exitapp

a1:
Gui,2:submit,nohide
e1=%e1%
ifexist,%e1%
    run,%e1%
else
  {
  Guicontrol,2:,e1
  Guicontrol,2:,e1,Path not exist
  sleep,5000
  Guicontrol,2:,e1
  }
return
an example , search folders with desired extensions and open folder with mouseclick

Code: Select all

;-------- saved at Mittwoch, 1. April 2015 09:04:40 -----------
Gui,2:font,s10,Verdana
Gui,2:add,button , x10 y120 h25  w100 gSelectx,SelectFolder
Gui,2:add,listbox, x10 y5   h100 w950 vlb1 gA1 +wrap,
Gui,2:show, x10 y10 h160 w1000 ,Select Folder Test
return
2Guiclose:
exitapp

a1:
;if (A_GuiEvent = "DoubleClick")
if (A_GuiEvent = "Normal")
{
Gui,2:Submit,nohide
ifexist,%lb1%
    run,%lb1%
return
}
return

selectx:
Extensions := "mp3,mp4"
preselect=%a_desktop%                       ;- search folder from here with contents 'extensions'
FileSelectFolder,rootfolder,%PRESELECT%
if rootfolder=
  return
Loop,%rootFolder%\*.*,2,1
{
	Loop,%A_LoopFileFullPath%\*.*,0,0
	{
		If A_LoopFileExt in %Extensions%
		{
                e .= A_LoopFileDir . "|"
			break
		}
	}
}
Guicontrol,2:,lb1,|            ;- clear listbox
if e<>
  Guicontrol,2:,lb1,%e%
else
  Guicontrol,2:,lb1,No folders found with files-extension= %extensions%
e=
return
;=========== end script ======================

Return to “请求帮助”

Who is online

Users browsing this forum: No registered users and 51 guests