AutoHotkey Community

It is currently May 26th, 2012, 10:49 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: October 28th, 2009, 12:00 am 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I'm looking for a proper way to detect if a file/folder or empty space was double clicked in the explorer file list. Right now I'm doing it by checking if any files are selected, as they get deselected if you click on empty space, but it's not working properly in some cases.
Basically I want to create a function to go upwards on double click on empty space, but it seems a bit difficult to get it working correctly.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 1:06 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6066
Location: San Diego, California
Quote:
Right now I'm doing it by checking if any files are selected, as they get deselected if you click on empty space, but it's not working properly in some cases.
A corollary to RTM is PYC :arrow: Post Your Code.

If you have something that works partially, it might be easier to say "if you change this, it will work better" . It also shows are trying to make it work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 1:33 am 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I would have, but I don't think it's helping much here.

Anyway, here's the code:

Code:
GetSelectedFilesInExplorer()
{
   global MuteClipboardSurveillance
   MuteClipboardSurveillance:=true
   clipboardbackup=%clipboardall%
   ControlFocus DirectUIHWND3, A
   SendInput {CTRL Down}{c}{CTRL Up}
   Sleep 10
   result:=clipboard
   clipboard:=clipboardbackup
   MuteClipboardSurveillance:=false
   return result
}

~LButton::

  Loop {
  LButtonDown := GetKeyState("LButton","P")
  If (!LButtonDown)
     Break
  }

   WaitTime:=DllCall("GetDoubleClickTime")/1000
   KeyWait, LButton, D T%WaitTime%
   If errorlevel=0
   {
      ControlGet renamestatus,Visible,,Edit1,A
      ControlGetFocus focussed, A
      if(renamestatus!=1&&focussed="DirectUIHWND3")
      {
         files:=GetSelectedFilesInExplorer()
         ;Yes, it really returns this character
        if files=
        {
            SendInput {Alt Down}{Up}{Alt Up}
         }
      }
   }
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 5:43 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6066
Location: San Diego, California
Might I ask what is DirectUIHWND3?
Code:
ControlFocus DirectUIHWND3, A

SysTreeView321 & SysListView321 are the controls I find in Windows Explorer that can be selected.

I suggest adding
Code:
msgbox %ErrorLevel%

to see if the command executes properly.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 12:25 pm 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
DirectUIHWND3 is the file list control in Vista and Windows7. It corresponds to SysListView321 in older Windows versions, but it's apparently very poorly documented. The problem I'm experiencing is that sometimes it's counting a double click on a folder as a click on empty space, and I can't enter the folder because I go upwards again. Another way i have thought of would be comparing the paths a short moment after the click, but I'm not sure if that would work properly.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 1:36 pm 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
I'm using XP so not sure if this applies to Vista/Win7, but in my experience ^c is a slow and unreliable method to grab file paths. Why not forgo the clipboard altogether, and instead use vista/win7 equivalents of:

Code:
ControlGet, selected, List, Selected Col1, SysListView321, A
ControlGet,focused,List,Focused Col1,SysListView321,A


And to detect double-clicks I'd just use double-keywaits. e.g.
Code:
#IfWinActive, ahk_class CabinetWClass
~LButton::
KeyWait,LButton
KeyWait, LButton, d T0.2
If ! Errorlevel
{
   ControlGet, selected, List, Selected Col1, SysListView321, A
   ControlGet,focused,List,Focused Col1,SysListView321,A
   ToolTip, Focused file:`n%focused%`n`nSelected files:`n%selected%
}
Return


In XP, double-clicking on empty deselects folders/files, but it does not remove the focus from the previously focused item, so not sure if that's any help to you. But I missed the point of your code anyway. On my system !{Up} does nothing, whereas !{Left} enters focused folder, but then again, so does double-clicking on it... And a single-click is enough to deselect files/folders, so again I don't see why anyone would double-click empty spaces for that purpose...

_________________
Hardware: 1.8 GHz laptop with 4 GB ram, Windows XP/SP3
Software: Prevx, Privatefirewall, KeyScrambler.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 2:15 pm 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I want to go upwards on double click on empty space, not into the focussed folder.

A few alternative file managers have this feature, and it's pretty useful I think because it's much faster to click on empty space then on the specific folder or button, and switching between keyboard and mouse is also slower.

I'll try your suggestions this evening, but I'm not sure there's a Vista/Win7 equivalent to the method for getting the filenames, because that control is very capsulated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 3:46 pm 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
OK, now I understand. Here's what I would use in XP:

Code:
GroupAdd, Explore, ahk_class CabinetWClass
GroupAdd, Explore, ahk_class ExploreWClass
WaitTime := DllCall("GetDoubleClickTime")/1000
return

#IfWinActive, ahk_group Explore
~LButton::
KeyWait,LButton
KeyWait, LButton, d T%WaitTime%
If ! Errorlevel
{
   MouseGetPos,,,,cCtrl,1
   ControlGet, selected, List, Selected Col1, %cCtrl%, A
   If ! selected
      Send {Up}
}
Return


The MouseGetPos command retrieve the ClassNN currently under the mouse cursor, but it's redunant if ClassNN is always the same (SysListView321 or DirectUIHWND3 ??)...

_________________
Hardware: 1.8 GHz laptop with 4 GB ram, Windows XP/SP3
Software: Prevx, Privatefirewall, KeyScrambler.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 4:04 pm 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
On XP that would probably be fine, but this is no supported ListView class unfortunately. It would be nice to see it supported in a future autohotkey update, but right now no one except Microsoft seems to know how exactly this control works.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 4:25 pm 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
Here is an article about DirectUIHWND hooking in MSN Messenger:
http://www.codeproject.com/KB/COM/comin ... gpart.aspx

Unfortunately, that article is far beyond my knowledge, but it would be cool if someone could dig into this :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 9:27 pm 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I now added an extra check for the path, and this seems to fix the problem I noticed:

Code:
~LButton::
   
   ControlGetText, path, ToolbarWindow322, A
  Loop {
  LButtonDown := GetKeyState("LButton","P")
  If (!LButtonDown)
     Break
  }

   WaitTime:=DllCall("GetDoubleClickTime")/1000
   KeyWait, LButton, D T%WaitTime%
   If errorlevel=0
   {
      Sleep 50
      
      ControlGetText, path1, ToolbarWindow322, A
      if(path == path1) {
         ControlGet renamestatus,Visible,,Edit1,A
         ControlGetFocus focussed, A
         if(renamestatus!=1&&focussed="DirectUIHWND3")
         {
            files:=GetSelectedFilesInExplorer()
            ;Yes, it really returns this character
           if files=
           {
               SendInput {Alt Down}{Up}{Alt Up}
            }
         }
      }
   }
Return


Not sure if everything is fixed now, there could still be problems when you double click on files, but I didn't see them yet.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2009, 11:51 pm 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
The timing is still causing me troubles, and I wonder if there's a more reliable method on vista/7 to get the selected files.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 17th, 2012, 4:11 am 
This is closer to what I'm looking for (Win 7 x64), anyone has any idea about how to make ControlGet work for Windows Explorer?


Report this post
Top
  
Reply with quote  
PostPosted: April 17th, 2012, 8:18 pm 
Online

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
It does not work with the file list anymore. You can use COM to get the selected files, select files and do similar stuff though.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], JSLover, Maestr0, Miguel, rbrtryn and 58 guests


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

Search for:
Powered by phpBB® Forum Software © phpBB Group