AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[solved] Get the Coord of the selected Listview Item

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
infogulch



Joined: 27 Mar 2008
Posts: 184

PostPosted: Sat May 10, 2008 2:12 am    Post subject: [solved] Get the Coord of the selected Listview Item Reply with quote

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?

Smile
_________________
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
View user's profile Send private message
Mkbailey755



Joined: 20 Aug 2007
Posts: 178

PostPosted: Sat May 10, 2008 4:09 am    Post subject: Reply with quote

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
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 139

PostPosted: Sat May 10, 2008 4:12 am    Post subject: Reply with quote

AU3 Spy? MouseGetPos? The AHK Window Info utility? You have a lot of options.
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 184

PostPosted: Sat May 10, 2008 4:59 am    Post subject: Reply with quote

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. Smile
Thanks for your help Very Happy

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. Very Happy
_________________
A great Beginner's Tutorial
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group