oMBRa Posted August 20, 2008 Share Posted August 20, 2008 I make a script that creates a window that follow my mouse cursor, but when i reach the bottom of the desktop the window disappear, so I have to make the window go up to the mouse when it disappears. How to do it? ( like how does Magnify of autoitt info tool) Link to comment Share on other sites More sharing options...
JFee Posted August 20, 2008 Share Posted August 20, 2008 Check to see if the Y position of the window is greater than the desktop height - height of window and act accordingly Regards,Josh Link to comment Share on other sites More sharing options...
oMBRa Posted August 20, 2008 Author Share Posted August 20, 2008 I did but then the window move up to the mouse and then come down again.. this is the script: #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <ScreenCapture.au3> HotKeySet("{F2}", "Chiudi") Opt('MustDeclareVars', 1) _Main() Func _Main() Sleep(10) Local $hGUI1, $hGUI2, $hImage, $hGraphic1, $hGraphic2,$PosM,$PosW $hGUI2 = GUICreate("Zoomed", 400, 300, 0, 400, -1, $WS_EX_TOPMOST) GUISetState() _GDIPlus_Startup () Do $PosM = MouseGetPos() _ScreenCapture_Capture (@DesktopDir & "\GDIPlus_Image.jpg",$PosM[0] - 100,$PosM[1] - 100,$PosM[0] + 100,$PosM[1] + 100, False) $hImage = _GDIPlus_ImageLoadFromFile (@DesktopDir & "\GDIPlus_Image.jpg") $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND ($hGUI2) _GDIPlus_GraphicsDrawImageRectRect ($hGraphic2, $hImage, 0, 0, 200, 200, 0, 0, 400, 300) _GDIPlus_GraphicsDispose ($hGraphic2) _GDIPlus_ImageDispose ($hImage) $PosW = WinGetPos("Zoomed") WinMove("Zoomed", "",$PosM[0] + 100,$PosM[1] + 100) Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc Func Chiudi() _GDIPlus_Shutdown () FileDelete(@DesktopDir& "\GDIPlus_Image.jpg") Exit EndFunc Link to comment Share on other sites More sharing options...
maxlarue Posted August 21, 2008 Share Posted August 21, 2008 (edited) I did but then the window move up to the mouse and then come down again.. this is the script: #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <ScreenCapture.au3> HotKeySet("{F2}", "Chiudi") Opt('MustDeclareVars', 1) _Main() Func _Main() Sleep(10) Local $hGUI1, $hGUI2, $hImage, $hGraphic1, $hGraphic2,$PosM,$PosW $hGUI2 = GUICreate("Zoomed", 400, 300, 0, 400, -1, $WS_EX_TOPMOST) GUISetState() _GDIPlus_Startup () Do $PosM = MouseGetPos() _ScreenCapture_Capture (@DesktopDir & "\GDIPlus_Image.jpg",$PosM[0] - 100,$PosM[1] - 100,$PosM[0] + 100,$PosM[1] + 100, False) $hImage = _GDIPlus_ImageLoadFromFile (@DesktopDir & "\GDIPlus_Image.jpg") $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND ($hGUI2) _GDIPlus_GraphicsDrawImageRectRect ($hGraphic2, $hImage, 0, 0, 200, 200, 0, 0, 400, 300) _GDIPlus_GraphicsDispose ($hGraphic2) _GDIPlus_ImageDispose ($hImage) $PosW = WinGetPos("Zoomed") WinMove("Zoomed", "",$PosM[0] + 100,$PosM[1] + 100) Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc Func Chiudi() _GDIPlus_Shutdown () FileDelete(@DesktopDir& "\GDIPlus_Image.jpg") Exit EndFunc expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <ScreenCapture.au3> HotKeySet("{F2}", "Chiudi") Opt('MustDeclareVars', 1) _Main() Func _Main() Sleep(10) Local $hGUI1, $hGUI2, $hImage, $hGraphic1, $hGraphic2,$PosM,$PosW,$xvar,$yvar;<<<<2 extra variables $hGUI2 = GUICreate("Zoomed", 400, 300, 0, 400, -1, $WS_EX_TOPMOST) GUISetState() _GDIPlus_Startup () Do $PosM = MouseGetPos() _ScreenCapture_Capture (@DesktopDir & "\GDIPlus_Image.jpg",$PosM[0] - 100,$PosM[1] - 100,$PosM[0] + 100,$PosM[1] + 100, False) $hImage = _GDIPlus_ImageLoadFromFile (@DesktopDir & "\GDIPlus_Image.jpg") $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND ($hGUI2) _GDIPlus_GraphicsDrawImageRectRect ($hGraphic2, $hImage, 0, 0, 200, 200, 0, 0, 400, 300) _GDIPlus_GraphicsDispose ($hGraphic2) _GDIPlus_ImageDispose ($hImage) $PosW = WinGetPos("Zoomed") ;___________________added code here____________________________ if $PosM[0] + 100 + 400 > @DesktopWidth Then $xvar = @DesktopWidth - 400 Else $xvar = $PosM[0] + 100 EndIf if $PosM[1] + 100 + 300 > @DesktopHeight Then $yvar = @DesktopHeight - 300 Else $yvar = $PosM[1] + 100 EndIf ;______________________________________________________________ WinMove("Zoomed", "",$xvar,$yvar) Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc Func Chiudi() _GDIPlus_Shutdown () FileDelete(@DesktopDir& "\GDIPlus_Image.jpg") Exit EndFunc This fixes it, but don't grade it based on style Edited August 21, 2008 by maxlarue 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