It is currently Thu Jul 18, 2019 2:22 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: File or folder selected in windows explorer
PostPosted: Wed May 15, 2019 2:35 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4463
Location: Lyon - France
Hello at all

Have you a way for knowing the path of the file or directory selected in windows explorer

Have a good day

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Wed May 15, 2019 3:10 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5818
Location: Wales, UK
Hi

In the RSBasic WinAPI Library:

https://www.rsbasic.de/aktualisierung/winapi_library_2011/Codes/Dateien/Ermitteln%2C%20welche%20Ordner%20im%20Explorer%20ge%C3%B6ffnet%20sind.pb

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Wed May 15, 2019 3:14 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1033
Location: Germany::Berlin()
IdeasVacuum wrote:

The code shows only the open folder windows, but not which folders and files are selected in the folder window.

_________________
ImageImageImageImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Wed May 15, 2019 5:40 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4463
Location: Lyon - France
Thanks at you two for your quick answer 8)

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 :oops:
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 :idea:

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Wed May 15, 2019 6:02 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Oct 06, 2007 11:20 pm
Posts: 258
Location: France
I think GetForegroundWindow_() just return the name of the open windows, not the path.

_________________
~Ar-S~

ResizerGold : The easiest way to resize your pictures and more
My webSite (french) : LDVMULTIMEDIA
PB - 5.4x LTS / 5.6x - W10 x64 - GTX1080 - i5 6600k
Repeat : try : until done = 1


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Wed May 15, 2019 6:22 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4463
Location: Lyon - France
Hello ARS :wink:
Yes it return the handle of the explorer Window

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Wed May 15, 2019 6:34 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4463
Location: Lyon - France
Thanks to RASHAD code i have make that :D

Code:
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


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 ? :|

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Wed May 15, 2019 9:39 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3598
Location: Berlin, Germany
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:
Code:
cscript <path>\expl.js

I'm sure someone here can translate that JavaScript code to PB code.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Thu May 16, 2019 11:02 am 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4463
Location: Lyon - France
Hello LittleJohn :D
Thanks for your answer 8)

I have try your tip and i have the answer
Console wrote:
They are not script motor for the file extension ".js"
:|

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Thu May 16, 2019 11:09 am 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4463
Location: Lyon - France
But thanks to you and your idea, i have search in the direction of VbScript :idea:
I prefer PB and API solution, but for the moment this works 8)
Code:
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"
Again thanks LittleJohn for your precious help...you are a good man 8) :wink:

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Thu May 16, 2019 12:26 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 193
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!


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Thu May 16, 2019 12:56 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4463
Location: Lyon - France
Happy to read that !!! :D for one time my search interesting someone :lol:
You can also use the great COMATE for run this VB code into PB 8)

Quote:
Even when multiple files are selected in different folders, which amazed me
Yes i have see that too, it's magic :shock:
It's a pity it's for the moment impossible with PB :|

Quote:
your VBS script works perfectly for me too
It's not my code, i'm not enough intelligent to spawn that :mrgreen:
It's Kul-Tigin code : https://stackoverflow.com/questions/203 ... ected-file and LittleJohn for put me in one of the good ways 8)

Thanks for your kind message 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Fri May 17, 2019 8:27 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1572
Hi Kwai chang caine,

Kwai chang caine wrote:
I prefer PB and API solution
...
It's a pity it's for the moment impossible with PB

NOTE: Most of the heavy lifting was done by luis; see this post.
- Windows Services & Other Stuff
-- \Other_Stuff\SelectedItems\SelectedItems.pb

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Sat May 18, 2019 5:27 pm, edited 7 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Fri May 17, 2019 9:37 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 193
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: File or folder selected in windows explorer
PostPosted: Fri May 17, 2019 10:22 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1572
Hi BarryG,

BarryG wrote:
the VBS script is instant and includes the path

Previous post has been updated to include 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.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Exabot [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye