File or folder selected in windows explorer
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
File or folder selected in windows explorer
Hello at all
Have you a way for knowing the path of the file or directory selected in windows explorer
Have a good day
Have you a way for knowing the path of the file or directory selected in windows explorer
Have a good day
The happiness is a road...
Not a destination
Not a destination
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: File or folder selected in windows explorer
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: File or folder selected in windows explorer
The code shows only the open folder windows, but not which folders and files are selected in the folder window.IdeasVacuum wrote:https://www.rsbasic.de/aktualisierung/w ... %20sind.pb
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: File or folder selected in windows explorer
Thanks at you two for your quick answer
Apparently it's a simple question, me too at the begining of my search, I'm sure it's very simple to have this information
But after several hours of search, i have not fount it
GetForegroundWindow_() return the handle of the windows explorer window, but for have the highlight file in this window, it's another pair of sleeves
If nobody know this tips, perhaps someone know how obtain the path of the element clicked and obviously immediatly hightlighing
Apparently it's a simple question, me too at the begining of my search, I'm sure it's very simple to have this information
But after several hours of search, i have not fount it
GetForegroundWindow_() return the handle of the windows explorer window, but for have the highlight file in this window, it's another pair of sleeves
If nobody know this tips, perhaps someone know how obtain the path of the element clicked and obviously immediatly hightlighing
The happiness is a road...
Not a destination
Not a destination
Re: File or folder selected in windows explorer
I think GetForegroundWindow_() just return the name of the open windows, not the path.
~Ar-S~
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
Code: Select all
r3p347 : 7ry : un71l d0n3 = 1
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: File or folder selected in windows explorer
Hello ARS
Yes it return the handle of the explorer Window
Yes it return the handle of the explorer Window
The happiness is a road...
Not a destination
Not a destination
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: File or folder selected in windows explorer
Thanks to RASHAD code i have make that
Now i can read under mouse.....
But like the first question...how can i have the file or folder selected if i have the handle of the windows explorer window ?
Code: Select all
Prototype.l ProtoAccessibleObjectFromPoint(x.l, y.l, *ia, *var)
Global AccessibleObjectFromPoint.ProtoAccessibleObjectFromPoint
CoInitialize_(0)
hdll.l = OpenLibrary(#PB_Any, "Oleacc.dll")
AccessibleObjectFromPoint = GetFunction(hdll, "AccessibleObjectFromPoint")
Repeat
Delay(100)
Define CursorPos.point, vt.VARIANT, *pIAcc.IAccessible, pName.l,len.l
GetCursorPos_(@CursorPos)
If AccessibleObjectFromPoint(CursorPos\x, CursorPos\y, @*pIAcc, @vt) = #S_OK
If *pIAcc\get_accValue(vt, @pName) = #S_OK And pName
Debug PeekS(pName)
EndIf
*pIAcc\Release()
EndIf
ForEver
But like the first question...how can i have the file or folder selected if i have the handle of the windows explorer window ?
The happiness is a road...
Not a destination
Not a destination
-
- Addict
- Posts: 4519
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: File or folder selected in windows explorer
As far as I can see, the following works fine here on Windows 10.
1) Save this code by Raymond Chen to a file, say "expl.js".
2) In the code, replace both characters “ and ” with "" (= Chr(34)).
3) Open an Explorer window and select one or more items in it.
4) Open a console window, and run this command:
I'm sure someone here can translate that JavaScript code to PB code.
1) Save this code by Raymond Chen to a file, say "expl.js".
2) In the code, replace both characters “ and ” with "" (= Chr(34)).
3) Open an Explorer window and select one or more items in it.
4) Open a console window, and run this command:
Code: Select all
cscript <path>\expl.js
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: File or folder selected in windows explorer
Hello LittleJohn
Thanks for your answer
I have try your tip and i have the answer
Thanks for your answer
I have try your tip and i have the answer
Console wrote:They are not script motor for the file extension ".js"
The happiness is a road...
Not a destination
Not a destination
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: File or folder selected in windows explorer
But thanks to you and your idea, i have search in the direction of VbScript
I prefer PB and API solution, but for the moment this worksAgain thanks LittleJohn for your precious help...you are a good man
I prefer PB and API solution, but for the moment this works
Code: Select all
Function GetSelectedFiles() 'Returns paths as array of strings
Dim FileList, Window, SelectedItem
'avoid duplicates by storing paths in dictionary keys
Set FileList = CreateObject("Scripting.Dictionary")
With CreateObject("Shell.Application")
For Each Window In .Windows
'skip IE Windows
If InStr(1, Window.FullName, "iexplore.exe", vbTextCompare) = 0 Then
For Each SelectedItem In Window.Document.SelectedItems
FileList(SelectedItem.Path) = Null
Next
End If
Next
End With
GetSelectedFiles = FileList.Keys 'array of paths
End Function
MsgBox "Click OK after selecting the items", _
vbOKOnly Or vbInformation, "Select a few items"
Dim SelectedFiles
SelectedFiles = GetSelectedFiles
MsgBox "You selected: " & vbNewLine & vbNewLine & _
Join(SelectedFiles, vbNewLine), vbOKOnly Or vbInformation, "Selected Items"
The happiness is a road...
Not a destination
Not a destination
Re: File or folder selected in windows explorer
Thank you too, Kwai chang caine, because your VBS script works perfectly for me too. Even when multiple files are selected in different folders, which amazed me!
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: File or folder selected in windows explorer
Happy to read that !!! for one time my search interesting someone
You can also use the great COMATE for run this VB code into PB
It's a pity it's for the moment impossible with PB
It's Kul-Tigin code : https://stackoverflow.com/questions/203 ... ected-file and LittleJohn for put me in one of the good ways
Thanks for your kind message
You can also use the great COMATE for run this VB code into PB
Yes i have see that too, it's magicEven when multiple files are selected in different folders, which amazed me
It's a pity it's for the moment impossible with PB
It's not my code, i'm not enough intelligent to spawn thatyour VBS script works perfectly for me too
It's Kul-Tigin code : https://stackoverflow.com/questions/203 ... ected-file and LittleJohn for put me in one of the good ways
Thanks for your kind message
The happiness is a road...
Not a destination
Not a destination
Re: File or folder selected in windows explorer
Hi Kwai chang caine,
- Windows Services & Other Stuff
-- \Other_Stuff\SelectedItems\SelectedItems.pb
NOTE: Most of the heavy lifting was done by luis; see this post.Kwai chang caine wrote:I prefer PB and API solution
...
It's a pity it's for the moment impossible with PB
- Windows Services & Other Stuff
-- \Other_Stuff\SelectedItems\SelectedItems.pb
Last edited by JHPJHP on Sat May 18, 2019 5:27 pm, edited 7 times in total.
Re: File or folder selected in windows explorer
JHPJHP, I don't know if it's my PC or what, but that codes takes a long time to get the selected files (about 2 seconds for each one). It also doesn't include the path to the file. By comparison, the VBS script is instant and includes the path.
Re: File or folder selected in windows explorer
Hi BarryG,
After some additional testing, if a selected file or folder is scrolled offscreen it may not be listed. This can definitely be resolved, but it requires more interest then I currently possess.
NB*: The script in its current form is still slower then the VB approach, but has the potential to do so much more.
Previous post has been updated to include the Path.BarryG wrote:the VBS script is instant and includes the path
After some additional testing, if a selected file or folder is scrolled offscreen it may not be listed. This can definitely be resolved, but it requires more interest then I currently possess.
NB*: The script in its current form is still slower then the VB approach, but has the potential to do so much more.