Sign in to follow this  
Followers 0
zvvyt

Dynamically created GUIs with simultaneous minimize/restore but only one "shown" window

8 posts in this topic

Hello ya'll!

My problem is split in two, so I'll start with the first one:

What I'm having is my script with dynamically created GUIs with similar / identical names. I would like to have that undepending on how many windows I have open to only have one "window" down at the taskbar.

I guess all I need is the correct GUI style, but I can't find which one I need.

Which brings me to problem part 2 (which I also find to be the easy part):

Windows will open and close on random, so there's no set order in which they'll get closed. But I still need one "window" at the taskbar to work with as long as there's at least one window open.

In the action of one of these windows getting minimized/restored all of the windows will act simultaneously.

This will be solved with something similar: 

case $GUI_EVENT_MINIMIZE
         for $1 = 1 to Ubound($ActiveWindows) step +1
                WinSetState($ActiveWindows[$1], @SW_MINIMIZE)
        Next

And vice versa for restore.

So .. Mainly prob #1 that I need some help with, and a thought about the "always one window at taskbar"-issue.

Just point me in the right direction and I'll hopefully solve it myself ^__^'

Thanks, and have a great weekend!

zvvyt

Share this post


Link to post
Share on other sites

have a look:

Opt("TrayIconHide", 1) ; this will hide all
; or
TraySetState(2) ; will hide the tray icon

I'm not sure if this will leave you 1 tray icon for at least 1 window; I'm sure a guru will chime in ;)

To minimize all you can do the following:

WinMinimizeAll() ; this will minimize all windows
;or
Local $ShellObj = ObjCreate("Shell.Application")
$ShellObj.ToggleDesktop() ; will minimize all currently open windows -- if called again, it will bring up all windows minimized by ToggleDesktop()

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

zvvyt,

To hide the button on the taskbar you need to set another GUI as the "parent" in the GUICreate call. So it sounds like you could do with a "master" GUI with all the others as children. :)

Is that enough to get you going? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

 

have a look:

Opt("TrayIconHide", 1) ; this will hide all
; or
TraySetState(2) ; will hide the tray icon

I'm not sure if this will leave you 1 tray icon for at least 1 window; I'm sure a guru will chime in ;)

I'm sorry if I were unclear, but it's not in the tray where I only want one icon, but on the taskbar where only the open windows are.

To minimize all you can do the following:

WinMinimizeAll() ; this will minimize all windows
;or
Local $ShellObj = ObjCreate("Shell.Application")
$ShellObj.ToggleDesktop() ; will minimize all currently open windows -- if called again, it will bring up all windows minimized by ToggleDesktop()

I only want to minimize the windows I've made myself, which all have about the same name.

To hide the button on the taskbar you need to set another GUI as the "parent" in the GUICreate call. So it sounds like you could do with a "master" GUI with all the others as children. :)

Is that enough to get you going? :huh:

Well, both yay and nay.

I've tried with a hidden GUI as I don't want to have another window active and primary all the GUIs in this script are made dynamically, but I couldn't get that to work.

When I try to minimize child GUIs whos parent is hidden they don't have anywhere to go, so to say. See my attachment at the bottom.

Have a look at the script in it's whole. And I'm sorry if some of the texts are hard to understand as the are in swedish, but all of the relevant text should be in proper english :)

#cs
Unlimited, controllable windows

$WinArray[n][0] = GUI winhandle
$WinArray[n][1] = Rich winhandle
$WinArray[n][2] = GUI height
$WinArray[n][3] = GUI width
$WinArray[n][4] = Rich color
$WinArray[n][5] = Rich textsize

$SaveArray[0] = GUI-name minus "LAN-notes"
$SaveArray[1] =
#ce
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 1 + 2)
Opt("TrayOnEventMode",1)
#include <array.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <TrayConstants.au3>
#include <GuiRichEdit.au3>
#include <GuiMenu.au3>
#include <GuiComboBox.au3>
#include <Color.au3>

TrayCreateItem("LAN-notes")
TrayItemSetState(-1, $TRAY_DISABLE)
TrayCreateItem("")
TrayCreateItem("Ny lapp")
TrayItemSetOnEvent(-1, "New")
TrayCreateItem("")
TrayCreateItem("Följ lapp")
TrayItemSetOnEvent(-1, "LoadList")
TrayCreateItem("")
TrayCreateItem("Stäng av")
TrayItemSetOnEvent(-1,"TrayExit")
TraySetState(1)

Global Enum $idCopy = 1000, $idPaste, $idUndo, $idSelectAll, $idFontsize, $idBkColor, $idCut, $idTest

Global $WinArray[1][6], $GUI_Size[4], $Font_hFont ,$BkColor_RedInputPrev = 0, $BkColor_GreenInputPrev = 0, $BkColor_BlueInputPrev = 0, _
    $BkColor_RedInputPrevSaved = 0, $BkColor_GreenInputPrevSaved = 0, $BkColor_BlueInputPrevSaved = 0, $ColorEventsVal = 0, $BkColor_OK, $BkColor_Cancel, $FontEventsVal = 0, _
    $Font_OK, $Font_Cancel

$hWnd = GUICreate("",0,0) ;-------------------------------------------------- Hidden parentGUI
GUISetState(@SW_HIDE,-1)

Call("New")
while 1
    Sleep(10)
    $Current_GUI = WinGetHandle("[ACTIVE]")
    If _ArraySearch($WinArray,$Current_GUI) <> -1 And WinGetState($Current_GUI) = BitOR(1,2,4,8) Then
        $GUI_Size = WinGetPos($Current_GUI)
        $Current_Rich = $WinArray[_ArraySearch($WinArray,$Current_GUI)][1]
        ;$Rich_Size = GUICtrlSetPos($Current_Rich)
        If $GUI_Size[2] <> $WinArray[_ArraySearch($WinArray,$Current_GUI)][2] Or $GUI_Size[3] <> $WinArray[_ArraySearch($WinArray,$Current_GUI)][3] Then
            _WinAPI_MoveWindow($Current_Rich,0,20,$GUI_Size[2]-20,$GUI_Size[3]-60)
            $WinArray[_ArraySearch($WinArray,$Current_GUI)][2] = $GUI_Size[2]
            $WinArray[_ArraySearch($WinArray,$Current_GUI)][3] = $GUI_Size[3]
        EndIf
    EndIf
WEnd

Func New()
ReDim $WinArray[UBound($WinArray,1)+1][6]

$WinArray[UBound($WinArray,1)-1][0] = GUICreate("LAN-notes - ",200,200,Default,Default,BitOR($ws_sizebox,$WS_MINIMIZEBOX),-1,$hWnd) ;-------------------------------------------------- Dynamical childGUIs
$WinArray[UBound($WinArray,1)-1][2] = 200
$WinArray[UBound($WinArray,1)-1][3] = 200
$WinArray[UBound($WinArray,1)-1][4] = "255,255,255"
$WinArray[UBound($WinArray,1)-1][5] = 8

GUISetOnEvent($GUI_EVENT_CLOSE, "MainEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainEvents")
GUICtrlCreateButton("+",0,0,20,20)
    GUICtrlSetTip(-1,"Skapa ny lapp")
    GUICtrlSetFont(-1,12)
    GUICtrlSetOnEvent(-1,"New")
GUICtrlCreateButton("Spara",20,0,35,20)
    GUICtrlSetOnEvent(-1,"Save")
;GUICtrlCreateButton("Test", 50,80)
    ;GUICtrlSetOnEvent(-1,"Test")
GUICtrlCreateInput("",55,0,105,20)
    GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateButton("Ändra",160,0,35,20)
    GUICtrlSetOnEvent(-1,"EditProjName")
$WinArray[UBound($WinArray,1)-1][1] = _GUICtrlRichEdit_Create($WinArray[UBound($WinArray,1)-1][0], "",0,25,180,160, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_WANTRETURN,$ES_MULTILINE))
_GUICtrlRichEdit_SetFont($WinArray[UBound($WinArray,1)-1][1], 8)

Global $hMenu = _GUICtrlMenu_CreatePopup()

_GUICtrlMenu_AddMenuItem($hMenu, "Ångra", $idUndo)
_GUICtrlMenu_AddMenuItem($hMenu, "")
_GUICtrlMenu_AddMenuItem($hMenu, "Klipp ut", $idCut)
_GUICtrlMenu_AddMenuItem($hMenu, "Kopiera", $idCopy)
_GUICtrlMenu_AddMenuItem($hMenu, "Klistra in", $idPaste)
_GUICtrlMenu_AddMenuItem($hMenu, "Markera allt", $idSelectAll)
_GUICtrlMenu_AddMenuItem($hMenu, "")
_GUICtrlMenu_AddMenuItem($hMenu, "Textstorlek", $idFontsize)
_GUICtrlMenu_AddMenuItem($hMenu, "Bakgrundsfärg", $idBkColor)
_GUICtrlMenu_AddMenuItem($hMenu, "")
_GUICtrlMenu_AddMenuItem($hMenu, "Test", $idTest)

Global $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam")

Global $wProcOld = _WinAPI_SetWindowLong($WinArray[UBound($WinArray,1)-1][1], $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))

GUISetState()

EndFunc

Func Test($RichTest)
    If _GUICtrlRichEdit_GetTextLength($RichTest, True, True) > 0 Then
        Local $RichPrevFontSize, $RichPrevFontSizeChange, $RichStringFonts, $RichCurrentFontSize
        For $1 = 0 To _GUICtrlRichEdit_GetTextLength($RichTest, True, True) Step +1
            _GUICtrlRichEdit_SetSel($RichTest,$1,$1)
            If $1 = 0 Then
                $RichPrevFontSize = _GUICtrlRichEdit_GetFont($RichTest)
                $RichPrevFontSizeChange = $1
                $RichStringFonts = String("<" & $RichPrevFontSize[0] & ">")
            ElseIf $1 > 0 Then
                $RichCurrentFontSize = _GUICtrlRichEdit_GetFont($RichTest)
                If $RichCurrentFontSize[0] <> $RichPrevFontSize[0] Then
                    $RichCurrentFontSizeChange = $1-1
                    If $RichPrevFontSizeChange <> 0 Then $RichPrevFontSizeChange = $RichPrevFontSizeChange-1
                    $RichStringFonts = String($RichStringFonts & _GUICtrlRichEdit_GetTextInRange($RichTest,$RichPrevFontSizeChange,$RichCurrentFontSizeChange) & "<" & $RichPrevFontSize[0] & ">" & "<" & $RichCurrentFontSize[0] & ">")
                    $RichPrevFontSize[0] = $RichCurrentFontSize[0]
                    $RichPrevFontSizeChange = $1
                EndIf
            EndIf
        Next
        If $RichPrevFontSizeChange <> 0 Then $RichPrevFontSizeChange = $RichPrevFontSizeChange-1
        $RichStringFonts = String($RichStringFonts & _GUICtrlRichEdit_GetTextInRange($RichTest,$RichPrevFontSizeChange, $1) & "<" & $RichPrevFontSize[0] & ">")
        ConsoleWrite($RichStringFonts & @CRLF)
    EndIf
EndFunc

Func MainEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            If WinExists("LAN-notes - ") Then
                If MsgBox(4,"Stäng?","Är du säker på att du vill stänga lappen?") = 6 Then
                    For $1 = (_ArraySearch($WinArray,@GUI_WinHandle)) To (UBound($WinArray,1)-2) Step +1
                        $WinArray[$1][0] = $WinArray[$1+1][0]
                        $WinArray[$1][1] = $WinArray[$1+1][1]
                        $WinArray[$1][2] = $WinArray[$1+1][2]
                        $WinArray[$1][3] = $WinArray[$1+1][3]
                    Next
                    ReDim $WinArray[UBound($WinArray,1)-1][4]
                    GUIDelete(@GUI_WinHandle)
                EndIf
            EndIf
    EndSelect
EndFunc

Func EditProjName()
    ConsoleWrite("Edit projName" & @CRLF)
    If GUICtrlGetState(@GUI_CtrlId-1) = 144 Then
        GUICtrlSetState(@GUI_CtrlId-1,$GUI_ENABLE)
        GUICtrlSetData(@GUI_CtrlId,"Klar")
    Else
        WinSetTitle(@GUI_WinHandle,"","LAN-notes - " & GUICtrlRead(@GUI_CtrlId-1))
        GUICtrlSetState(@GUI_CtrlId-1,$GUI_DISABLE)
        GUICtrlSetData(@GUI_CtrlId,"Ändra")
    EndIf
EndFunc

Func Save()
    ConsoleWrite("--> Save" & @CRLF)
    ConsoleWrite(StringReplace(WinGetTitle(@GUI_WinHandle),"LAN-notes - ","") & @CRLF)
EndFunc

Func TrayExit()
    ConsoleWrite("TrayExit")
    If MsgBox(4,"Stäng?","Är du säker på att du vill stänga av?") = 6 Then
        DllCallbackFree($wProcHandle)
        Exit
    EndIf
EndFunc

Func _WindowProc($hWnd, $Msg, $wParam, $lParam)
    $GUI = WinActive("LAN-notes - ")
    If _ArraySearch($WinArray,$GUI) <> -1 Then
    Switch $hWnd
        Case $WinArray[_ArraySearch($WinArray,$GUI)][1]
            Switch $Msg
                Case $WM_RBUTTONUP
                    ConsoleWrite("-> Rightclick" & @LF)
                    _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    Return 0
                Case $WM_COMMAND
                    Switch $wParam
                        Case $idCut
                            ConsoleWrite("-> Cut" & @LF)
                            _GUICtrlRichEdit_Cut($WinArray[_ArraySearch($WinArray,$GUI)][1])
                        Case $idCopy
                            ConsoleWrite("-> Copy" & @LF)
                            _GUICtrlRichEdit_Copy($WinArray[_ArraySearch($WinArray,$GUI)][1])
                        Case $idPaste
                            ConsoleWrite("-> Paste" & @LF)
                            _GUICtrlRichEdit_Paste($WinArray[_ArraySearch($WinArray,$GUI)][1])
                        Case $idUndo
                            ConsoleWrite("-> Undo" & @LF)
                            _GUICtrlRichEdit_Undo($WinArray[_ArraySearch($WinArray,$GUI)][1])
                        Case $idSelectAll
                            ConsoleWrite("-> Select all" & @LF)
                            _GUICtrlRichEdit_SetSel($WinArray[_ArraySearch($WinArray,$GUI)][1],0,StringLen(_GUICtrlRichEdit_GetText($WinArray[_ArraySearch($WinArray,$GUI)][1])))
                        Case $idFontsize
                            ConsoleWrite("-> Size" &@LF)
                            $Return_Font = _Fontsize($GUI,$WinArray[_ArraySearch($WinArray,$GUI)][5])
                            ConsoleWrite($Return_Font&@CRLF)
                            If $Return_Font <> 0 Then
                                $Text_Selected = _GUICtrlRichEdit_GetSel($WinArray[_ArraySearch($WinArray,$GUI)][1])
                                If $Text_Selected[0] = $Text_Selected[1] Then
                                    _GUICtrlRichEdit_SetSel($WinArray[_ArraySearch($WinArray,$GUI)][1],0,_GUICtrlRichEdit_GetTextLength($WinArray[_ArraySearch($WinArray,$GUI)][1],True,True))
                                    _GUICtrlRichEdit_SetFont($WinArray[_ArraySearch($WinArray,$GUI)][1],$Return_Font)
                                    _GUICtrlRichEdit_SetSel($WinArray[_ArraySearch($WinArray,$GUI)][1],$Text_Selected[0],$Text_Selected[0])
                                Else
                                    _GUICtrlRichEdit_SetFont($WinArray[_ArraySearch($WinArray,$GUI)][1],$Return_Font)
                                EndIf
                            EndIf
                        Case $idBkColor
                            ConsoleWrite("-> BkColor" &@LF)
                            $Return_BkColor = _BkColor($GUI)
                            If $Return_BkColor <> 0 Then _GUICtrlRichEdit_SetBkColor($WinArray[_ArraySearch($WinArray,$GUI)][1],$Return_BkColor)
                        Case $idTest
                            ConsoleWrite("-> Test" &@LF)
                            Call("Test",$WinArray[_ArraySearch($WinArray,$GUI)][1])
                    EndSwitch
            EndSwitch
    EndSwitch
    endif
    Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _
                          "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    Return $aRet[0]
EndFunc

Func _BkColor($hGui)
    $PrevBkColors = StringSplit($WinArray[_ArraySearch($WinArray,$hGui)][4],",")
    $BkColor_RedInputPrevSaved = $PrevBkColors[1]
    $BkColor_GreenInputPrevSaved = $PrevBkColors[2]
    $BkColor_BlueInputPrevSaved = $PrevBkColors[3]
    $hGui_BkColor = GUICreate("Ställ bakgrundsfärg", 250,150,-1,-1,$WS_border, -1,$hGui)
    $BkColor_MainInput = GUICtrlCreateCombo("Vit", 90,15,70)
    If $BkColor_RedInputPrevSaved = 255 And $BkColor_GreenInputPrevSaved = 255 And $BkColor_BlueInputPrevSaved = 255 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Vit")
    If $BkColor_RedInputPrevSaved = 255 And $BkColor_GreenInputPrevSaved = 0 And $BkColor_BlueInputPrevSaved = 0 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Röd")
    If $BkColor_RedInputPrevSaved = 0 And $BkColor_GreenInputPrevSaved = 255 And $BkColor_BlueInputPrevSaved = 0 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Grön")
    If $BkColor_RedInputPrevSaved = 0 And $BkColor_GreenInputPrevSaved = 0 And $BkColor_BlueInputPrevSaved = 255 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Blå")
    If $BkColor_RedInputPrevSaved = 0 And $BkColor_GreenInputPrevSaved = 0 And $BkColor_BlueInputPrevSaved = 0 Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Svart")
    If ($BkColor_RedInputPrevSaved <> 0 And $BkColor_RedInputPrevSaved <> 255) Or ($BkColor_GreenInputPrevSaved <> 0 And $BkColor_GreenInputPrevSaved <> 255) Or _
        ($BkColor_BlueInputPrevSaved <> 0 And $BkColor_BlueInputPrevSaved <> 255) Then GUICtrlSetData(-1,"Röd|Grön|Blå|Svart|Egen","Egen")
    GUICtrlCreateLabel("Röd", 10,40,30)
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlCreateLabel("Grön", 10,60,30)
    GUICtrlSetColor(-1, 0x00FF00)
    GUICtrlCreateLabel("Blå", 10,80,30)
    GUICtrlSetColor(-1, 0x0000FF)
    $BkColor_Red = GUICtrlCreateSlider(35,40,120,-1)
    GUICtrlSetLimit(-1,255)
    GUICtrlSetData(-1, $BkColor_RedInputPrevSaved)
    $BkColor_Green = GUICtrlCreateSlider(35,60,120,-1)
    GUICtrlSetLimit(-1,255)
    GUICtrlSetData(-1, $BkColor_GreenInputPrevSaved)
    $BkColor_Blue = GUICtrlCreateSlider(35,80,120,-1)
    GUICtrlSetLimit(-1,255)
    GUICtrlSetData(-1,$BkColor_BlueInputPrevSaved)
    $BkColor_RedInput = GUICtrlCreateInput($BkColor_RedInputPrevSaved,160,40,40,20,$ES_NUMBER)
    GUICtrlSetLimit(-1,255)
    $BkColor_GreenInput = GUICtrlCreateInput($BkColor_GreenInputPrevSaved,160,60,40,20,$ES_NUMBER)
    GUICtrlSetLimit(-1,255)
    $BkColor_BlueInput = GUICtrlCreateInput($BkColor_BlueInputPrevSaved,160,80,40,20,$ES_NUMBER)
    GUICtrlSetLimit(-1,255)
    $BkColor_OK = GUICtrlCreateButton("OK", 25,100,50,25)
    GUICtrlSetOnEvent(-1,"ColorEvents")
    $BkColor_Cancel = GUICtrlCreateButton("Avbryt", 75,100,50,25)
    GUICtrlSetOnEvent(-1,"ColorEvents")
    Local $BkColor_RedPrev = $BkColor_RedInputPrevSaved, $BkColor_GreenPrev = $BkColor_GreenInputPrevSaved, $BkColor_BluePrev = $BkColor_BlueInputPrevSaved, $BkColor_MainInputPrev
    $BkColor_Prev = $BkColor_RedInputPrevSaved*65536+$BkColor_GreenInputPrevSaved*256+$BkColor_BlueInputPrevSaved
    $BkColor_ExampleColor = GUICtrlCreateLabel("",210,40,30,60)
    GUICtrlSetColor(-1, $BkColor_Prev)
    GUISetState(@SW_DISABLE, $hGui)
    GUISetState(@SW_SHOW, $hGui_BkColor)
    While 1
        If _GUICtrlComboBox_GetDroppedState($BkColor_MainInput) = False Then
            If $ColorEventsVal = 1 Then
                GUIDelete($hGui_BkColor)
                GUISetState(@SW_ENABLE,$hGui)
                WinActivate($hGui)
                $ColorEventsVal = 0
                Return 0
                ExitLoop
            ElseIf $ColorEventsVal = 2 Then
                $WinArray[_ArraySearch($WinArray,$hGui)][4] = GUICtrlRead($BkColor_RedInput)&","&GUICtrlRead($BkColor_GreenInput)&","&GUICtrlRead($BkColor_BlueInput)
                Local $BkColor_ColorArray[3] = [GUICtrlRead($BkColor_RedInput), GUICtrlRead($BkColor_GreenInput), GUICtrlRead($BkColor_BlueInput)]
                $BkColor_Color = _ColorSetCOLORREF($BkColor_ColorArray)
                ConsoleWrite($BkColor_Color&@CRLF)
                GUIDelete($hGui_BkColor)
                GUISetState(@SW_ENABLE,$hGui)
                WinActivate($hGui)
                $ColorEventsVal = 0
                Return $BkColor_Color
                ExitLoop
            EndIf
        If GUICtrlRead($BkColor_MainInput) <> $BkColor_MainInputPrev Then
            ConsoleWrite(GUICtrlRead($BkColor_MainInput)&@CRLF)
            If GUICtrlRead($BkColor_MainInput) = "Vit" Then
                ConsoleWrite("Set to white"&@CRLF)
                GUICtrlSetData($BkColor_Red,255)
                $BkColor_RedPrev = 255
                GUICtrlSetData($BkColor_RedInput,255)
                $BkColor_RedInputPrev = 255
                GUICtrlSetData($BkColor_Green,255)
                $BkColor_GreenPrev = 255
                GUICtrlSetData($BkColor_GreenInput,255)
                $BkColor_GreenInputPrev = 255
                GUICtrlSetData($BkColor_Blue,255)
                $BkColor_BluePrev = 255
                GUICtrlSetData($BkColor_BlueInput,255)
                $BkColor_BlueInputPrev = 255
            EndIf
            If GUICtrlRead($BkColor_MainInput) =  "Röd" Then
                ConsoleWrite("Set to red"&@CRLF)
                GUICtrlSetData($BkColor_Red,255)
                $BkColor_RedPrev = 255
                GUICtrlSetData($BkColor_RedInput,255)
                $BkColor_RedInputPrev = 255
                GUICtrlSetData($BkColor_Green,0)
                $BkColor_GreenPrev = 0
                GUICtrlSetData($BkColor_GreenInput,0)
                $BkColor_GreenInputPrev = 0
                GUICtrlSetData($BkColor_Blue,0)
                $BkColor_BluePrev = 0
                GUICtrlSetData($BkColor_BlueInput,0)
                $BkColor_BlueInputPrev = 0
            EndIf
            If GUICtrlRead($BkColor_MainInput) =  "Grön" Then
                ConsoleWrite("Set to green"&@CRLF)
                GUICtrlSetData($BkColor_Red,0)
                $BkColor_RedPrev = 0
                GUICtrlSetData($BkColor_RedInput,0)
                $BkColor_RedInputPrev = 0
                GUICtrlSetData($BkColor_Green,255)
                $BkColor_GreenPrev = 255
                GUICtrlSetData($BkColor_GreenInput,255)
                $BkColor_GreenInputPrev = 255
                GUICtrlSetData($BkColor_Blue,0)
                $BkColor_BluePrev = 0
                GUICtrlSetData($BkColor_BlueInput,0)
                $BkColor_BlueInputPrev = 0
            EndIf
            If GUICtrlRead($BkColor_MainInput) =  "Blå" Then
                ConsoleWrite("Set to blue"&@CRLF)
                GUICtrlSetData($BkColor_Red,0)
                $BkColor_RedPrev = 0
                GUICtrlSetData($BkColor_RedInput,0)
                $BkColor_RedInputPrev = 0
                GUICtrlSetData($BkColor_Green,0)
                $BkColor_GreenPrev = 0
                GUICtrlSetData($BkColor_GreenInput,0)
                $BkColor_GreenInputPrev = 0
                GUICtrlSetData($BkColor_Blue,255)
                $BkColor_BluePrev = 255
                GUICtrlSetData($BkColor_BlueInput,255)
                $BkColor_BlueInputPrev = 255
            EndIf
            If GUICtrlRead($BkColor_MainInput) =  "Svart" Then
                ConsoleWrite("Set to black"&@CRLF)
                GUICtrlSetData($BkColor_Red,0)
                $BkColor_RedPrev = GUICtrlRead($BkColor_Red)
                GUICtrlSetData($BkColor_RedInput,0)
                $BkColor_RedInputPrev = GUICtrlRead($BkColor_RedInput)
                GUICtrlSetData($BkColor_Green,0)
                $BkColor_GreenPrev = GUICtrlRead($BkColor_Green)
                GUICtrlSetData($BkColor_GreenInput,0)
                $BkColor_GreenInputPrev = GUICtrlRead($BkColor_GreenInput)
                GUICtrlSetData($BkColor_Blue,0)
                $BkColor_BluePrev = GUICtrlRead($BkColor_Blue)
                GUICtrlSetData($BkColor_BlueInput,0)
                $BkColor_BlueInputPrev = GUICtrlRead($BkColor_BlueInput)
            EndIf
            $BkColor_MainInputPrev = GUICtrlRead($BkColor_MainInput)
        EndIf
        If GUICtrlRead($BkColor_RedInput) > 255 Then
            GUICtrlSetData($BkColor_Red,255)
            GUICtrlSetData($BkColor_RedInput,255)
            $BkColor_RedPrev = 255
            $BkColor_RedInputPrev = 255
        EndIf
        If GUICtrlRead($BkColor_GreenInput) > 255 Then
            GUICtrlSetData($BkColor_Green,255)
            GUICtrlSetData($BkColor_GreenInput,255)
            $BkColor_GreenPrev = 255
            $BkColor_GreenInputPrev = 255
        EndIf
        If GUICtrlRead($BkColor_BlueInput) > 255 Then
            GUICtrlSetData($BkColor_Blue,255)
            GUICtrlSetData($BkColor_BlueInput,255)
            $BkColor_BluePrev = 255
            $BkColor_BlueInputPrev = 255
        EndIf
        $BkColor_ZerocheckRed = StringSplit(GUICtrlRead($BkColor_RedInput),"")
        $BkColor_ZerocheckGreen = StringSplit(GUICtrlRead($BkColor_GreenInput),"")
        $BkColor_ZerocheckBlue = StringSplit(GUICtrlRead($BkColor_BlueInput),"")
        If $BkColor_ZerocheckRed[0] > 1 And $BkColor_ZerocheckRed[1] = "0" Then GUICtrlSetData($BkColor_RedInput,StringReplace(GUICtrlRead($BkColor_RedInput),"0","",1))
        If $BkColor_ZerocheckGreen[0] > 1 And $BkColor_ZerocheckGreen[1] = "0" Then GUICtrlSetData($BkColor_GreenInput,StringReplace(GUICtrlRead($BkColor_GreenInput),"0","",1))
        If $BkColor_ZerocheckBlue[0] > 1 And $BkColor_ZerocheckBlue[1] = "0" Then GUICtrlSetData($BkColor_BlueInput,StringReplace(GUICtrlRead($BkColor_BlueInput),"0","",1))
        $BkColor_ReadRed = GUICtrlRead($BkColor_Red)
        $BkColor_ReadGreen = GUICtrlRead($BkColor_Green)
        $BkColor_ReadBlue = GUICtrlRead($BkColor_Blue)
        $BkColor_ReadRedInput = GUICtrlRead($BkColor_RedInput)
        $BkColor_ReadGreenInput = GUICtrlRead($BkColor_GreenInput)
        $BkColor_ReadBlueInput = GUICtrlRead($BkColor_BlueInput)
        If $BkColor_ReadRedInput <> $BkColor_RedPrev Or $BkColor_ReadRed <> $BkColor_RedPrev Then
            If $BkColor_ReadRedInput <> $BkColor_RedPrev Then
                GUICtrlSetData($BkColor_Red,$BkColor_ReadRedInput)
                $BkColor_RedPrev = $BkColor_ReadRedInput
            ElseIf $BkColor_ReadRed <> $BkColor_RedPrev Then
                GUICtrlSetData($BkColor_RedInput,$BkColor_ReadRed)
                $BkColor_RedInputPrev = $BkColor_ReadRed
            EndIf
        EndIf

        If $BkColor_ReadGreenInput <> $BkColor_GreenPrev Or $BkColor_ReadGreen <> $BkColor_GreenPrev Then
            If $BkColor_ReadGreenInput <> $BkColor_GreenPrev Then
                GUICtrlSetData($BkColor_Green,$BkColor_ReadGreenInput)
                $BkColor_GreenPrev = $BkColor_ReadGreenInput
            ElseIf $BkColor_ReadGreen <> $BkColor_GreenPrev Then
                GUICtrlSetData($BkColor_GreenInput,$BkColor_ReadGreen)
                $BkColor_GreenInputPrev = $BkColor_ReadGreen
            EndIf
        EndIf

        If $BkColor_ReadBlueInput <> $BkColor_BluePrev Or $BkColor_ReadBlue <> $BkColor_BluePrev Then
            If $BkColor_ReadBlueInput <> $BkColor_BluePrev Then
                GUICtrlSetData($BkColor_Blue,$BkColor_ReadBlueInput)
                $BkColor_BluePrev = $BkColor_ReadBlueInput
            ElseIf $BkColor_ReadBlue <> $BkColor_BluePrev Then
                GUICtrlSetData($BkColor_BlueInput,$BkColor_ReadBlue)
                $BkColor_BlueInputPrev = $BkColor_ReadBlue
            EndIf
        EndIf

    If $BkColor_RedPrev = 255 And $BkColor_GreenPrev = 255 And $BkColor_BluePrev = 255 And GUICtrlRead($BkColor_MainInput) <> "Vit" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,0)
    If $BkColor_RedPrev = 255 And $BkColor_GreenPrev = 0 And $BkColor_BluePrev = 0 And GUICtrlRead($BkColor_MainInput) <> "Röd" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,1)
    If $BkColor_RedPrev = 0 And $BkColor_GreenPrev = 255 And $BkColor_BluePrev = 0 And GUICtrlRead($BkColor_MainInput) <> "Grön" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,2)
    If $BkColor_RedPrev = 0 And $BkColor_GreenPrev = 0 And $BkColor_BluePrev = 255 And GUICtrlRead($BkColor_MainInput) <> "Blå" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,3)
    If $BkColor_RedPrev = 0 And $BkColor_GreenPrev = 0 And $BkColor_BluePrev = 0 And GUICtrlRead($BkColor_MainInput) <> "Svart" Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,4)
    If ($BkColor_RedPrev <> 0 And $BkColor_RedPrev <> 255 And GUICtrlRead($BkColor_MainInput) <> "Egen") Or ($BkColor_GreenPrev <> 0 And $BkColor_GreenPrev <> 255 And GUICtrlRead($BkColor_MainInput) <> "Egen") Or _
        ($BkColor_BluePrev <> 0 And $BkColor_BluePrev <> 255 And GUICtrlRead($BkColor_MainInput) <> "Egen") Then _GUICtrlComboBox_SetCurSel($BkColor_MainInput,5)
    EndIf
    $BkColor =     $BkColor_RedPrev*65536+$BkColor_GreenPrev*256+$BkColor_BluePrev
    If $BkColor <> $BkColor_Prev Then
        GUICtrlSetBkColor($BkColor_ExampleColor,$BkColor)
        $BkColor_Prev = $BkColor
    EndIf
    WEnd
EndFunc

Func ColorEvents()
    switch @GUI_CtrlId
        Case $BkColor_OK
            $ColorEventsVal = 2
        Case $BkColor_Cancel
            $ColorEventsVal = 1
    EndSwitch
EndFunc

Func _Fontsize($hGui,$Font_PrevSize)
    $hGui_fontsize = GUICreate("Ställ textstorlek", 150,150,-1,-1,$WS_border,-1,$hGui)
    $Font_Input = GUICtrlCreateInput($Font_PrevSize,50,15,50)
    GUICtrlCreateUpdown(-1)
    GUICtrlSetLimit(-1, 50,8)
    $Font_ExampleLable = GUICtrlCreateLabel("Ex",60,40,100,75)
    GUICtrlSetState(-1,$gui_disable)
    GUICtrlSetFont(-1,$Font_PrevSize)
    $Font_OK = GUICtrlCreateButton("OK", 25,100,50,25)
    GUICtrlSetOnEvent(-1, "FontEvents")
    $Font_Cancel = GUICtrlCreateButton("Avbryt", 75,100,50,25)
    GUICtrlSetOnEvent(-1, "FontEvents")
    GUISetState(@SW_DISABLE, $hGui)
    GUISetState(@SW_SHOW, $hGui_fontsize)
    While 1
        If $FontEventsVal = 1 Then
            GUIDelete($hGui_fontsize)
            GUISetState(@SW_ENABLE,$hGui)
            WinActivate($hGui)
            $FontEventsVal = 0
            Return 0
            ExitLoop
        ElseIf $FontEventsVal = 2 Then
            $WinArray[_ArraySearch($WinArray,$hGui)][5] = GUICtrlRead($Font_Input)
            GUIDelete($hGui_fontsize)
            GUISetState(@SW_ENABLE,$hGui)
            WinActivate($hGui)
            ConsoleWrite(GUICtrlRead($Font_Input)&@CRLF)
            $FontEventsVal = 0
            Return $WinArray[_ArraySearch($WinArray,$hGui)][5]
            ExitLoop
        EndIf
        $Font_CurrentSize = GUICtrlRead($Font_Input)
        If $Font_CurrentSize > 50 Then GUICtrlSetData($Font_Input,50)
        If $Font_CurrentSize < 8 Then GUICtrlSetData($Font_Input,8)
        If $Font_CurrentSize <> $Font_PrevSize Then
            GUICtrlSetFont($Font_ExampleLable,GUICtrlRead($Font_Input))
            GUICtrlSetPos($Font_ExampleLable,60-(GUICtrlRead($Font_Input)/2))
            $Font_PrevSize = $Font_CurrentSize
        EndIf
    WEnd
EndFunc

Func FontEvents()
    switch @GUI_CtrlId
        Case $Font_OK
            $FontEventsVal = 2
        Case $Font_Cancel
            $FontEventsVal = 1
    EndSwitch
EndFunc

Func LoadList()

EndFunc

DllCallbackFree($wProcHandle)

fehqfLj.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

zvvyt,

Firstly, you can use the hidden, but always present, AutoIt GUI as a parent:

$hWnd = WinGetHandle(AutoItWinGetTitle())
Next, I suggest preventing the default behaviour of the GUI for button events (Opt("GUIEventOptions", 1) and then adding some code to your MainEvents function to hide the GUI instead of minimizing it:

Func MainEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            [...]
        Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE, @GUI_WinHandle)
    EndSelect
EndFunc   ;==>MainEvents
You will of course have to develop a way to get the GUI visible again when required. ;)

Finally, your script nearly always crashes on exit, but I have not yet discovered why. :(>

M23

Edit:

Found the problem - you should delete all the subclassed GUIs before freeing the replacement WndProc:

Func TrayExit()
    ConsoleWrite("TrayExit")
    If MsgBox(4, "Stäng?", "Är du säker på att du vill stänga av?") = 6 Then
        For $i = 0 To UBound($WinArray, 1) - 1
            GUIDelete($WinArray[$i][0])
        Next
        DllCallbackFree($wProcHandle)
        Exit
    EndIf
EndFunc   ;==>TrayExit
Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Firstly, you can use the hidden, but always present, AutoIt GUI as a parent:

$hWnd = WinGetHandle(AutoItWinGetTitle())

Grazie! 

Next, I suggest preventing the default behaviour of the GUI for button events (Opt("GUIEventOptions", 1) and then adding some code to your MainEvents function to hide the GUI instead of minimizing it:

You will of course have to develop a way to get the GUI visible again when required. ;)

Thanks, that's the exact way of putting me on the right track I was looking for!

But then I still don't have a "window" I can use to "restore"/show the GUIs again?

I could add a hide/show-function to the tray, but that is a step off my original path..

Finally, your script nearly always crashes on exit, but I have not yet discovered why. :(>

Found the problem - you should delete all the subclassed GUIs before freeing the replacement WndProc:

That's odd, as I'm not getting a single error when I run and/or close it..

But if it was as simple and fundamental as deleting the GUIs then I'm more than happy you pointed that out :)

Share this post


Link to post
Share on other sites

"Följ lapp"

Is it bad that I laughed at that? :P

(it's a Swedish thing)

Well, now I can't keep it like that..! xD

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

  • Similar Content

    • computergroove
      By computergroove
      I've made a form in Koda where I make a list of 3 user definable elements that I want to be able to replicate with a button press so a user can add data that can be used as part of the program. 
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=D:\Carbonite Important\0 - Programing\Scite and Autoit\Koda 1.7.3.0\Forms\Mileage Estimator.kxf $Form1 = GUICreate("Save Project", 614, 1126, 298, 141) $Location = GUICtrlCreateInput("Location", 40, 112, 345, 21) $Distance = GUICtrlCreateInput("Distance", 400, 112, 89, 21) $AddLocation = GUICtrlCreateButton("AddLocation", 288, 80, 97, 25) $Label1 = GUICtrlCreateLabel("Location", 40, 88, 45, 17) $Label2 = GUICtrlCreateLabel("Distance", 400, 88, 46, 17) $HomeBase = GUICtrlCreateInput("HomeBase", 312, 32, 121, 21) $LeapYear = GUICtrlCreateCheckbox("LeapYear", 464, 32, 17, 17) $Label3 = GUICtrlCreateLabel("Leap Year?", 488, 32, 59, 17) $Variance = GUICtrlCreateInput("Variance", 504, 112, 81, 21) $Label4 = GUICtrlCreateLabel("Variance", 504, 88, 46, 17) $Label5 = GUICtrlCreateLabel("Home Base", 312, 8, 59, 17) $Button1 = GUICtrlCreateButton("Button1", 144, 56, 1, 57) $Save = GUICtrlCreateButton("Save Project", 40, 16, 121, 25) $Load = GUICtrlCreateButton("Load Project", 176, 16, 121, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $AddLocation EndSwitch WEnd I want to press the "add location" button and have the fields {Location, Distance and variance} create a new blank record located under the existing 3 input boxes. Since the fields can number over 30 locations in some examples I am thinking about having these items in a scrolling window. What is the best way to do this and can auto it add a variable while running by pressing a button?
    • XaelloNegative
      By XaelloNegative
      Hi,
      I made a small blunder with my code. I created the GUI under 1920x1080 resolution however, my user is configured to ONLY 1080x720 and cannot go any further than that.
      What do you guys think is the best way to correct this one? Resolution mathematics is something that came to mind however I do not have access to his PC to check  from time to time if  my estimation is correct and the resolution on my PC doesn't go down to 1080x720.
      Please help.
      ~XN~
    • davidacrozier
      By davidacrozier
      Hello all ~
      I am running an autoit script on Windows 10 inside VMware Workstation 12 Pro version 12.5.2.  Technically I am remoting into ESXi which has a Domain Controller (DC), WebServer, FilServer, Windows 10, etc.  Using the GUI (i.e. running explorer.exe) I am able to open several different folders successfully.  The desktop, documents, USB external all open without issue.  The network share opening gives me issues.  Whenever I attempt to open \\filserver\users\user\sharedfolder I get the documents folder instead.  I understand that the documents folder is the default for explorer.  I have also attempted to use the letter drive mapped to the network share (Z:) and receive the same result.  When I run this script on Windows 10 alone without  the VM or the ESXi I am able to open the network share without problems.  I have tried to use the net use command to designate a letter M: to the network share folder prior to running the script.  This did not work for me.  
      One additional avenue I think might work is to use the systreeview321 and _GUICtrlTreeView_FindItem to step through the tree looking for the network share.  Once found,  double click on it and see if that opens the shared network folder.  I can click inside the VM with my mouse on the network share and it opens just fine.  Not sure if running up against GUI issues, or permission issues, or what?
      Thanks in advance,
      Davida Crozier
      TestNetworkShare.au3
      This script is a subset of a much larger program, but it illustrates what I am dealing with.

    • superflq
      By superflq
      Hi everyone,
      GUICtrlSetState Function example ,i found $GUI_DROPACCEPTED isn't working in windows10 x64(windows_10_enterprise_2016_ltsb_x64).
      if the example put to windows10 x86 or windows xp, the $GUI_DROPACCEPTED is effective,
      the AutoIt Edition is v3.3.14.2.
      any ideas? thanks you.
       
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 420, 200, -1, -1, -1, $WS_EX_ACCEPTFILES) ; Create a label and set the state as drop accepted. Local $idLabel = GUICtrlCreateLabel("Drop a file on this label.", 10, 10, 400, 40, $WS_BORDER) GUICtrlSetState($idLabel, $GUI_DROPACCEPTED) ; Create an input and set the state as drop accepted. Local $idInput = GUICtrlCreateInput("", 10, 60, 400, 22) GUICtrlSetState($idInput, $GUI_DROPACCEPTED) Local $idOK = GUICtrlCreateButton("OK", 310, 170, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop Case $GUI_EVENT_DROPPED ; If the value of @GUI_DropId is $idLabel, then set the label of the dragged file. If @GUI_DropId = $idLabel Then GUICtrlSetData($idLabel, @GUI_DragFile) EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
    • MrCheese
      By MrCheese
      Hey Guys,
       
      So, the functions work, where primarygui() accurately determines the evaluation of the status of the checkboxes - the msgbox picks this up.
       
      However, later on, when we re-enter a 'for $i = 0 to ubound($checkbox)' loop, then in the 'batchinitial' function it doesn't picked up that the status&$i = 1, so it jumps out, then within the While 1 loop, it exits the loop in the first row, again because the status& $i= 0
      The "assign" line within the primarygui funtion, is this only a local assignment? if so, how can I make it cross function?
       
      Thank in adv for your help
       
       
      Func excelsheetlist() $i = 0 Global $aWorkSheets = _Excel_SheetList($oWorkbook1) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetList Example 1", "Error listing Worksheets." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;_ArrayDisplay($aWorkSheets, "Excel UDF: _Excel_SheetList Example 1") ;_ArrayDisplay($aWorkSheets, "Array") Global $iRows = UBound($aWorkSheets, $UBOUND_ROWS) ; Total number of rows. In this example it will be 10. Global $iCols = UBound($aWorkSheets, $UBOUND_COLUMNS) ; Total number of columns. In this example it will be 20. Global $iDimension = UBound($aWorkSheets, $UBOUND_DIMENSIONS) ; The dimension of the array e.g. 1/2/3 dimensional. MsgBox($MB_SYSTEMMODAL, "", "The array is a " & $iDimension & " dimensional array with " & _ $iRows & " row(s) & " & $iCols & " column(s).") Dim $checkbox[$iRows] EndFunc ;==>excelsheetlist Func primarygui() ; Create a GUI with various controls. Local $hGUI = GUICreate("Script Controller", 300, ($iRows * 24)) ; Create a checkbox control. ;Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25) Local $Button2 = GUICtrlCreateButton("Close", 210, 200, 85, 25) Local $Button3 = GUICtrlCreateButton("Run", 210, 170, 85, 25) Local $Button1 = GUICtrlCreateButton("Discharge", 210, 140, 85, 25) For $i = 0 To UBound($checkbox) - 1 $checkbox[$i] = GUICtrlCreateCheckbox($aWorkSheets[$i][0], 8, 0 + ($i * 24)) ;, 81, 17) Next ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button2 ;Close Exit Case $nMsg = $Button1 MsgBox(0, "Discharge Button not configured", "Now Exiting") Exit Case $nMsg = $Button3 ;Run $fSelection = False For $i = 0 To UBound($checkbox) - 1 If BitAND(GUICtrlRead($checkbox[$i]), $GUI_CHECKED) Then $fSelection = True ExitLoop EndIf Next If $fSelection Then For $i = 0 To UBound($checkbox) - 1 Assign("status" & $i, GUICtrlRead($checkbox[$i])) Next $batchcount = 0 For $i = 0 To UBound($checkbox) - 1 If Eval("status" & $i) = 1 Then $batchcount = $batchcount + 1 ;Call ("o" & $i & "copy") ; if you want to call the functions directly, remove ; before the call and comment or delete the following DirCopy statement MsgBox(0, "Checking", "Checking that: " & $checkbox[$i] & " no, with title: " & $aWorkSheets[$i][0] & " was selected, Batch count: " & $batchcount) ; if you need only the DirCopy EndIf Next ExitLoop Else MsgBox(48, 'No Items Selected', 'You have not selected any Patients to Load, Please select from the list') EndIf EndSelect WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>primarygui Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func batchinitial() If Eval("status" & $i) = 1 Then debugbox() $oWorkbook1.Sheets(1).Activate $bigloop = $bigloop + 1 $sheet = $aWorkSheets[$i][0] $oWorkbook1.Sheets($sheet).Activate debugbox() EndIf EndFunc ;==>batchinitial OpenExcel() excelsheetlist() primarygui() For $i = 0 To UBound($checkbox) - 1 batchinitial() While 1 If Eval("status" & $i) = 0 Then ExitLoop ;all the rest of my script loops etc WEnd Next