gcue Posted September 1, 2011 Posted September 1, 2011 (edited) i am trying to use fileopendialog to have a user select a file for copying to another destination. problem is if i chose a *.url or *.lnk file it tries to resolve the link and tries to send (temporary internet file for URL and actual file for LNK) and when selecting multiple files some will be LNK, URL files others while others will not here is what i am using: $afile = FileOpenDialog("Please Choose a File:", "C:\", "All (*.*)", 4) If not @error Then MsgBox(0,"",$afile) EndIf i have also tried All (*.url;*.lnk;*.*) i know i can do this: "URL (*.url)|LNK (*.lnk)|All (*.*)" but you cant select a mixture of URL,LNK or any file type in one shot. hope this makes sense anyone else come across this? thanks in advance Edited September 1, 2011 by gcue
rcmaehl Posted September 1, 2011 Posted September 1, 2011 Have you tried temporarily renaming .url and .lnk extensions? My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF
kaotkbliss Posted September 1, 2011 Posted September 1, 2011 I don't think FileOpenDialog is the correct method for this as from my understanding of the function, it's doing exactly as it is meant to -> opening/running the file. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
gcue Posted September 1, 2011 Author Posted September 1, 2011 Have you tried temporarily renaming .url and .lnk extensions? if a *.lnk or *.url file is chosen, the path is resolved so i never get to see the actual filepath to the lnk or url file - so i cannot rename it
gcue Posted September 1, 2011 Author Posted September 1, 2011 I don't think FileOpenDialog is the correct method for this as from my understanding of the function, it's doing exactly as it is meant to -> opening/running the file. what other methods did you have in mind?
kaotkbliss Posted September 1, 2011 Posted September 1, 2011 maybe FileSelectFolder, then you can do a FileListToArray and display the list of files in your own Gui to use FileCopy on? 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
gcue Posted September 1, 2011 Author Posted September 1, 2011 nice creative idea =) wish there was a switch in fileselectdialog to disable path resolving. seems that would be the best solution.
rover Posted September 1, 2011 Posted September 1, 2011 (edited) if a *.lnk or *.url file is chosen, the path is resolved so i never get to see the actual filepath to the lnk or url file - so i cannot rename it My first post after another Invision IP.Board forum software update... I still have the advanced editor setting turned off from the last forum update. I couldn't post unless I used the minimal editor... @gcue You need the _WinAPI_GetOpenFileName() UDF Helpfile: _WinAPI_GetOpenFileName() $tagOPENFILENAME link under Related section. Flags section lists the OFN_ constants and their descriptions. $OFN_NODEREFERENCELINKS - Directs the dialog box to return the path and file name of the selected shortcut (.LNK) file. If this value is not specified, the dialog box returns the path and file name of the file referenced by the shortcut. $OFN_NOCHANGEDIR - uses $sInitalDir every time dialog opened, does not recall directory from previous use. (contrary to comment in $tagOPENFILENAME, it does work in XP (SP3) with GetOpenFileName) Edit: *******! tags! expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <StructureConstants.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $iMemo ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite _Example_ExplorerStyleMultiSelect() Func _Example_ExplorerStyleMultiSelect() Local $hGui, $btn_dialog, $aFile, $sError ; Create GUI $hGui = GUICreate("GetOpenFileName use Explorer Style (Multi Select)", 400, 296) $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") $btn_dialog = GUICtrlCreateButton("Open Dialog", 155, 270, 90, 20) GUISetState() While 1 Switch GUIGetMsg() Case $btn_dialog $aFile = _WinAPI_GetOpenFileName("My Open File Dialog", _ "All (*.*)", ".", @ScriptName, "", 1, _ BitOR($OFN_NODEREFERENCELINKS, $OFN_ALLOWMULTISELECT, $OFN_EXPLORER), 0, $hGui) ;$OFN_NOCHANGEDIR If @error Or $aFile[0] = 0 Then $sError = _WinAPI_CommDlgExtendedError() MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError) Else For $x = 1 To $aFile[0] MemoWrite($aFile[$x]) Next EndIf Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGui) EndFunc ;==>_Example_ExplorerStyleMultiSelect Edited September 1, 2011 by rover I see fascists...
Ward Posted September 9, 2011 Posted September 9, 2011 (edited) Here is another way, an example to hook the windows API. This just add OFN_NODEREFERENCELINKS flag to AutoIt bulid-in FileOpenDialog. Only x86 system is supported for now. You need WinAPIEx.au3 for _WinAPI_GetProcAddress. #Include <WinAPI.au3> #Include <Memory.au3> #Include "WinAPIEx.au3" Dim $File = FileOpenDialogEx("", @WorkingDir, "All Files (*.*)") ConsoleWrite($File & @CRLF) Func FileOpenDialogEx($Title, $Init, $Filter, $Option = 0, $DefName = "", $hWnd = 0) Local $Addr = _WinAPI_GetProcAddress(_WinAPI_LoadLibrary("comdlg32.dll"), "GetOpenFileNameW") - 5 Local $Hook = DllStructCreate("byte[7]", $Addr) If DllStructGetData($Hook, 1) = Binary("0x90909090908BFF") Then Local $Code = "0x8B44240881483400001000584040FFE0" Local $CodePtr = _MemVirtualAlloc(0, BinaryLen($Code), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Local $Buffer = DllStructCreate("byte[" & BinaryLen($Code) & "]", $CodePtr) DllStructSetData($Buffer, 1, $Code) DllCall("kernel32.dll", "int", "VirtualProtect", "ptr", $Addr, "uint", 7, "int", 0x40, "int*", 0) DllStructSetData($Hook, 1, Binary("0xE8") & Binary($CodePtr - $Addr - 5) & Binary("0xEBF9")) EndIf Local $Ret = FileOpenDialog($Title, $Init, $Filter, $Option, $DefName, $hWnd) Return SetError(@Error, @Extended, $Ret) EndFunc Edited September 9, 2011 by Ward 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now