# Full path of file/files selected by mouse

**URL:** <https://forums.powershell.org/t/full-path-of-file-files-selected-by-mouse/15485>\
**Category:** PowerShell Help\
**Created:** [January 16, 2021, 5:11am UTC](https://forums.powershell.org/t/full-path-of-file-files-selected-by-mouse/15485 "2021-01-16T05:11:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abrumathew007](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@abrumathew007](https://forums.powershell.org/u/abrumathew007)\
**Post date:** [January 16, 2021, 5:11am UTC](https://forums.powershell.org/t/full-path-of-file-files-selected-by-mouse/15485/1 "2021-01-16T05:11:51Z")

</div>

Hi Guys,

Greetings of the day!

I have an interesting query. If I select a file in a directory by using mouse, Is it possible to fetch the path of this file using Powershell or otherwise? Is it stored somewhere in registry or file? I want to fetch full path of file for mouse event.

&nbsp;

Thanks in Advance. Await your response.

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [January 19, 2021, 7:08am UTC](https://forums.powershell.org/t/full-path-of-file-files-selected-by-mouse/15485/2 "2021-01-19T07:08:19Z")

</div>

Not sure this can be done with PS, at least not simply selecting a file. Might have a look at this:

[https://stackoverflow.com/questions/6678195/catch-windows-explorer-events](https://stackoverflow.com/questions/6678195/catch-windows-explorer-events)

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![ralphmwr](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ralphmwr/32/1064_2.png) [@ralphmwr](https://forums.powershell.org/u/ralphmwr)\
**Post date:** [January 19, 2021, 7:59am UTC](https://forums.powershell.org/t/full-path-of-file-files-selected-by-mouse/15485/3 "2021-01-19T07:59:51Z")

</div>

Do you want this to fire any time a file is selected in explorer or do you want the script to launch an explorer window and retrieve a file? If it’s the latter then it can be done with windows forms. Here’s a simple example:

```
Add-Type -AssemblyName system.windows.forms
$fileselection = New-Object System.Windows.Forms.OpenFileDialog -Property @{
        InitialDirectory = "C:\Windows"
        Filter = "*.*|*.*"
        Title = "Select a File"
    }
$null = $fileselection.ShowDialog()
"You selected {0}" -f $fileselection.FileName
```

If what you want is the former then you are in much more complicated territory and I would start with the link in TonyD’s post.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/full-path-of-file-files-selected-by-mouse/15485/4 "2024-05-16T20:27:59Z")

</div>


