Jump to content

Quit program


PcExpert
 Share

Recommended Posts

Hi all,

I made a program that uses includes to open 2 other programs, so when button1 is pressed it runs this:

#include "FILENAME.au3"

The other button works the same. But when I close the program by pressing the X on the upper right side, it closes all windows, not only the window from the include. I tried to do it with GUIdelete() , that works, but when I click the buton again, it doesnt open anymore. So the question is: How to exit an include, without quitting the whole program?

Thanks!

Link to comment
Share on other sites

can u post the code

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

Hi,

make it a childGUI and have a look at GuiGetMsg( PARAMETER!!!)

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

if im correct im learning something but a child gui is a gui that is not the main yet still has a mind of it own just like unplugging ur phone from a wall if battery full it becomes a child gui once unplugged as it acts on its own accord so once u create the child gui it acts in itself the and

Case $GUI_EVENT_CLOSE

Exit

then works only for the child gui

got it?

cheers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

I made a program that uses includes to open 2 other programs, so when button1 is pressed it runs this:

#include "FILENAME.au3"

The #include statement is found and executed by the AutoIt compiler before the rest of the script is interpreted at all, and it is NOT conditional.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hi,

#include <GUIConstants.au3>

$main_GUI = GUICreate("Main GUI", 300, 100, 10, 10, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
$b_1 = GUICtrlCreateButton("Click me 1", 10, 10, 80, 20)
GUISetState(@SW_SHOW, $main_GUI)

$child_GUI = GUICreate("Child GUI", 300, 100, 330, 10, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX), Default, $main_GUI)
$b_2 = GUICtrlCreateButton("Click me 2", 10, 10, 80, 20)
GUISetState(@SW_SHOW, $child_GUI)

GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO")

While 1
    $msg = GUIGetMsg(1)
    Select
        Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $main_GUI
            MsgBox(16, "MAIN", "Closed MAIN", 2)
            Exit(0)
        Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $child_GUI
            MsgBox(16, "CHILD", "CLOSED CHILD", 2)
            GUIDelete($child_GUI)
        Case $msg[0] = $b_1 And $msg[1] = $main_GUI
            MsgBox(16, "MAIN", "Button 1", 2)
        Case $msg[0] = $b_2 And $msg[1] = $child_GUI
            MsgBox(16, "CHILD", "Button 2", 2)
    EndSelect
WEnd

Func MY_WM_GETMINMAXINFO($hWnd, $msg, $wParam, $lParam)
    If $hWnd <> $main_GUI Then Return
    $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, 500) ; min X
    DllStructSetData($minmaxinfo, 8, 250) ; min Y
    DllStructSetData($minmaxinfo, 9, 500) ; max X
    DllStructSetData($minmaxinfo, 10, 700) ; max Y
    Return 0
EndFunc   ;==>MY_WM_GETMINMAXINFO

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

The #include statement is found and executed by the AutoIt compiler before the rest of the script is interpreted at all, and it is NOT conditional.

Sorry, but you wrong here :P ...

Script.au3:

$Var = 0

If $Var = 1 Then
    #include ".\Inc.au3"
EndIfoÝ÷ Ø   ݶ"w»Ûjëh×6MsgBox(0, "", "Hello from Inc.au3 script ;)")

Save them in one directory, and run Script.au3, you will not get anything, but if you set $Var = 1, then you see a message box :blink:

When i just started to learn AutoIt, i thought that this way the includes are work, and we need to include them as part of our script, so the condition part will not be messed/confusing... but today i know, this is not a correct way to handle our projects :)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

how can I show the child gui when a button is pressed

Just move the line GUISetState(@SW_SHOW, $child_GUI) under button condition (If $msg = $Button Then ...).

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

#include <GUIConstants.au3>

$main_GUI = GUICreate ("Main GUI", 200 , 100,-1,-1,$WS_POPUPWINDOW + $WS_THICKFRAME)
$b_1 = GUICtrlCreateButton("Show Child GUI", 10, 20,120, 30)
$x = GUICtrlCreateButton("Exit", 10, 60,120, 30)
GUISetState(@SW_SHOW, $main_GUI)
$a = WinGetPos ($main_GUI)
$child_GUI = GUICreate("Child GUI",200,100,$a[0] + 210 , $a[1],$WS_POPUPWINDOW + $WS_THICKFRAME)
GUICtrlCreateLabel("This is the Child GUI", 50, 30,120, 30)
$b_2 = GUICtrlCreateButton("Close Child GUI", 40, 60,120, 30)
GUISetState(@SW_HIDE, $child_GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $x
            Exit
        Case $msg = $b_1
            GUISetState (@SW_SHOW, $child_GUI)
            GUICtrlSetState ($b_1 , $gui_disable)
        Case $msg = $b_2
            GUISetState (@SW_HIDE, $child_GUI)
            GUICtrlSetState ($b_1 , $gui_enable)
    EndSelect
WEnd

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

Sorry, but you wrong here :blink: ...

Script.au3:

$Var = 0

If $Var = 1 Then
    #include ".\Inc.au3"
EndIfoÝ÷ Ø   ݶƮݫ­¢+Ù5Í  ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí!±±¼É½´%¹¹ÔÌÍÉ¥ÁÐè´¤ÅÕ½Ðì

Save them in one directory, and run Script.au3, you will not get anything, but if you set $Var = 1, then you see a message box :wub:

When i just started to learn AutoIt, i thought that this way the includes are work, and we need to include them as part of our script, so the condition part will not be messed/confusing... but today i know, this is not a correct way to handle our projects :)

How do you know from that if the code from the #include was substituted or not, since the code would not be executed by the If statement any way? Since function declarations are the most common use of #include files, and Func cannot be used conditionally, how would that make sense? What if $Var depended on Run-Time conditions? How would the compiler know whether is should have included or not back at Compile-Time?

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

How do you know from that if the code from the #include was substituted or not, since the code would not be executed by the If statement any way? Since function declarations are the most common use of #include files, and Func cannot be used conditionally, how would that make sense? What if $Var depended on Run-Time conditions? How would the compiler know whether is should have included or not back at Compile-Time?

Well, first of all i am not sure if i following you, but, if you include a script (conditionaly) that contain Func...EndFunc, the Syntax Check will alert about syntax error, but eventualy, the point is, that you can (but not neccessary) include scripts like this, i just wanted to show that your statment:

The #include statement is found and executed by the AutoIt compiler before the rest of the script is interpreted at all, and it is NOT conditional.

Is not quite correct, sorry for that, its just i thought that you might want to know about this autoit's ability :).

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Well, first of all i am not sure if i following you, but, if you include a script (conditionaly) that contain Func...EndFunc, the Syntax Check will alert about syntax error, but eventualy, the point is, that you can (but not neccessary) include scripts like this, i just wanted to show that your statment:

Is not quite correct, sorry for that, its just i thought that you might want to know about this autoit's ability :).

I'm willing to be wrong (wouldn't surprise anyone around this forum), but I don't think I am. In your example, the code expanded from the #include file might be EXECUTED conditionally (leading to errors if there are any function declarations), but it will be expanded unconditionally. The resulting code is:

$Var = 0

If $Var = 1 Then
    MsgBox(0, "", "Hello from Inc.au3 script :-)") ; This line from #include <Inc.au3>
EndIfoÝ÷ Ø(Z§Ø^½©nzôߥZ­Ú²}ýµÈZ¢~Ø^w%¹×¢²«¨¶)Üç^v«¨¶ç¢Ú'(¶¡× zÛÅç.µçSè§r[y×âè¬{Z×{h¶¬r¸©¶éÜ¢wb¶*'jYrN«{¬jw¶ÚârKhué¨Ëkj×­+-«n±çm£
+»­]zW­yÖ­²¦§¶èm¦åË^Ø^(¥zmðjÊÞÞu.®Ç+p¢é]$)¶¬jëh×6$Var = 0

If $Var = 1 Then
    #include ".\Inc.au3"
EndIf

FileInstall(">AUTOIT UNICODE SCRIPT<", @ScriptDir & "\TestAutoIt.au3")
Run('notepad.exe "' & @ScriptDir & '\TestAutoIt.au3"')

The file that was output would be your script as seen by the interpreter, with all #include files expanded in place. You could try it with an old version of AutoIt to see what it does.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...