tomashen Posted November 19, 2011 Share Posted November 19, 2011 i dont know how to search and i cant find anything like this ^^ but wat i wana do is when mouse is hovered over button then create another button at bottom of it and while its active keep checking if mouse cord is in that area if not then delete the button below wat i got is while $MOUSE_RECORD[0] > 154 & $MOUSE_RECORD[1] > 100 $TEST=GUICtrlCreatePic("",0, 25, 154, 15) _ResourceSetImageToCtrl(-1, "APPLICATION1") WEnd GUICtrlDelete($TEST) Proud of AutoIt Proud of MySelf :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 19, 2011 Moderators Share Posted November 19, 2011 tomashen, There are many ways to do this, butthis is probably the simplest: expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hButton = GUICtrlCreateButton("Test", 10, 10, 80, 30) $hPic = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\mslogo.jpg", 10, 60, 200, 40) GUICtrlSetState(-1, $GUI_HIDE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Check what is under the cursor $aCInfo = GUIGetCursorInfo() ; If it is the button If $aCinfo[4] = $hButton Then ; Check if picture is hidden If BitAnd(GUICtrlGetState($hPic), $GUI_HIDE) Then ; if so then show it GUICtrlSetState($hPic, $GUI_SHOW) EndIf ; If it is not the button Else ; Check if picture is showing If BitAnd(GUICtrlGetState($hPic), $GUI_SHOW) Then ; If so then hide it GUICtrlSetState($hPic, $GUI_HIDE) EndIf EndIf WEnd You need the slightly complicated hide/show code or you get a lot of flashing as the picture is constantly reshown. All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tomashen Posted November 19, 2011 Author Share Posted November 19, 2011 (edited) epic would of never tought of using GuiGetCursorInfo() thank you very much and about hide/show haha i used GuiCtrlDelete()and that why sometimes i get flashings going on thnx again but uh , how can i make this to be like the image would stay showen if mouse is hovered on the iamge too...like read mouse cord in certain area..if its not in the area then hide the image :/ im tring to figure it out but finding it rly hard lol Edited November 19, 2011 by tomashen Proud of AutoIt Proud of MySelf :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 19, 2011 Moderators Share Posted November 19, 2011 tomashen, This looks for the mouse in a defined area: expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> ; Use Client Area coordinates - so we can use the same reference frame as the normal controls Opt("MouseCoordMode", 2) ; Define the area Global $iL = 10, $iT = 10, $iW = 200, $iH = 90 $hGUI = GUICreate("Test", 500, 500) ; This is just to show the are we are loking at - you do NOT need to for the code to work GUICtrlCreateLabel("", $iL, $iT, $iW, $iH) GUICtrlSetBkColor(-1, 0xFFCCCC) GUICtrlSetState(-1, $GUI_DISABLE) $hButton = GUICtrlCreateButton("Test", 10, 10, 80, 30) $hPic = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\mslogo.jpg", 10, 60, 200, 40) GUICtrlSetState(-1, $GUI_HIDE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aMPos = MouseGetPos() ; Is the mouse in the rectangle If _WinAPI_PtInRectEx($aMPos[0], $aMPos[1], $iL, $iT, $iL+ $iW, $iT + $iH) Then ; Check if picture is hidden If BitAnd(GUICtrlGetState($hPic), $GUI_HIDE) Then ; if so then show it GUICtrlSetState($hPic, $GUI_SHOW) EndIf ; If it is not the button Else ; Check if picture is showing If BitAnd(GUICtrlGetState($hPic), $GUI_SHOW) Then ; If so then hide it GUICtrlSetState($hPic, $GUI_HIDE) EndIf EndIf WEnd Func _WinAPI_PtInRectEx($iX, $iY, $iLeft, $iTop, $iRight, $iBottom) Local $aResult Local $tRect = DllStructCreate($tagRECT) DllStructSetData($tRect, "Left", $iLeft) DllStructSetData($tRect, "Top", $iTop) DllStructSetData($tRect, "Right", $iRight) DllStructSetData($tRect, "Bottom", $iBottom) $aResult = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY) If @error Then Return SetError(@error, 0, False) Return $aResult[0] <> 0 EndFunc ;==>_WinAPI_PtInRectEx As explained the code, you do not need the label - it is just there to show the extent of the area we examine. Better? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tomashen Posted November 19, 2011 Author Share Posted November 19, 2011 umm that _WinAPI_PtInRectEx i do not get it yet but with time ill understand it i hope but yea i tested this modified it a bit for my needs and works like a charm thnx very much ! ild kiss u if i could Proud of AutoIt Proud of MySelf :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 19, 2011 Moderators Share Posted November 19, 2011 tomashen,ild kiss u if i couldJust as well you cannot as I am sure my wife would not approve at all! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tomashen Posted November 19, 2011 Author Share Posted November 19, 2011 heh well thnx very much tho (handshake) Proud of AutoIt Proud of MySelf :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 19, 2011 Moderators Share Posted November 19, 2011 tomashen, (handshake) Thank you - glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tomashen Posted November 19, 2011 Author Share Posted November 19, 2011 umm i keep getting this error if i Alt+Tab out of the app (94) : ==> Subscript used with non-Array variable.: If $CURSOR_GET_PLACE_ON_BUTTON[4] = $APPLICATIONS Then If $CURSOR_GET_PLACE_ON_BUTTON^ ERROR i dont get wats wrong lmao.. tryed putting $CURSOR_GET_PLACE_ON_BUTTON in global and in global const but still error Proud of AutoIt Proud of MySelf :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 19, 2011 Moderators Share Posted November 19, 2011 tomashen,The GUI is no longer active when you use Alt-Tab and so you do not get a valid array returned from GUIGetCursorInfo. Just add some errorchecking like this :If IsArray($CURSOR_GET_PLACE_ON_BUTTON) And $CURSOR_GET_PLACE_ON_BUTTON[4] = $APPLICATIONS ThenNow if no array is returned, the crash will not occur. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tomashen Posted November 19, 2011 Author Share Posted November 19, 2011 ah ill knw this the next time now thnx once more! also is there a way to make the GUI work when its not active.. like um when its not active if i move my cursor on a button an image will appear so its like as if the gui is inactive but it still works.. like "sleep walking" i was thinking of using "AlwaysOnTop" or sumtin like that but i doubt that would help Proud of AutoIt Proud of MySelf :) 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