Jump to content

How to create dynamic windows


Recommended Posts

Hi and sorry for my bad english.

How to create dynamic window's so what I close 1 window, others will stay open?The problem is when I close 1 of the window, all windows will be closed.

how I can make my script close ONLY window that closed by user, NOT all other(s) at once?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>


Dim $GUI[1][1]
Dim $msg[1][1]

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Lets make windows", 314, 200, 193, 125)
$Input1 = GUICtrlCreateInput("", 16, 16, 121, 21)
$Button1 = GUICtrlCreateButton("mk window", 200, 16, 75, 25, 0)
$Input2 = GUICtrlCreateInput(@ScriptDir&"\List.txt", 16, 56, 129, 21)
$Input3 = GUICtrlCreateInput("prefix", 16, 80, 129, 21)
$Input4 = GUICtrlCreateInput("suffix", 16, 105, 129, 21)
$Button2 = GUICtrlCreateButton("use list", 200, 48, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _window()
        Case $Button2
                $windows = StringSplit(FileRead(GUICtrlRead($Input2)),@CRLF,1)
                ReDim $GUI[$windows[0] + 1][1]
                ReDim $msg[$windows[0] + 1][1]
                For $i = 1 To $windows[0]
            _windows($windows[$i])
            Next
    EndSwitch
WEnd

Func _window()
    #Region ### START Koda GUI section ### Form=
$Form2 = GUICreate(GUICtrlRead($Input3)&GUICtrlRead($Input1)&GUICtrlRead($Input4), 314, 102, 193, 125)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form2)
            Return
    EndSwitch
WEnd
EndFunc

Func _windows($title)
    #Region ### START Koda GUI section ### Form=
$GUI[$i][0] = GUICreate(GUICtrlRead($Input3)&$title&GUICtrlRead($Input4), 314, 102, 193, 125)
GUISetState(@SW_SHOW)
return
#EndRegion ### END Koda GUI section ###
While 1
    $msg[$i][0] = GUIGetMsg()
    Switch $msg[$i][0]
        Case $GUI_EVENT_CLOSE
            GUIDelete($GUI[$i][0])
            Return
    EndSwitch
WEnd
EndFunc
Edited by E1M1

edited

Link to comment
Share on other sites

  • Moderators

E1M1,

Use the 'advanced' parameter with GUIGetMsg to identify the window that has sent the $GUI_EVENT_CLOSE message. Then you can close that window and leave the rest open. ;-)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Search for @GUI_WinHandle in the Helpfile

Try this:

#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>

Opt("GUIOnEventMode", 1)

Global $MainGUI

$MainGUI = GUICreate("TEST", 140, 120)
GUISetOnEvent($GUI_EVENT_CLOSE, "QUIT")
$bt1 = GUICtrlCreateButton("test1", 10, 10, 50, 20)
GUICtrlSetOnEvent($bt1, "GUI1")
$bt2 = GUICtrlCreateButton("test2", 10, 30, 50, 20)
GUICtrlSetOnEvent($bt2, "GUI2")
$bt3 = GUICtrlCreateButton("test3", 10, 50, 50, 20)
GUICtrlSetOnEvent($bt3, "GUI3")
$bt4 = GUICtrlCreateButton("test4", 10, 70, 50, 20)
GUICtrlSetOnEvent($bt4, "GUI4")
$bt5 = GUICtrlCreateButton("test5", 10, 90, 50, 20)
GUICtrlSetOnEvent($bt5, "GUI5")
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func GUI1()
    GUICreate("GUI1", 180, 120, Default, Default, Default, Default, $MainGUI)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
    GUISetState(@SW_SHOW)
EndFunc

Func GUI2()
    GUICreate("GUI2", 220, 190, Default, Default, Default, Default, $MainGUI)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
    GUISetState(@SW_SHOW)
EndFunc

Func GUI3()
    GUICreate("GUI3", 300, 200, Default, Default, Default, Default, $MainGUI)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
    GUISetState(@SW_SHOW)
EndFunc

Func GUI4()
    GUICreate("GUI4", 450, 160, Default, Default, Default, Default, $MainGUI)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
    GUISetState(@SW_SHOW)
EndFunc

Func GUI5()
    GUICreate("GUI5", 600, 70, Default, Default, Default, Default, $MainGUI)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
    GUISetState(@SW_SHOW)
EndFunc

Func Close()
    GUIDelete(@GUI_WinHandle)
EndFunc

Func QUIT()
    Exit
EndFunc

EDIT: I'm using OnEvent Mode

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

E1M1,

Use the 'advanced' parameter with GUIGetMsg to identify the window that has sent the $GUI_EVENT_CLOSE message. Then you can close that window and leave the rest open. ;-)

I tried this and it dont work. See below

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>


Dim $GUI[1][1]
Dim $msg[1][1]

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Lets make windows", 314, 200, 193, 125)
$Input1 = GUICtrlCreateInput("", 16, 16, 121, 21)
$Button1 = GUICtrlCreateButton("mk window", 200, 16, 75, 25, 0)
$Input2 = GUICtrlCreateInput(@ScriptDir&"\List.txt", 16, 56, 129, 21)
$Input3 = GUICtrlCreateInput("prefix", 16, 80, 129, 21)
$Input4 = GUICtrlCreateInput("suffix", 16, 105, 129, 21)
$Button2 = GUICtrlCreateButton("use list", 200, 48, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _window()
        Case $Button2
                $windows = StringSplit(FileRead(GUICtrlRead($Input2)),@CRLF,1)
                ReDim $GUI[$windows[0] + 1][1]
                ReDim $msg[$windows[0] + 1][1]
                For $i = 1 To $windows[0]
            _windows($windows[$i])
            Next
    EndSwitch
WEnd

Func _window()
    #Region ### START Koda GUI section ### Form=
$Form2 = GUICreate(GUICtrlRead($Input3)&GUICtrlRead($Input1)&GUICtrlRead($Input4), 314, 102, 193, 125)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form2)
            Return
    EndSwitch
WEnd
EndFunc

<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->Search for @GUI_WinHandle in the Helpfile

Try this:<!--QuoteEnd--></div><!--QuoteEEnd-->

But how this thing would work if I have text file that have 1 win title in every line?
I am not going to write static script. I have text file for windows and I newer know what is in file and how many win titles it contains.

Func _windows($title)
    #Region ### START Koda GUI section ### Form=
$GUI[$i][0] = GUICreate(GUICtrlRead($Input3)&$title&GUICtrlRead($Input4), 314, 102, 193, 125)
GUISetState(@SW_SHOW)
return
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($GUI[$i][0])
            Return
    EndSwitch
WEnd
EndFunc
Edited by E1M1

edited

Link to comment
Share on other sites

  • Moderators

E1M1,

Your code as posted is incomprehensible. What are you trying to do?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I made code simpler. But now i need some help, when I click buttons on main window, nothing happens.How to fix this?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>


Dim $GUI[1][1]

$Form1 = GUICreate("Lets make windows", 314, 200, 193, 125)
$Input1 = GUICtrlCreateInput("", 16, 16, 121, 21)
$Button1 = GUICtrlCreateButton("mk window", 200, 16, 75, 25, 0)
$Input2 = GUICtrlCreateInput(@ScriptDir&"\List.txt", 16, 56, 129, 21)
$Input3 = GUICtrlCreateInput("prefix", 16, 80, 129, 21)
$Input4 = GUICtrlCreateInput("suffix", 16, 105, 129, 21)
$Button2 = GUICtrlCreateButton("use list", 200, 48, 75, 25, 0)
GUISetState(@SW_SHOW)



While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
        Case $GUI_EVENT_CLOSE
            GUIDelete($nMsg[1])
        Case $Button1
            _window()
        Case $Button2
                $windows = StringSplit(FileRead(GUICtrlRead($Input2)),@CRLF,1)
                ReDim $GUI[$windows[0] + 1][1]
                For $i = 1 To $windows[0]
            _windows($windows[$i])
        Next
    EndSwitch
WEnd

Func _window()
$Form2 = GUICreate(GUICtrlRead($Input3)&GUICtrlRead($Input1)&GUICtrlRead($Input4), 314, 102, 193, 125)
GUISetState(@SW_SHOW)
EndFunc

Func _windows($title)
$GUI[$i][0] = GUICreate(GUICtrlRead($Input3)&$title&GUICtrlRead($Input4), 314, 102, 193, 125)
GUISetState(@SW_SHOW)
return
EndFunc

edited

Link to comment
Share on other sites

  • Moderators

E1M1,

Tyr this in your loop:

$aMsg = GUIGetMsg(1)
Switch $aMsg[0]
    Case $GUI_EVENT_CLOSE
        Switch $aMsg[1]
            Case $Form1
                Exit
            Case Else
                GUIDelete($aMsg[1])
        EndSwitch
    Case $Button1
        _window()
    Case $Button2

You (and me!) would find it much easier if you gave your controls descriptive names and added some comments. It is very hard to work out what you are trying to do at the moment. :-)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

E1M1,

Your code as posted is incomprehensible. What are you trying to do?

M23

This code must test program that kill "bad" windows, I have program that kill window if it's title is in blacklist, and black list is long and it can have many combinations, and I need to test all the possibilities.

for example

"porn" is in black list

now I need to know if it also kills windows like

"porno - Firefox"

"porno - Microsoft internet explorer"

"porn - Firefox"

"porn - Microsoft internet explorer"

"gayporno - Firefox"

and there can be thousands of combinations like these, and my script must create GUIs to test these combinations.

Idea is that if my script creates GUI titled "porn" then I can see if that program that kills windows by blacklist work or not.

now you see how many combinations I got from 1 word, but what if I have 50 and more words in blacklist.

...Also this program must not kill word, excel ... and open office windows because office programs are needed to work so I also need to test these combinations.

If I would test all these combinations manually, it takes lots of time, but script that test out 100 combinations in less that 1 sec.

edited

Link to comment
Share on other sites

E1M1,

Tyr this in your loop:

$aMsg = GUIGetMsg(1)
Switch $aMsg[0]
    Case $GUI_EVENT_CLOSE
        Switch $aMsg[1]
            Case $Form1
                Exit
            Case Else
                GUIDelete($aMsg[1])
        EndSwitch
    Case $Button1
        _window()
    Case $Button2

You (and me!) would find it much easier if you gave your controls descriptive names and added some comments. It is very hard to work out what you are trying to do at the moment. :-)

M23

Thanks man

edited

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...