Jump to content

Recommended Posts

Hello,

I have this code :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$TESTExit = GUICreate("EXITTest", 275, 250, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU))
$AltF4 = GUICtrlCreateLabel("Press ALT+F4 to exit", 10, 210)
$ContextMenu = GUICtrlCreateContextMenu()
$ContextMenuExit = GUICtrlCreateMenuItem("Exit", $ContextMenu)
$FileMenu = GUICtrlCreateMenu("&File")
$FileExit = GUICtrlCreateMenuItem("Exit", $FileMenu)
$Button = GUICtrlCreateButton("Exit", 150, 20, 100, 24)
GUISetState(@SW_SHOW, $TESTExit)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $Button, $FileExit, $ContextMenuExit
Exit
     EndSwitch
WEnd

Can you tell me please how to make for close a active windows and not program ?

 

THX

Link to post
Share on other sites

Example :

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
$GetTitle = WinList()
For $i = 1 To $GetTitle[0][0]
  If $GetTitle[$i][0] <> '' And BitAND(WinGetState($GetTitle[$i][0]), 2) And BitAND(WinGetState($GetTitle[$i][0]), 8) Then
    $Msb = MsgBox($MB_YESNO + $MB_ICONWARNING, 'Window is active', @TAB & 'Confirm Closing Process ?' & @CR & _
    'Process ID = ' & WinGetProcess($GetTitle[$i][0]) & @CR & _
    'Title = ' & $GetTitle[$i][0])
    If $Msb = $IDYES Then
      WinClose($GetTitle[$i][0])
    EndIf
  EndIf
Next

Don't know if it's exactly what you asked :D 
 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...