Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ? Topic is solved
-
- Posts: 20
- Joined: 02 Aug 2017, 06:33
Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
I have TreeView (TreeViewWndClass1) where i have selected one item using Keyboard keys (up n down) and at there i need right click to open context menu. I don't want to use mouse to get coordinates. Can anybody help me out ? problem is that Appskey doesn't work and no other shortcut are there. only way i found is to get coordinates and use MouseClick Right {x} {y}
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
AccViewer appears to be able to do this for standard treeview controls created in AHK GUIs. So it might work for your control:
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 20
- Joined: 02 Aug 2017, 06:33
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
Vh_ wrote:ControlGetPos command.
i tried but ControlGetPos doesn't get coordinates of selected text from TreeView. if you have example , could you please show me
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
You may be able to use the following command.
Control, TabLeft, 1, TreeView, WinTitle
Control, TabLeft, 1, TreeView, WinTitle
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
you could also try the tree view with ControlGetPos, and then when you click X and Y, you do Click X+25, Y.
-
- Posts: 20
- Joined: 02 Aug 2017, 06:33
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
what does this script do ?Vh_ wrote:You may be able to use the following command.
Control, TabLeft, 1, TreeView, WinTitle
-
- Posts: 20
- Joined: 02 Aug 2017, 06:33
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
What shall i achieve by using this script ?jeeswg wrote:AccViewer appears to be able to do this for standard treeview controls created in AHK GUIs. So it might work for your control:
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
Try it.
Spoiler
Some example code:
Code: Select all
q:: ;get item coordinates/text from a treeview control
ControlGet, hCtl, Hwnd,, SysTreeView321, A
vOutput := ""
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hCtl)
Loop, % oAcc.accChildCount
{
oRect := Acc_Location(oAcc, A_Index)
vOutput .= oRect.x " " oRect.y " " oRect.w " " oRect.h "`t" oAcc.AccName(A_Index) "`r`n"
}
oAcc := oRect := ""
Clipboard := vOutput
MsgBox, % vOutput
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 20
- Joined: 02 Aug 2017, 06:33
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ? Topic is solved
Thumb Up... thanks a bunch.. this coordinates helped me a lot.jeeswg wrote:Try it.SpoilerSome example code:Code: Select all
q:: ;get item coordinates/text from a treeview control ControlGet, hCtl, Hwnd,, SysTreeView321, A vOutput := "" oAcc := Acc_Get("Object", "4", 0, "ahk_id " hCtl) Loop, % oAcc.accChildCount { oRect := Acc_Location(oAcc, A_Index) vOutput .= oRect.x " " oRect.y " " oRect.w " " oRect.h "`t" oAcc.AccName(A_Index) "`r`n" } oAcc := oRect := "" Clipboard := vOutput MsgBox, % vOutput return
Re: Is it possible to get coordinates of selected item in TreeView (TreeViewWndClass1) control ?
I dont understandjeeswg wrote:Try it.
Some example code:Code: Select all
q:: ;get item coordinates/text from a treeview control ControlGet, hCtl, Hwnd,, SysTreeView321, A vOutput := "" oAcc := Acc_Get("Object", "4", 0, "ahk_id " hCtl) Loop, % oAcc.accChildCount { oRect := Acc_Location(oAcc, A_Index) vOutput .= oRect.x " " oRect.y " " oRect.w " " oRect.h "`t" oAcc.AccName(A_Index) "`r`n" } oAcc := oRect := "" Clipboard := vOutput MsgBox, % vOutput return
I am trying to run this on the followin treeview but it doesnt display anything
Code: Select all
Gui, Add, TreeView
P1 := TV_Add("First parent")
P1C1 := TV_Add("Parent 1's first child", P1) ; Specify P1 to be this item's parent.
P2 := TV_Add("Second parent")
P2C1 := TV_Add("Parent 2's first child", P2)
P2C2 := TV_Add("Parent 2's second child", P2)
P2C2C1 := TV_Add("Child 2's first child", P2C2)
Gui, Show ; Show the window and its TreeView.
return
GuiClose: ; Exit the script when the user closes the TreeView's GUI window.
ExitApp
Who is online
Users browsing this forum: No registered users and 186 guests