biase Posted October 15, 2012 Share Posted October 15, 2012 I have a gui which hidden on the right screen, and it will slide out from right to left if the mouse is hovered at the right screen, but I'm having trouble with slide in which will hide the gui back to the right screen. I've tried for 3 hours making it to works but failed.Hope some one can help me and make a good use of this piece of codeexpandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #NoTrayIcon Global $sout = False $Main = GUICreate("Slider", 500, (@DesktopHeight - _TaskBarHeight()), @DesktopWidth, -1, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $BgPic = GUICtrlCreatePic('background.jpg', 0, 0, 0, 0) GUICtrlSetState($BgPic, $GUI_DISABLE) GUISetState(@SW_HIDE, $Main) While 1 * Sleep(100) $nMsg = GUIGetMsg(1) $MPos = MouseGetPos() $GPos = WinGetClientSize($Main) Select Case $nMsg[0] = -3 Exit EndSelect If $MPos[0] >= (@DesktopWidth - 1) Then If Not $sout Then $sout = True ;WinMove($Main, "", (@DesktopWidth - $GPos[0]), 0, $GPos[0], @DesktopHeight, 2) WinMove($Main, "", (@DesktopWidth - $GPos[0]), 0) WinSetTrans($Main, 0, 235) WinSetOnTop($Main, "", 1) Else DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Main, "int", 270, "long", 0x00040002);slide in from right = show GUISetState(@SW_SHOW, $Main) EndIf EndIf If Not _isGuiHover() Then If $sout Then $sout = False ;WinMove($Main, "", @DesktopWidth, 0, $GPos[0], @DesktopHeight, 2) WinMove($Main, "", @DesktopWidth, 0) WinSetOnTop($Main, "", 0) Else DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Main, "int", 270, "long", 0x00050002);slide out to left = hide GUISetState(@SW_HIDE, $Main) EndIf EndIf WEnd Func _isGuiHover() Local $m = MouseGetPos(), $p = WinGetPos($Main) If $m[0] > $p[0] Then Return 1 Else Return 0 EndIf EndFunc ;==>_isGuiHover Func _TaskBarHeight() Local $aPos = WinGetPos("[CLASS:Shell_TrayWnd; W:" & @DesktopWidth & "]") Return $aPos[3] EndFunc ;==>_TaskBarHeightBelow are the file with the images i useSlide.rar Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 15, 2012 Moderators Share Posted October 15, 2012 biase, You were overcomplicating things - and you misunderstood the slide in/out directions (they are not easy to interpret): Try this: #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Global $sout = False $Main = GUICreate("Slider", 500, (@DesktopHeight - _TaskBarHeight()), @DesktopWidth - 500, -1, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $BgPic = GUICtrlCreatePic('background.jpg', 0, 0, 0, 0) GUICtrlSetState($BgPic, $GUI_DISABLE) While 1 $nMsg = GUIGetMsg() $MPos = MouseGetPos() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $MPos[0] >= (@DesktopWidth - 1) And Not $sout $sout = True DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Main, "int", 270, "long", 0x00040002) ; $AW_SLIDE_IN_RIGHT Case $MPos[0] < (@DesktopWidth - 500) And $sout $sout = False DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Main, "int", 270, "long", 0x00050001) ; $AW_SLIDE_OUT_RIGHT EndSelect WEnd Func _TaskBarHeight() Local $aPos = WinGetPos("[CLASS:Shell_TrayWnd; W:" & @DesktopWidth & "]") Return $aPos[3] EndFunc ;==>_TaskBarHeight Any better? M23 biase 1 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...
biase Posted October 15, 2012 Author Share Posted October 15, 2012 Thanks alot, it works like a charm and the code much smaller.You're correct about the "misunderstood the slide directions". It's give me a headcahe once... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 15, 2012 Moderators Share Posted October 15, 2012 biase,You're correct about the "misunderstood the slide directions". It's give me a headcahe once...Me too the first time - and I still have to check now! 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...
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