sree161 Posted October 14, 2017 Posted October 14, 2017 Hi all, how can i get the location of selected file into a variable?? I tried all these but i didn't get desired output $a = @ProgramFilesDir $b = @ProgramsDir MsgBox(0, "", $a) MsgBox(0, "", $b)
water Posted October 14, 2017 Posted October 14, 2017 Please define "desired output". My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
sree161 Posted October 14, 2017 Author Posted October 14, 2017 22 minutes ago, water said: Please define "desired output". i am select a file a running a hot key which is set before. i need to assign the location of the selected document to a variable. below is my complete program. HotKeySet('h', 'HotKey1') While 1 sleep(5) WEnd Func HotKey1() ConsoleWrite("n:" & @CRLF) $a = @ProgramFilesDir $b = @ProgramsDir $f = @filedir ; i need to assign the location of selected file to this variable and display it. MsgBox(0, "", $a) MsgBox(0, "", $b) EndFunc
Developers Jos Posted October 14, 2017 Developers Posted October 14, 2017 Which selected file? Do you mean the running script file? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
water Posted October 14, 2017 Posted October 14, 2017 Or do you mean you select a file in another program (e.g. Windows Explorer) and when the hotkey gets pressed you want to process this selected file? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted October 14, 2017 Posted October 14, 2017 BTW: When posting code please use AutoIt code tags in the editor (the "<>" button). Makes your code much easier to read Example: HotKeySet('h', 'HotKey1') While 1 Sleep(5) WEnd Func HotKey1() ConsoleWrite("n:" & @CRLF) $a = @ProgramFilesDir $b = @ProgramsDir $f = @filedir ; i need to assign the location of selected file to this variable and display it. MsgBox(0, "", $a) MsgBox(0, "", $b) EndFunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
sree161 Posted October 14, 2017 Author Posted October 14, 2017 5 minutes ago, water said: Or do you mean you select a file in another program (e.g. Windows Explorer) and when the hotkey gets pressed you want to process this selected file? ya exactly...i am going to select a notepad file. the location of notepad should be copied to that variable.
sree161 Posted October 14, 2017 Author Posted October 14, 2017 1 minute ago, water said: BTW: When posting code please use AutoIt code tags in the editor (the "<>" button). Makes your code much easier to read Example: HotKeySet('h', 'HotKey1') While 1 Sleep(5) WEnd Func HotKey1() ConsoleWrite("n:" & @CRLF) $a = @ProgramFilesDir $b = @ProgramsDir $f = @filedir ; i need to assign the location of selected file to this variable and display it. MsgBox(0, "", $a) MsgBox(0, "", $b) EndFunc sure
water Posted October 14, 2017 Posted October 14, 2017 There are many examples on the forum on how to retrieve the selected file from Windows Explorer. One of them is: My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted October 14, 2017 Posted October 14, 2017 Another BTW: When you reply to a post there is no need to quote the original post by clicking the Quote button. I know what I have written Just enter your reply at the end of the thread and click "Submit Reply". My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
sree161 Posted October 14, 2017 Author Posted October 14, 2017 1 hour ago, Jos said: Which selected file? Do you mean the running script file? Jos no i am selecting a file from windows explorer...i need to pull the location of the file to a variable
1957classic Posted October 14, 2017 Posted October 14, 2017 Is this what you mean? #include <MsgBoxConstants.au3> $f = FileOpenDialog("Select File", "", "Text (*.txt)") MsgBox($MB_SYSTEMMODAL, "File Location", $f, 5)
water Posted October 14, 2017 Posted October 14, 2017 No, he is looking for Windows Explorer to select files from. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
sree161 Posted October 15, 2017 Author Posted October 15, 2017 ya i need the script to get the location of the file when i select any file from any other location i.e. windows explorer I used hotkey as posted in above comments
mikell Posted October 15, 2017 Posted October 15, 2017 Laziness is counterproductive It took 2 minutes to find it using search, and 2 minutes more to make a runnable snippet ; https://www.autoitscript.com/forum/topic/144641-get-path-of-currently-selected-file-in-explorer/ #include <WinAPI.au3> HotKeySet('h', 'GetExplorerSelection') While 1 Sleep(10) Wend Func GetExplorerSelection() Local $saveClip = "" Local $filesFolders = "" Local $handle = _WinAPI_GetForegroundWindow() Local $className = _WinAPI_GetClassName($handle) If $className = "ExploreWClass" Or $className = "CabinetWClass" Then $saveClip = ClipGet() Send("^c") Sleep(50) $filesFolders = ClipGet() ClipPut($saveClip) Msgbox(0,"", $filesFolders) EndIf EndFunc
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