lemony Posted May 16, 2008 Share Posted May 16, 2008 (edited) Hey guys, please check out my code (posted below). I need to be able to somehow get the text of the listbox item on a mouseover. I can do it "on click", but I have no idea what to do for "on mouseover". Please help if you can. Thanks! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GuiListBox.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 418, 356, 410, 474) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $List1 = GUICtrlCreateList("", 8, 8, 401, 214) GUICtrlSetData($List1, "Item #01|Item #02|Item #03|Item #04|Item #05|Item #06|Item #07|Item #08|Item #09|Item #10") GUICtrlSetOnEvent($List1, "List1Click") $Label1 = GUICtrlCreateLabel("Shows selected listbox item:", 8, 232, 136, 17) $Label2 = GUICtrlCreateLabel("Needs to show the listbox item that the mouse is currently hovered over:", 8, 296, 342, 17) $Input1 = GUICtrlCreateInput("", 8, 256, 401, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) $Input2 = GUICtrlCreateInput("How can this be done?", 8, 320, 401, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Form1Close() Exit EndFunc Func List1Click() GUICtrlSetData($Input1, _GUICtrlListBox_GetText($List1, _GUICtrlListBox_GetCurSel($List1))) EndFunc Edited May 16, 2008 by lemony Link to comment Share on other sites More sharing options...
Eigensheep Posted May 16, 2008 Share Posted May 16, 2008 This seems to work for me: GUICreate("My GUI Window",900,500) GUISetState() While 1 AutoItSetOption("MouseCoordMode",0) $x1 = ;left hand side of mouseover area (+ left border of GUI) $x2 = ;right hand side of mouseover area (+ left border of GUI) $y1 = ;top side of mouseover area (+ top border of GUI) $y2 = ;bottom side of mouseover area (+ top border of GUI) If MouseGetPos(0) > $x1 and MouseGetPos(0) < $x2 and MouseGetPos(1) > $y1 and MouseGetPos(1) < $y2 Then MsgBox(64,"Info","MouseOver!!") EndIf Wend But it might make larger GUIs slower. I hope this helps. jimmy123j 1 Link to comment Share on other sites More sharing options...
lemony Posted May 16, 2008 Author Share Posted May 16, 2008 Hey NumberDaemon, thanks for your reply. I know what you are trying to show me but unfortunately that method does not help me. In that script I posted, the same action that occurs when you click the listbox items needs to happen when hovering over (mousing over) the listbox items instead. I need an elegant solution if anyone knows one. Thanks! Link to comment Share on other sites More sharing options...
Siao Posted May 16, 2008 Share Posted May 16, 2008 (edited) Add these to your example: GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "On_MOUSEMOVE") Func On_MOUSEMOVE() Local $aCI = GUIGetCursorInfo(), $aCtrlPos, $x, $sText = "" If @error Or $aCI[4] <> $List1 Then Return GUICtrlSetData($Input2, $sText) $aCtrlPos = ControlGetPos(@GUI_WinHandle, "", $aCI[4]) $x = _GUICtrlListBox_ItemFromPoint($aCI[4], $aCI[0]-$aCtrlPos[0], $aCI[1]-$aCtrlPos[1]) If $x > -1 Then $sText = _GUICtrlListBox_GetText($aCI[4], $x) GUICtrlSetData($Input2, $sText) EndFunc Edited May 16, 2008 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
lemony Posted May 17, 2008 Author Share Posted May 17, 2008 WOW.. just WOW. That's brilliant Siao Thanks a lot! Great job! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now