fopetesl

Exit not work without button defined (NEWB)

27 posts in this topic

#1 ·  Posted (edited)

For some reason my personal notes were omitted when posting.

Still a Newb it seems! So have attached my slightly modified example.

If I comment out Exit button references script will not Exit even with windows 'X' button icon.

If I'm losing GUI/Tab focus I cannot see where is the difference with(out) definition.

GUI_No_Exit.au3

Edited by fopetesl
My notes were omitted!

The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites



#2 ·  Posted

fopetesl,

So what exactly is the problem? If you do not define a control, how do you expect it be recognised within your GUIGetMsg loop?

M23

1 person likes this

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

#3 ·  Posted (edited)

8 minutes ago, Melba23 said:

fopetesl,

So what exactly is the problem? If you do not define a control, how do you expect it be recognised within your GUIGetMsg loop?

M23

I don't follow, Melba.

The $Btn_Test still works so it is reading $msg.

The $Btn_Exit missing locks out any means of closing the program so the script now doesn't even recognise the Windows close icon.

However, if I define $Btn_Exit but do not include in the Switch statement the Windows 'X' icon now works.

Edited by fopetesl
Missed one reaction

The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites

#4 ·  Posted

fopetesl,

I understand now you have explained what happens - usually a good idea to do that in the OP.

I imagine the problem is caused by the rather odd parent-child relationship - I will take a deeper look.

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

#5 ·  Posted

fopetesl,

I knew this problem rang a bell - I ran into it some years ago when working with child windows. You need to have at least one control in the parent window or you run into focus problems - just as you do here when you can no longer focus on the main GUI to action the [X]. I asked the Devs about it at the time (in a private section of the  forum) at the time and no-one was able to explain why this happened - so I cannot offer anything further.

You can see that the "solution" works in this code:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$Main_GUI = GUICreate("Main", @DesktopWidth * 1, @DesktopHeight * 1, 0, 0,-1, $WS_EX_COMPOSITED)
GUISetState(@SW_SHOW, $Main_GUI)

$Child1_GUI = GUICreate("ExitGUI", 480, 480, 10, 10, $WS_CHILD, -1, $Main_GUI)
;$Btn_Exit = GUICtrlCreateButton("E&xit", -1, -1, 90, 20)
GUICtrlCreateLabel("", 1, 1, 0, 0) ; A control added to the parent window <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUISetState(@SW_SHOW, $Child1_GUI)

$Child2_GUI = GUICreate("Child", 200, 100, 10, 50, $WS_CAPTION)
$Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child2_GUI)

; this puts the 'child' GUI within 'master' GUI...
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI))
;sleep(5000)
;Exit
    While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE;  And now this works <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Exit
        Case $Btn_Test
            MsgBox(0, "Test", "Hit Button on Child Window")
    EndSwitch
WEnd

M23

1 person likes this

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

#6 ·  Posted

Maybe replace SetParent to create child for child?

#include <GuiConstants.au3>

$Main_GUI = GUICreate("Main", 500, 500)
GUISetBkColor(0x1B5583, $Main_GUI)
GUISetState(@SW_SHOW, $Main_GUI)

$Child1_GUI = GUICreate("ExitGUI", 480, 480, 10, 10, $WS_CHILD, -1, $Main_GUI)
GUISetState(@SW_SHOW, $Child1_GUI)

$Child2_GUI = GUICreate("Child", 200, 100, 10, 50, BitOR($WS_CAPTION, $WS_CHILD), -1, $Child1_GUI)
$Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child2_GUI)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Btn_Test
            MsgBox(0, "Test", "Hit Button on Child Window")
    EndSwitch
WEnd

 

1 person likes this

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks, M23 & InnI, nice work arounds.

Both solutions work fine :)

I was somewhat chastised previously for asking abut au3 program flow but this example suggests not as straightforward, (to me), as C coding.

I still haven't decided whether I need GUIs within GUIs or Tabs within GUI so I may be chasing my tail going down this path.

What I would really like to achieve is a simplified version of the attached....;)

Herschel_GUI.jpg

Edited by fopetesl
Missing attachment?

The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites

#8 ·  Posted

fopetesl,

What makes you say that the "program flow" is not straightforward? The  code starts at the top and works its way to the bottom.

Anyway at first glance, a GUI such as that should be really easy to code in AutoIt, but as always the devil is in the detail. What exactly are the coloured boxes and what are the elements inside them? Clickable controls or just labels? If you can explain what the each element is supposed to be, we can see if we can produce something for you.

Here  is a quick and dirty example which might give you some idea of what could be done:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Create arrays to hold details of element text and ControlID
Global $aBox_1[3][2] = [["System Setup", 0], ["My Info Tool", 0], ["User Details Tool", 0]]
Global $aBox_2[3][2] = [["Manager Reports", 0], ["Currency Details", 0], ["User Details", 0]]

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

; Create tab structure
$cTab = GUICtrlCreateTab(10, 10, 480, 350)

; Create tab item
$cTab_0 = GUICtrlCreateTabItem("Tab 0")

; And another
$cTab_0 = GUICtrlCreateTabItem("Manager")
GUICtrlSetState($cTab_0, $GUI_SHOW) ; Force ot be shown when GUI created

; Create coloured box
GUICtrlCreateLabel("", 20, 40, 150, 100)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetState(-1, $GUI_DISABLE) ; And disable so that element labels are actionable

; Add title
GUICtrlCreateLabel($aBox_1[0][0], 20, 50, 140, 20)
GUICtrlSetFont(-1, Default, 800) ; Set to bold font

; Add actionable elements from the array
For $i = 1 To UBound($aBox_1) - 1
    $aBox_1[$i][1] = GUICtrlCreateLabel($aBox_1[$i][0], 20, 60 + (20 * $i), 140, 20)
Next

; Create another coloured box
GUICtrlCreateLabel("", 20, 180, 150, 100)
GUICtrlSetBkColor(-1, 0xCCCCFF)
GUICtrlSetState(-1, $GUI_DISABLE)

; Add title
GUICtrlCreateLabel($aBox_2[0][0], 20, 190, 140, 20)
GUICtrlSetFont(-1, Default, 800)

; Add actionable elements from the array
For $i = 1 To UBound($aBox_2) - 1
    $aBox_2[$i][1] = GUICtrlCreateLabel($aBox_2[$i][0], 20, 200 + (20 * $i), 140, 20)
Next

; Create another tab item
$cTab_0 = GUICtrlCreateTabItem("Tab 2")

; Close tab structure creation
GUICtrlCreateTabItem("")

; Add other controls
$cButton_1 = GUICtrlCreateButton("Button 1", 10, 410, 80, 30)
$cButton_2 = GUICtrlCreateButton("Button 2", 410, 410, 80, 30)

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton_1
            MsgBox($MB_SYSTEMMODAL, "Clicked", "Button 1")
        Case $cButton_2
            MsgBox($MB_SYSTEMMODAL, "Clicked", "Button 2")
        Case Else
            ; Now look for the ControlID in the arrays
            For $i = 1 To UBound($aBox_1) - 1
                If $iMsg = $aBox_1[$i][1] Then
                    ; It was this element
                    MsgBox($MB_SYSTEMMODAL, "Clicked", $aBox_1[$i][0])
                    ; No point in looking further
                    ExitLoop
                EndIf
            Next
            For $i = 1 To UBound($aBox_2) - 1
                If $iMsg = $aBox_2[$i][1] Then
                    MsgBox($MB_SYSTEMMODAL, "Clicked", $aBox_2[$i][0])
                    ExitLoop
                EndIf
            Next
    EndSwitch

WEnd

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

#9 ·  Posted

Why not just use koda? Should take like 10 mins for the gui

Share this post


Link to post
Share on other sites

#10 ·  Posted

M23. My excuse? Even older than older!

Neat example M23. I look forward to the day I can generate code like that so apparently easily ... if I live that long :)

The GUI I showed is  an example of a manufacturing control program. Each tab has multiple choices each will open a sub GUI with more information to enter/search/view/edit.  I like it because it's uncomplicated and user friendly.

There's little point in amplifying more since my end result will be quite different,  What I need to generate is a complete rewrite of a messy complicated IT-person-designed machine control and data capture/display program in LINUX.  I have the task of doing the same in Windows without the complication of mixed software disciplines.

So, there will be one tab or GUI for each operation. 1) Scan a sample. Operator enters relevant parameters.  Then by calling a program using telnet to send commands and receive data.  Received data, after processing with C program, is displayed as a graph with numerical detail. Data then saved as a unique file.

2) Retrieve scans' data and display/print/copy similar to 1) so needs to access usual Windows print options.

As usual, devil is in the detail. Producing on screen graph with dual scaled plots with AutoIt? Showing progress of background program(s)?


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites

#11 ·  Posted

fopetesl,

Quote

Each tab has multiple choices each will open a sub GUI with more information to enter/search/view/edit

Sounds like AutoIt would be a perfect tool in which to write this - and the above example should give you a good pointer as to how to go about it. Do not hesitate to come back and ask for help with any aspects that you find difficult.

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

#12 ·  Posted

On 07/03/2017 at 11:34 AM, gononono64 said:

Why not just use koda? Should take like 10 mins for the gui

Would you care to elucidate, GoNoNo?

 


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites

#13 ·  Posted

fopetesl,

Koda is a utility to help you create your GUIs using a graphical interface - personally I do not use it as I find manual coding of control position just as quick, but some swear by it. Of course the utility only deals with the GUI section of your script - you still have to do all the "bread and butter" coding to get the pretty GUI to actually do anything.

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

#14 ·  Posted

I have to say, M23, that I grow ever more impressed with the AutoIt community.

The proliferation of UDFs and camaraderie is amazing.  Nothing like it on any other forum I have been a member of.

Here one doesn't get ignored :)

 


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites

#15 ·  Posted

fopetesl,

Delighted to hear it.

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

#16 ·  Posted

Slightly puzzled:

; Create tab item
$cTab_0 = GUICtrlCreateTabItem("Tab 0")

; And another
$cTab_0 = GUICtrlCreateTabItem("Manager")
GUICtrlSetState($cTab_0, $GUI_SHOW) ; Force ot be shown when GUI created

Same variable $cTab_0 used twice for different definitions?

This is by design? If so what am I missing?


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites

#17 ·  Posted

fopetesl,

"Cut and paste" error - I did say the code was "quick and dirty"!

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

#18 ·  Posted

Another lost focus? Where's my cut & paste typo :(

;;;; Acquisition tab and action boxes......
; Create tab item
$cTab_0 = GUICtrlCreateTabItem("Acquisition")
; Create coloured box
  GUICtrlCreateLabel("", 20, 40, 250, 220,-1,1)
  GUICtrlSetBkColor(-1, 0xAFEEEE)
  GUICtrlSetState(-1, $GUI_DISABLE) ; And disable so that element labels are actionable
; Add title
  GUICtrlCreateLabel("New Sample", 20, 50, 240, 200, $SS_CENTER)
  GUICtrlSetFont(-1, 10, 800) ; Set to bold font
;  $0Box_1 = GUICtrlCreateLabel("Scan", 25, 80, 140, 20,$SS_CENTER)
  $0Box_1 = GUICtrlCreateLabel("Scan", 20, 20, 140, 20,$SS_CENTER) ;<<< works outside of box
; add baseline check and/or scan
;;;; ...end..Acquisition tab and action boxes......
;
;
;
While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
 ;       Case $cButton_1
 ;           MsgBox($MB_SYSTEMMODAL, "Clicked", "Button 1")
 ;       Case $cButton_2
 ;           MsgBox($MB_SYSTEMMODAL, "Clicked", "Button 2")
        Case $0Box_1
             MsgBox($MB_SYSTEMMODAL, "Clicked", "Scan!")
        Case Else
            ; Now look for the ControlID in the arrays
            For $i = 1 To UBound($aBox_1) - 1
                If $iMsg = $aBox_1[$i][1] Then
                    ; It was this element
                    MsgBox($MB_SYSTEMMODAL, "Clicked", $aBox_1[$i][0])
                    ; No point in looking further
                    ExitLoop
                EndIf
            Next

If I position $0Box_1 outside of GUICtrlCreateTabItem("Acquisition") the Case reacts as coded. Positioned inside the box it doesn't react, so I've lost focus?


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites

#19 ·  Posted

fopetesl,

Please post a runnable script which shows the problem or we have little chance of finding a solution as it could well be the result of factors other than the tab structure and will not appear if we add our own GUI code

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

#20 ·  Posted

 

OK, will remember for future.. here it is...

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>

; Create arrays to hold details of element text and ControlID
Global $aBox_1[3][2] = [[" System Setup", 0], [" My Info Tool", 0], [" User Details Tool", 0]]
Global $aBox_2[3][2] = [[" Manager Reports", 0], [" Currency Details", 0], [" User Details", 0]]

; Create GUI
 $hGUI = GUICreate("New GUI", @DesktopWidth * .99, @DesktopHeight * .96, 0, 0,-1)

; Create tab structure
$cTab = GUICtrlCreateTab(5, 5, @DesktopWidth * .97, @DesktopHeight * .95,-1,1)

;;;; Acquisition tab and action boxes......
; Create tab item
$cTab_0 = GUICtrlCreateTabItem("Acquisition")
; Create coloured box
  GUICtrlCreateLabel("", 20, 40, 250, 220,-1,1)
  GUICtrlSetBkColor(-1, 0xAFEEEE)
  GUICtrlSetState(-1, $GUI_DISABLE) ; And disable so that element labels are actionable
; Add title
  GUICtrlCreateLabel("New Sample", 20, 50, 240, 200, $SS_CENTER)
  GUICtrlSetFont(-1, 10, 800) ; Set to bold font
;  $0Box_1 = GUICtrlCreateLabel("Scan", 25, 80, 140, 20,$SS_CENTER)
  $0Box_1 = GUICtrlCreateLabel("Scan", -1, 260, 140, 20,$SS_CENTER)
  GUICtrlSetFont(-1, 10, 800) ; Set to bold font
  $0Box_2 = GUICtrlCreateLabel("Start Scan", -1, 100, 140, 20,$SS_CENTER)
  GUICtrlSetFont(-1, 10, 800) ; Set to bold font
;;;; ...end..Acquisition tab and action boxes......

;;;;  Manager tab and action boxes......
; And another
$cTab_1 = GUICtrlCreateTabItem("Manager")
GUICtrlSetState($cTab_1, $GUI_SHOW) ; Force to be shown when GUI created
; Create coloured box
GUICtrlCreateLabel("", 20, 40, 150, 100,-1,1)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetState(-1, $GUI_DISABLE) ; And disable so that element labels are actionable
; Add title
GUICtrlCreateLabel($aBox_1[0][0], 20, 50, 140, 20)
GUICtrlSetFont(-1, Default, 800) ; Set to bold font
; Add actionable elements from the array
For $i = 1 To UBound($aBox_1) - 1
    $aBox_1[$i][1] = GUICtrlCreateLabel($aBox_1[$i][0], 20, 60 + (20 * $i), 140, 20)
Next
; Create another coloured box
GUICtrlCreateLabel("", 20, 180, 150, 100,-1,1)
GUICtrlSetBkColor(-1, 0xCCCCFF)
GUICtrlSetState(-1, $GUI_DISABLE)
; Add title
GUICtrlCreateLabel($aBox_2[0][0], 20, 190, 140, 20)
GUICtrlSetFont(-1, Default, 800)
; Add actionable elements from the array
For $i = 1 To UBound($aBox_2) - 1
    $aBox_2[$i][1] = GUICtrlCreateLabel($aBox_2[$i][0], 20, 200 + (20 * $i), 140, 20)
Next
;;;;;;;;; ..end.. Manager tab & action boxes ;;;;;;;;

;;;;;;;;  Database tab & action boxes.....
; Create another tab item
$cTab_0 = GUICtrlCreateTabItem("Database")
;;;;;;;; ..end.. Database tab & action boxes.....

; Close tab structure creation
GUICtrlCreateTabItem("")

; Add other controls
;$cButton_1 = GUICtrlCreateButton("Button 1", 10, 410, 80, 30)  ; actionable :))
;$cButton_2 = GUICtrlCreateButton("Button 2", 410, 410, 80, 30)

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
 ;       Case $cButton_1
 ;           MsgBox($MB_SYSTEMMODAL, "Clicked", "Button 1")
 ;       Case $cButton_2
 ;           MsgBox($MB_SYSTEMMODAL, "Clicked", "Button 2")
        Case $0Box_1
             MsgBox($MB_SYSTEMMODAL, "Clicked", "Scan")
        Case $0Box_2
             MsgBox($MB_SYSTEMMODAL, "Clicked", "Start Scan")
        Case Else
            ; Now look for the ControlID in the arrays
            For $i = 1 To UBound($aBox_1) - 1
                If $iMsg = $aBox_1[$i][1] Then
                    ; It was this element
                    MsgBox($MB_SYSTEMMODAL, "Clicked", $aBox_1[$i][0])
                    ; No point in looking further
                    ExitLoop
                EndIf
            Next
            For $i = 1 To UBound($aBox_2) - 1
                If $iMsg = $aBox_2[$i][1] Then
                    MsgBox($MB_SYSTEMMODAL, "Clicked", $aBox_2[$i][0])
                    ExitLoop
                EndIf
            Next
    EndSwitch

WEnd

 


The most powerful number in the Universe.  Zero.

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

  • Similar Content

    • IamKJ
      By IamKJ
      So I have a lot of different functions in the little program I'm making.  Most of them use the Do statement, such as finding images, clicking buttons, etc.
       
      The question I have is how would I be able to both
      1) Create a hotkey to pause whatever I am doing at the moment.  If I have to put something into every function in the program, I don't mind.
      2) Create a hotkey to exit whatever I am doing and stop all loops or commands and bring back the main GUI?
    • ur
      By ur
      I have created an exit function and registered using OnAutoItExitRegister.But it is not running when I close the app from taskbar or even with normal exit during end.
       
      Below is the part of code and the included files.
      #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <WinAPIFiles.au3> #include <Date.au3> #include <file.au3> #include <Array.au3> #include <String.au3> OnAutoItExitRegister("Exit_Program") Func Exit_Program() LoggingMainScr("Entered Exit_Program") Local $exitmethod = ["Natural closing", "close by Exit function", "close by clicking on exit of the systray","close by user logoff","close by Windows shutdown"] ExitProgram("Exit with exit code: "& @exitCode & " And because of: " & $exitmethod[@exitmethod],@exitmethod) EndFunc Func ExitProgram($sReason="Exit by user",$sCode=0) LoggingMainScr($sReason) if $sCode <> 0 then LoggingMainScr("stopped before completion") FileDelete(@ScriptDir&"\Machines*.txt") FileDelete(@ScriptDir&"\PsExec.exe") FileDelete(@ScriptDir&"\HyperVMachines.ps1") FileDelete(@ScriptDir&"\VMwareMachines.ps1") EndFunc Func LoggingMainScr($sMessage) LoggingDefault($sMessage,@ScriptDir&"\MainScr_Logging.log") EndFunc Func LoggingDefault($sMessage,$sLogFile=@ScriptDir&"\Logging.log") If $sMessage = "" Then FileWriteLine($sLogFile, "") Else FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF) EndIf EndFunc Any suggestion.
       
    • fosil
      By fosil
      Hi all,

      I'm working on a relatively complex automation program and I need it to call a specific function when it is closed by a user. Ive resorted to "OnAutoItExitRegister" as i believe that's the only option available.

      This command works perfectly fine in a small scale test application I wrote, but once implemented in the final program that's much larger and divided over many files in many directories it no longer works. I don't get any error messages.

      My question is has anyone encountered an issue where implementation of this command in a large scale program gave them trouble? Does it matter where "OnAutoItExitRegister" is called and where the function is located? Currently they are both places in the main file that runs the whole program but it still doesn't work.

      Any help is appreciated
    • Masum
      By Masum
      Hi all,
      Ctrl+Break stops script only if AutoIt window is active. It doesn't work while automation is going on elsewhere.
      Is there a way to stop the script regardless of where the automation is happening?
      Thanks
    • crushyna
      By crushyna
      Hi everyone!
      I'm developing small testing tool for new software in my company.
      Tool itself is working correctly (it follows scripted test commands one by one), but I'm trying to develop an error checking function.

      Mechanics are simple: every time software (external) shows specific error (via window class), program asks for next step. Continue, or abort test (and return to main GUI)?
      The error check function is switched on/off via Checkbox in GUI.

      Here are some code fragments:

      Checkbox:
      Global $idCheckbox1 = GUICtrlCreateCheckbox("Enable TP.net error handling", 352, 40, 249, 17) GUICtrlSetFont(-1, 12, 400, 0, "Calibri") GUICtrlSetColor(-1, 0x000000)  
      Checkbox switch:
      GUISetState(@SW_SHOW) Local $Choosen While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idCheckbox1 If _IsChecked($idCheckbox1) Then $cSwitch1 = 1 Else $cSwitch1 = 0 EndIf Case $idAddTest (and so on...)  
      Function call:
      (alot of ElseIf commands...) ElseIf $aItem = $idOperatorIn Then WywolanieOkna() WinActivate($hFSO) ControlClick($hFSO, "", "[NAME:lblCashierNumber]") Sleep($Sleep_05) Send("0000019{Enter}19{Enter 2}") Sleep($Sleep_75) EndIf #EndRegion ### START ELSEIF ARMY ### Next If $cSwitch1 = 1 Then MsgBox( 0, "Error check!", "Error check ON!") /// just for testing purposes CheckError() Else Return EndIf EndSwitch WEnd
      Classic _IsChecked function:
      Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked  
      And Checkerror() function itself:
      Func CheckError() Local $Answer If ControlCommand($hMsgPanel, "", "[NAME:panelMsgBox]", "IsEnabled", "") Then ;~ Sleep($Sleep_05) $Answer = MsgBox(52, "Error!", "An error occured! Continue testing?") ;~ Sleep($Sleep_05) Switch $Answer Case 6 MsgBox(0, "Error!", "Test will now continue.", 3) Send("{Enter}") WinActivate($hWnd) Return Case 7 MsgBox(64, "Error!", "Test cancelled.", 5) $ElseIfArmyOff = 1 ControlClick($hMsgPanel, "", "[NAME:cmdOK]") WinActivate($AppName) #cs MsgBox( 0, "test1", $idTSList) Local $idTSListCopy For $i = 0 to _GUICtrlListView_GetItemCount($idTSList) - 1\ #ce $idTSListCopy = _GUICtrlListView_GetItemTextString($idTestCaseList, $LoopCount) ExitLoop EndSwitch EndIf Return 1 EndFunc ;==>CheckError
      Problem is: i can't make this function (CheckError() ) return to main gui state, that means: break the If/ElseIf loop.
      The switch is working correctly (MsgBox on error shows only when it's activated).
      Checkerror() function works correctly - recognizes the error, stops script until decision is made. But it doesn't terminate If/ElseIf loop.

      Any help appreciated!