 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
fragman
Joined: 13 Oct 2009 Posts: 81
|
Posted: Tue Oct 27, 2009 11:00 pm Post subject: Detect if empty space or file/folder was double clicked |
|
|
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. |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1158 Location: San Diego, California
|
Posted: Wed Oct 28, 2009 12:06 am Post subject: |
|
|
| 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 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. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 81
|
Posted: Wed Oct 28, 2009 12:33 am Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1158 Location: San Diego, California
|
Posted: Wed Oct 28, 2009 4:43 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 81
|
Posted: Wed Oct 28, 2009 11:25 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
pajenn
Joined: 07 Feb 2009 Posts: 345
|
Posted: Wed Oct 28, 2009 12:36 pm Post subject: |
|
|
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
Software: Windows XP/SP3, Rising Antivirus, Online Armor firewall, Dragon NaturallySpeaking Pro + Natlink (with Vocola/Unimacro) and AHK for macro support. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 81
|
Posted: Wed Oct 28, 2009 1:15 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
pajenn
Joined: 07 Feb 2009 Posts: 345
|
Posted: Wed Oct 28, 2009 2:46 pm Post subject: |
|
|
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
Software: Windows XP/SP3, Rising Antivirus, Online Armor firewall, Dragon NaturallySpeaking Pro + Natlink (with Vocola/Unimacro) and AHK for macro support. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 81
|
Posted: Wed Oct 28, 2009 3:04 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 81
|
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 81
|
Posted: Wed Oct 28, 2009 8:27 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 81
|
Posted: Thu Oct 29, 2009 10:51 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|