Jump to content
Sign in to follow this  
Kohr

Close magnify that is in a function

Recommended Posts

I am trying to use the code made by Larry (and others) that uses the magnifier. The main difference is that I want to use it like a function where I can turn it on/off. My current method stops using the magnifier but it leaves it on the screen. How can I get rid of it?

Kohr

example code

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global $SRCCOPY = 0x00CC0020
Global $leave = 0

HotKeySet("{PAUSE}","leave")
HotKeySet("{HOME}","MAG")

$main = GUICreate("a",100,100)
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked")

While 1
    Sleep(100)
WEnd

Func MAG()
    SplashTextOn ( "AU3MAG", "" , 100 , 100 , 0, 0, 1 )
    $MyhWnd = WinGetHandle("AU3MAG")
    While Not $leave
      $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
      If @error Then Return
      $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
      If Not @error Then
         $xy = MouseGetPos()
         If Not @error Then
            $l = $xy[0]-10
            $t = $xy[1]-10
            DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int", _
                        0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int", _
                        $l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
         EndIf
         DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
      EndIf
      DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
    WEnd
    Return
EndFunc

Func leave()
  $leave = 1
EndFunc
Func CloseClicked()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global $SRCCOPY = 0x00CC0020
Global $leave = "" ; <------ Changed

HotKeySet("{PAUSE}","leave")
HotKeySet("{HOME}","MAG")

$main = GUICreate("a",100,100)
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked")

While 1
    Sleep(100)
WEnd

Func MAG()
    $Leave=0 ; <---- Added
    SplashTextOn ( "AU3MAG", "" , 100 , 100 , 0, 0, 1 )
    $MyhWnd = WinGetHandle("AU3MAG")
    While Not $leave
      $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
      If @error Then Return
      $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
      If Not @error Then
         $xy = MouseGetPos()
         If Not @error Then
            $l = $xy[0]-10
            $t = $xy[1]-10
            DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int", _
                        0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int", _
                        $l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
         EndIf
         DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
      EndIf
      DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
    WEnd
    Return
EndFunc

Func leave()
  $leave = 1
  SplashOff() ; <------ Added
EndFunc
Func CloseClicked()
    Exit
EndFunc

Edit

Modified to enable restarting magnify

Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...