Sign in to follow this  
Followers 0
Sub

Delete GUI image window

3 posts in this topic

#1 ·  Posted (edited)

Hi, Im trying to research the GUI side of Autoit and I made this little hotkey from snipits of scripts Ive seen on these forums that creates a picture and displays it on the screen. What problem I am having is I dont know exactly how to delete this window if I press the hotkey multiple times. Without deleting it, the script just makes multiple GUI windows.

This takes a picture at the mouse location called "shot.bmp" then displays it lower on your desktop. I just dont know how exactly to delete this window.

#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>


HotKeySet("{F8}", "Pic")
HotKeySet("{F11}","Terminate")

Local $GUIwidth = _GDIPlus_ImageGetWidth("Shot.bmp")
Local $GUIheight = _GDIPlus_ImageGetHeight("Shot.bmp")



Func Pic()
$pos = MouseGetPos()
_ScreenCapture_SetBMPFormat(0)
_ScreenCapture_Capture("Shot.bmp", $pos[0], $pos[1], $pos[0] + 30, $pos[1] + 30, 1)
$gui = GUICreate("", 150, 80, (@DesktopWidth/2)-100,@DesktopHeight-200,$WS_POPUP,$WS_EX_TOPMOST)
GUICtrlCreatePic("shot.bmp", 0, 0, $GUIwidth, $GUIheight)
GUISetState(@SW_SHOW)
EndFunc

while 1
sleep(10)
WEnd

Func Terminate()
Exit 0
EndFunc
Edited by Sub

Share this post


Link to post
Share on other sites



This could be a way:

#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

HotKeySet("{F8}", "Pic")
HotKeySet("{F11}","Terminate")

Func Pic()
    Static $bFirst = True
    Static $hPic
    $pos = MouseGetPos()
    _ScreenCapture_SetBMPFormat(0)
    _ScreenCapture_Capture("Shot.bmp", $pos[0], $pos[1], $pos[0] + 30, $pos[1] + 30, 1)
    If $bFirst Then
        $gui = GUICreate("", 30, 30, (@DesktopWidth/2)-100,@DesktopHeight-200,$WS_POPUP,$WS_EX_TOPMOST)
        $hPic = GUICtrlCreatePic("shot.bmp", 0, 0, 30, 30)
        GUISetState(@SW_SHOW)
        $bFirst = False
    Else
        GUICtrlSetImage($hPic,"shot.bmp")
    EndIf
EndFunc

while True
    Sleep(10)
WEnd

Func Terminate()
    Exit 0
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Or this:

#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>


HotKeySet("{F8}", "Pic")
HotKeySet("{F11}","Terminate")

$gui = GUICreate("", 150, 80, (@DesktopWidth/2)-100,@DesktopHeight-200,$WS_POPUP,$WS_EX_TOPMOST)
$idPic = GUICtrlCreatePic("shot.bmp", 0, 0, 0, 0)
GUISetState(@SW_SHOW)


Func Pic()
$pos = MouseGetPos()
_ScreenCapture_SetBMPFormat(0)
_ScreenCapture_Capture("Shot.bmp", $pos[0], $pos[1], $pos[0] + 30, $pos[1] + 30, 0)
GUICtrlSetImage($idPic, "shot.bmp")
EndFunc

while 1
sleep(10)
WEnd

Func Terminate()
Exit 0
EndFunc

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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  
Followers 0