 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Thu Sep 03, 2009 2:41 pm Post subject: doubleclick on selected syslistview32 item ? |
|
|
Hi !
I have a syslistview32 control of a third party app and want to define a shortcut like :
Enter::doubleclick on highlighted item
Is there an easy way to do this (without dll apart from the microsoft ones) ?
I read the forum thoroughly and only came across "read text from list view"
topics.
Thanks in advance ! This would be damn useful ! _________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05 |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Thu Sep 03, 2009 7:17 pm Post subject: |
|
|
Here you have something to play with
I can't get ControlClick to send a doubleclick, not sure why
| Code: | VarSetCapacity(POINT,8) ;to recieve position
Gui,Add,ListView,r20 hwndsys AltSubmit gLaunch,test|auch
Loop 20
LV_Add("",A_Index,A_Index)
Gui,Show
Gui +LastFound
hwnd:=WinExist()
Return
GuiClose:
ExitApp
Launch:
If A_GuiEvent=DoubleClick
ToolTip % A_EventInfo
Return
Enter::
ControlGetPos,x,y,,,,ahk_id %sys%
SendMessage,TVM_GETITEM:=0x100c,-1,3,,ahk_id %sys%
If ErrorLevel=4294967295
Return
item:=ErrorLevel+1
SendMessage,LVM_GETITEMPOSITION:=0x1010,item,&POINT,,ahk_id %sys%
x+=NumGet(POINT,0)
y+=NumGet(POINT,4)
;~ ToolTip % y,0,0,2
MouseClick,,% x,% y,2
;~ ControlClick, % "x" x " y" y,ahk_id %hwnd%,,,3, Pos ;,ahk_id %sys%,,,4
Return |
_________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun  |
|
| Back to top |
|
 |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Thu Sep 03, 2009 7:47 pm Post subject: |
|
|
@HotKeyIt : thanks indeed - I will play with it and post back _________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05 |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Thu Sep 03, 2009 7:59 pm Post subject: |
|
|
This seems to work with Windows Explorer (thought Enter originally works as well) but this sends the doubleclick
But ControlClick will still not work
Includes RemoteBuf | Code: | ENTER::
hwnd:=WinExist("A")
chwnd=
ControlGet,chwnd,HWND,,SysListView321,ahk_id %hwnd%
If chwnd=
Return
ControlGetPos,x,y,,,,ahk_id %chwnd%
SendMessage,TVM_GETITEM:=0x100c,-1,3,,ahk_id %chwnd%
If ErrorLevel=4294967295
Return
VarSetCapacity(POINT,16) ;to recieve position
item:=ErrorLevel+1
size:=8
RemoteBuf_Open(hPOINT, hwnd, size)
SendMessage,LVM_GETITEMPOSITION:=0x1010,item,RemoteBuf_Get(hPOINT),SysListView321,ahk_id %hwnd%
RemoteBuf_Read(hPOINT, POINT,size)
RemoteBuf_Close(hPOINT)
x+=NumGet(POINT,0)
y+=NumGet(POINT,4)-5
ToolTip % x " . " y "." item,0,0,2
MouseClick,,% x,% y,2
;~ ControlClick, % "x" x " y" y,ahk_id %hwnd%,,,2 ;,ahk_id %chwnd%,,,4
Return
RemoteBuf_Open(ByRef H, hwnd, size) {
static MEM_COMMIT=0x1000, PAGE_READWRITE=4
WinGet, pid, PID, ahk_id %hwnd%
hProc := DllCall( "OpenProcess", "uint", 0x38, "int", 0, "uint", pid)
IfEqual, hProc,0, return A_ThisFunc "> Unable to open process (" A_LastError ")"
bufAdr := DllCall( "VirtualAllocEx", "uint", hProc, "uint", 0, "uint", size, "uint", MEM_COMMIT, "uint", PAGE_READWRITE)
IfEqual, bufAdr,0, return A_ThisFunc "> Unable to allocate memory (" A_LastError ")"
VarSetCapacity(H, 12, 0 )
NumPut( hProc, H, 0)
NumPut( size, H, 4)
NumPut( bufAdr, H, 8)
}
RemoteBuf_Close(ByRef H) {
static MEM_RELEASE = 0x8000
handle := NumGet(H, 0)
IfEqual, handle, 0, return A_ThisFunc "> Invalid remote buffer handle"
adr := NumGet(H, 8)
r := DllCall( "VirtualFreeEx", "uint", handle, "uint", adr, "uint", 0, "uint", MEM_RELEASE)
ifEqual, r, 0, return A_ThisFunc "> Unable to free memory (" A_LastError ")"
DllCall( "CloseHandle", "uint", handle )
VarSetCapacity(H, 0 )
}
RemoteBuf_Read(ByRef H, ByRef pLocal, pSize, pOffset = 0){
handle := NumGet( H, 0), size:= NumGet( H, 4), adr := NumGet( H, 8)
IfEqual, handle, 0, return A_ThisFunc "> Invalid remote buffer handle"
IfGreaterOrEqual, offset, %size%, return A_ThisFunc "> Offset is bigger then size"
VarSetCapacity( pLocal, pSize )
return DllCall( "ReadProcessMemory", "uint", handle, "uint", adr + pOffset, "uint", &pLocal, "uint", size, "uint", 0 ), VarSetCapacity(pLocal, -1)
}
RemoteBuf_Write(Byref H, byref pLocal, pSize, pOffset=0) {
handle:= NumGet( H, 0), size := NumGet( H, 4), adr := NumGet( H, 8)
IfEqual, handle, 0, return A_ThisFunc "> Invalid remote buffer handle"
IfGreaterOrEqual, offset, %size%, return A_ThisFunc "> Offset is bigger then size"
return DllCall( "WriteProcessMemory", "uint", handle,"uint", adr + pOffset,"uint", &pLocal,"uint", pSize, "uint", 0 )
}
RemoteBuf_Get(ByRef H, pQ="adr") {
return pQ = "adr" ? NumGet(H, 8) : pQ = "size" ? NumGet(H, 4) : NumGet(H)
} |
_________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun  |
|
| Back to top |
|
 |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Fri Sep 04, 2009 11:09 am Post subject: |
|
|
Yes yes this second one works - needs some tweaking maybe for my needs (and a lot of reading) - thanks a lot ! The first one probably would work on GUIs only...
I 'll come back with the tweaked code _________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05 |
|
| Back to top |
|
 |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Fri Sep 04, 2009 2:26 pm Post subject: |
|
|
Slightly modified to accommodate multiple treeviews, and only treeviews : | Code: | ENTER::
hwnd:=WinExist("A") ; this won't be needed as the shortcut will be in a "ifwinexist" hotkey command
controlgetfocus, cntrlNN ;,A
if (RegExMatch(cntrlNN, "i)syslistview32")) { ;if more than one syslistview32 are present
ControlGet,chwnd,HWND,,%cntrlNN%,ahk_id %hwnd%
If chwnd= ;maybe superfluous
Return
ControlGetPos,x,y,,,,ahk_id %chwnd%
SendMessage,TVM_GETITEM:=0x100c,-1,3,,ahk_id %chwnd% ; could you explain this a bit ? why -1 for wparam ? what is the return value ?
If ErrorLevel=4294967295
Return
VarSetCapacity(POINT,16) ;to receive position
item:=ErrorLevel+1
size:=8
RemoteBuf_Open(hPOINT, hwnd, size)
SendMessage,LVM_GETITEMPOSITION:=0x1010,item,RemoteBuf_Get(hPOINT),%cntrlNN%,ahk_id %hwnd%
RemoteBuf_Read(hPOINT, POINT,size)
RemoteBuf_Close(hPOINT)
x+=NumGet(POINT,0)
y+=NumGet(POINT,4)-5
ToolTip % x " . " y "." item,0,0,2
MouseClick,,% x,% y,2
;~ ControlClick, % "x" x " y" y,ahk_id %hwnd%,,,2 ;,ahk_id %chwnd%,,,4
chwnd=
}
Return | Thanks again - works like a charm and I think will be useful to many people  _________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05 |
|
| Back to top |
|
 |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Sat Sep 05, 2009 6:15 pm Post subject: |
|
|
Unfortunately the code above has a bug - when on the last item of the listview Enter clicks on other windows (???). I am not sure if I introduced the bug or was already in HotKeyIt's code. I'll test and post back. _________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05 |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Sat Sep 05, 2009 6:58 pm Post subject: |
|
|
Does it produce the error for you in Windows Explorer, it works fine for me?
| Code: | ENTER::
hwnd:=WinExist("A") ; this won't be needed as the shortcut will be in a "ifwinexist" hotkey command
controlgetfocus, cntrlNN ;,A
if (RegExMatch(cntrlNN, "i)syslistview32")) { ;if more than one syslistview32 are present
ControlGet,chwnd,HWND,,%cntrlNN%,ahk_id %hwnd%
ControlGetPos,x,y,,,,ahk_id %chwnd%
SendMessage,LVM_GETITEM:=0x100c,-1,3,,ahk_id %chwnd% ; http://msdn.microsoft.com/en-us/library/bb774953.aspx
item:=ErrorLevel+1 ;Line number 0 based so +1 needed
If ErrorLevel=4294967296
Return
VarSetCapacity(POINT,16) ;to receive position
RemoteBuf_Open(hPOINT, hwnd, 8)
SendMessage,LVM_GETITEMPOSITION:=0x1010,item,RemoteBuf_Get(hPOINT),%cntrlNN%,ahk_id %hwnd% ;http://msdn.microsoft.com/en-us/library/bb761048.aspx
RemoteBuf_Read(hPOINT, POINT,size),RemoteBuf_Close(hPOINT)
x+=NumGet(POINT,0)
y+=NumGet(POINT,4)-10
MouseClick,,% x,% y,2
chwnd=
}
Return |
_________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun  |
|
| Back to top |
|
 |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Sat Sep 05, 2009 7:22 pm Post subject: |
|
|
You mean on the folders view of explorer ? EDIT : you meant Explorer's list of files and folders - works fine for me also EDIT2 : no doesn't - again in a folder (containing folders) sometimes (for instance if I press enter on another folder and then on the last one - or once it works, next time not, next time again works and so on) on the last folder I get the same behavior (x coordinate explodes)- only on the last folder and on details view. On list view works fine indeed. Arranged by name.
I am checking it on a 3rd party app EDIT : checked also on defraggler - same behavior
Basically the tooltip suddenly, on the last item of the list, displays a huge x coordinate - for instance jumping from 555 (same for all the other items) to 486136363 (!). Not the same number either and not same behavior - sometimes the window stays on focus sometimes another window receives focus (obviously was double-clicked by the script). If you cannot reproduce it then probably it's my weird app. Thanks anyway
The code I used :
| Code: | ~ENTER:: ;the tilde does not make any difference - I just added it for convenience
hwnd:=WinExist("A") ; this won't be needed as the shortcut will be in a "ifwinexist" hotkey command
controlgetfocus, cntrlNN ;,A
if (RegExMatch(cntrlNN, "i)syslistview32")) { ;if more than one syslistview32 are present
ControlGet,chwnd,HWND,,%cntrlNN%,ahk_id %hwnd%
If chwnd=
Return
ControlGetPos,x,y,,,,ahk_id %chwnd%
SendMessage,TVM_GETITEM:=0x100c,-1,3,,ahk_id %chwnd%
If ErrorLevel=4294967295
Return
VarSetCapacity(POINT,16) ;to receive position
item:=ErrorLevel+1
size:=8
RemoteBuf_Open(hPOINT, hwnd, size)
SendMessage,LVM_GETITEMPOSITION:=0x1010,item,RemoteBuf_Get(hPOINT),%cntrlNN%,ahk_id %hwnd%
RemoteBuf_Read(hPOINT, POINT,size)
RemoteBuf_Close(hPOINT)
x+=NumGet(POINT,0)
y+=NumGet(POINT,4)-10 ;changed this but no difference
ToolTip % x " . " y "." item,0,0,2
MouseClick,,% x,% y,2
;~ ControlClick, % "x" x " y" y,ahk_id %hwnd%,,,2 ;,ahk_id %chwnd%,,,4
chwnd=
}
Return |
_________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05
Last edited by Mr_and_Mrs_D on Sat Sep 05, 2009 8:19 pm; edited 2 times in total |
|
| Back to top |
|
 |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Sat Sep 05, 2009 7:53 pm Post subject: |
|
|
Checked it on defraggler - again weird behavior on last item - x coordinate jumps from 11 (same as for other items) to 91 to 16011 to 19839307 back to 11 etc Which numbers do i get depends on the speed I press enter  _________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05 |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Sun Sep 06, 2009 1:53 am Post subject: |
|
|
| HotKeyIt wrote: | I can't get ControlClick to send a doubleclick, not sure why  | FYI, ControlClick fails to perform a double click ... (the short story: AutoHotkey sends two "single-clicks" not a double-click.) |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Sun Sep 06, 2009 9:07 am Post subject: |
|
|
Thanks Lexikos, I tested now on few lisviews, might work perfectly now
| Code: | ENTER::
hwnd:=WinExist("A") ; this won't be needed as the shortcut will be in a "ifwinexist" hotkey command
controlgetfocus, cntrlNN ;,A
if (RegExMatch(cntrlNN, "i)syslistview32")) { ;if more than one syslistview32 are present
ControlGet,chwnd,HWND,,%cntrlNN%,ahk_id %hwnd%
;~ ControlGetPos,x,y,,,,ahk_id %chwnd%
SendMessage,LVM_GETITEM:=0x100c,-1,3,,ahk_id %chwnd% ; http://msdn.microsoft.com/en-us/library/bb774953.aspx
item:=ErrorLevel+1 ;Line number 0 based so +1 needed
If ErrorLevel=4294967296
Return
VarSetCapacity(POINT,16) ;to receive position
RemoteBuf_Open(hPOINT, hwnd, 8)
SendMessage,LVM_GETITEMPOSITION:=0x1010,item,RemoteBuf_Get(hPOINT),%cntrlNN%,ahk_id %hwnd% ;http://msdn.microsoft.com/en-us/library/bb761048.aspx
RemoteBuf_Read(hPOINT, POINT,size),RemoteBuf_Close(hPOINT)
x:=NumGet(POINT,0)
y:=NumGet(POINT,4)-10
PostMessage, 0x86, 0, ,, ahk_id %chwnd% ; WM_NCACTIVATE
PostMessage, 0x201, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONDOWN
PostMessage, 0x202, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONUP
PostMessage, 0x203, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONDBLCLCK
PostMessage, 0x202, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONUP
chwnd=
}
Return |
Edit:
Small fix implemented, so it also works when mouse does not hover the listview _________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun  |
|
| Back to top |
|
 |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Sun Sep 06, 2009 6:09 pm Post subject: |
|
|
Thanks ! Great improvement - but still in details view in explorer, the last item on the list produces a huge x-coordinate - check the tooltip in the code below. Also same problem in third party apps but not on all syslistviews - not sure yet why.
| Code: | ~ENTER::
hwnd:=WinExist("A") ; this won't be needed as the shortcut will be in a "ifwinexist" hotkey command
controlgetfocus, cntrlNN ;,A
if (RegExMatch(cntrlNN, "i)syslistview32")) { ;if more than one syslistview32 are present
ControlGet,chwnd,HWND,,%cntrlNN%,ahk_id %hwnd%
;~ ControlGetPos,x,y,,,,ahk_id %chwnd%
SendMessage,LVM_GETITEM:=0x100c,-1,3,,ahk_id %chwnd% ; http://msdn.microsoft.com/en-us/library/bb774953.aspx
item:=ErrorLevel+1 ;Line number 0 based so +1 needed
If ErrorLevel=4294967296
Return
VarSetCapacity(POINT,16) ;to receive position
RemoteBuf_Open(hPOINT, hwnd, 8)
SendMessage,LVM_GETITEMPOSITION:=0x1010,item,RemoteBuf_Get(hPOINT),%cntrlNN%,ahk_id %hwnd% ;http://msdn.microsoft.com/en-us/library/bb761048.aspx
RemoteBuf_Read(hPOINT, POINT,size),RemoteBuf_Close(hPOINT)
x:=NumGet(POINT,0)
y:=NumGet(POINT,4)-10
PostMessage, 0x86, 0, ,, ahk_id %chwnd% ; WM_NCACTIVATE
PostMessage, 0x201, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONDOWN
PostMessage, 0x202, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONUP
PostMessage, 0x203, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONDBLCLCK
PostMessage, 0x202, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONUP
tooltip x=%x% . y=%y%
chwnd=
}
Return |
_________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05 |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Sun Sep 06, 2009 8:43 pm Post subject: |
|
|
I've got it | Code: | ~ENTER::
hwnd:=WinExist("A") ; this won't be needed as the shortcut will be in a "ifwinexist" hotkey command
controlgetfocus, cntrlNN ;,A
if (RegExMatch(cntrlNN, "i)syslistview32")) { ;if more than one syslistview32 are present
ControlGet,chwnd,HWND,,%cntrlNN%,ahk_id %hwnd%
;~ ControlGetPos,x,y,,,,ahk_id %chwnd%
SendMessage,LVM_GETITEMNEXT:=0x100c,-1,3,,ahk_id %chwnd% ; http://msdn.microsoft.com/en-us/library/bb761057.aspx
item:=ErrorLevel
If ErrorLevel=4294967296
Return
VarSetCapacity(POINT,16) ;to receive position
RemoteBuf_Open(hPOINT, hwnd, 8)
SendMessage,LVM_GETITEMPOSITION:=0x1010,item,RemoteBuf_Get(hPOINT),%cntrlNN%,ahk_id %hwnd% ;http://msdn.microsoft.com/en-us/library/bb761048.aspx
RemoteBuf_Read(hPOINT, POINT,size),RemoteBuf_Close(hPOINT)
x:=NumGet(POINT,0)
y:=NumGet(POINT,4)
PostMessage, 0x86, 0, ,, ahk_id %chwnd% ; WM_NCACTIVATE
PostMessage, 0x201, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONDOWN
PostMessage, 0x202, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONUP
PostMessage, 0x203, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONDBLCLCK
PostMessage, 0x202, 0, X&0xFFFF | Y<<16,, ahk_id %chwnd% ; WM_LBUTTONUP
tooltip x=%x% . y=%y% : %item%
chwnd=
}
Return |
_________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun 
Last edited by HotKeyIt on Mon Sep 07, 2009 7:09 pm; edited 2 times in total |
|
| Back to top |
|
 |
Mr_and_Mrs_D
Joined: 19 Dec 2006 Posts: 164
|
Posted: Mon Sep 07, 2009 9:22 am Post subject: |
|
|
Thanks so much !! I dedicate my 100th post to you !! Perfect
As for the msdn links - I had checked them already, but still don't understand the LVITEM thing - shouldn't the wparam be 0 (while here it is -1) ?
I think I have to do (much) more googlework lol
Thanks again and I will be sure to credit you once I finish my script  _________________ XP SP3 Pro x32 / 7 x64 Pro - AHK 1.0.48.05 |
|
| 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
|