 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
infogulch
Joined: 27 Mar 2008 Posts: 184
|
Posted: Sat May 10, 2008 2:12 am Post subject: [solved] Get the Coord of the selected Listview Item |
|
|
Edit: it's actually not completely solved, but I now have a reasonable and satisfying workaround.
Is it possible to get the X and Y coordinates of the currently selected listview item? A_CaretX and Y get the top of the control, so that won't work.. ideas?
 _________________
A great Beginner's Tutorial
Last edited by infogulch on Sat May 10, 2008 1:56 pm; edited 1 time in total |
|
| Back to top |
|
 |
Mkbailey755
Joined: 20 Aug 2007 Posts: 178
|
Posted: Sat May 10, 2008 4:09 am Post subject: |
|
|
| Code: |
SendMessage, 0x188, 0, 0, ListBox1, WinTitle ; 0x188 is LB_GETCURSEL (for a ListBox).
ChoicePos = %ErrorLevel% ; It will be -1 if there is no item selected.
ChoicePos += 1 ; Convert from 0-based to 1-based, i.e. so that the first item is known as 1, not 0.
Mousemove = %Error Level%
MouseGetPos, xpos, ypos
Msgbox, The Listview is at X%xpos% Y%ypos%.
|
I think that should help Untested as I dont have any listboxes to test
Edit:Maybe ControlGetFocus Im kinda tired someone will correct me
Last edited by Mkbailey755 on Sat May 10, 2008 4:29 am; edited 1 time in total |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 139
|
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 184
|
Posted: Sat May 10, 2008 4:59 am Post subject: |
|
|
I found a workaround. The mouse pos won't work because people can scroll thru a listbox with their arrow keys, and i wanted to support that. What my goal is, is to display a second gui right over the existing one to edit the selected row. If I use the GuiContextMenu: label, that gives A_GuiX and Y where the menu is supposed to appear.(or in my case the editor gui) Here's how it works right now:
| Code: | ;...
Gui, 1: Show
Gui, 1: +LastFoundExist
GuiID := "ahk_id" . WinExist()
;...
;...
GuiContextMenu:
;...
WinGetPos, Gui1X, Gui1Y,,, %GuiID%
DispX := Gui1X + 5 ;right off the edge of the window
DispY := A_GuiY + Gui1Y + 5 ;just below the list item (for me anyway)
Gui, 2:Show, X%DispX% Y%DispY%
return
;(i know, var naming isn't one of my strong points. :P) |
I originally wanted it to work with double click, but right click works ok. Actually I could make double click invoke the apps key, so maybe that'll work after all.
Thanks for your help
Edit-------:
I just figured out something that works almost exactly how I wanted it:
| Code: | Gui, 1:Add, ListView, r30 w600 -Multi gDoubleClick, Num|Description|X Var ;...
;...
Gui, 1: Show
Gui, 1: +LastFoundExist
GuiID := "ahk_id" . WinExist()
;...
DoubleClick:
If A_GuiEvent = DoubleClick
Send {AppsKey}
return
PressApps:
Send {AppsKey}
return
GuiContextMenu:
If A_GuiEvent = RightClick
{
SetTimer, PressApps, -2
Exit
}
;...
WinGetPos, GuiX, GuiY,,, %GuiID%
DispX := GuiX + 5
DispY := A_GuiY + GuiY + 5
Gui, 2:Show, X%DispX% Y%DispY%
return |
So now, whenever the user right clicks, double clicks, or presses the apps key, the apps key is sent, and I get a reliable A_GuiX and Y in relation to the currently selected item. Cool.  _________________
A great Beginner's Tutorial |
|
| 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
|