Jump to content

GUI issue


Recommended Posts

I helped Infinitex0 with his issue and got him on the right track. But I am new and found some issues - I am trying to keep the main window open and do not know how. It works most of the time the way it should but when I click on button1 from title1 it pops up title2 then I move title2 anywhere and click on button4 and then close title3 then try to close title2 - that is where the trouble starts - it does not close.

http://www.autoitscript.com/forum/index.ph...35entry159335

Question: How do you make sure the first window that opens - stays open and you can continue the program until the main window is closed.

Mind you as I have posted before I am very new to all this - but got hooked right away. The coding style I hope will come, as I have no idea what makes it go faster or slower based on what functions you use.

Thanks for any help.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        nitekram
;
; Script Function:
;   GUI Testing
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIconstants.au3>
Global $var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8, $var9, $var10, $var11, $running = 1


; starting function call
While $running = 1
    $running = _main()
WEnd


Func _main()
    GUICreate("Title1")
    $var1 = GUICtrlCreateButton("button1", 0, 0)
    $var2 = GUICtrlCreateButton("button2", 50, 0)
    $var3 = GUICtrlCreateButton("button3", 100, 0)
    GUISetState(@SW_SHOW)
    
    While 1
        $var4 = GUIGetMsg()
        Select
            Case $var4 = $GUI_EVENT_CLOSE
                Exit
            Case $var4 = $var1
                _make_title2()


            Case $var4 = $var2
                _make_title4()
            Case $var4 = $var3
                _make_title5()
            ;_click_button9()
                
                
        EndSelect
    WEnd
    
    Return 1
EndFunc  ;==>_main


func _make_title2()
    Select
        Case $var4 = $var1  
                GUICreate("Title2")
                $var5 = GUICtrlCreateButton("button4", 0, 0)
                GUISetState(@SW_SHOW)
                _click_button4()
    EndSelect
EndFunc             





Func _make_title4()
    Select
        Case $var4 = $var2
            GUICreate("Title4")
            $var6 = GUICtrlCreateButton("button5", 76, 249)
            $var7 = GUICtrlCreateButton("button6", 155, 75)
            $var8 = GUICtrlCreateButton("button7", 250, 247)
            $var9 = GUICtrlCreateButton("button8", 155, 300)
        ;GUICtrlCreatePic("Pic1", 100, 100)
            GUISetState(@SW_SHOW)
            _click_title4_button()
    EndSelect
EndFunc  ;==>_make_title4

Func _make_title5()
    Select
        Case $var4 = $var3
            GUICreate("Title5")
            $var10 = GUICtrlCreateButton("button9", 0, 0)
        ;GUICtrlCreatePic("Pic1", 100, 100)
            GUISetState(@SW_SHOW)
            _click_button9()
    EndSelect
    
    
EndFunc  ;==>_make_title5
;   WEnd





Func _click_button4()
    While 1
        $var4 = GUIGetMsg()
        Select
            Case $var4 = $GUI_EVENT_CLOSE
                _main();Exit
                
            Case $var4 = $var5
                MsgBox(4096, "Title3", "Text1" & @CRLF & @CRLF & "text2" & @CRLF & @CRLF & "text3" & @CRLF & @CRLF & "text4" & @CRLF & @CRLF & "text5" & @CRLF & @CRLF & "text6")
        EndSelect
    WEnd
EndFunc  ;==>_click_button4

Func _click_title4_button()
    While 1
        $var4 = GUIGetMsg()
        Select
            Case $var4 = $GUI_EVENT_CLOSE
                _main();Exit
            Case $var4 = $var6
                MsgBox(0, "button5-Title4", "text")
            Case $var4 = $var7
                MsgBox(0, "button6-Title5", "text")
            Case $var4 = $var8
                MsgBox(0, "button7-Title6", "text")
            Case $var4 = $var9
                MsgBox(0, "button8-Title7", "text")
        EndSelect
    WEnd
EndFunc  ;==>_click_title4_button

Func _click_button9()
    While 1
        $var4 = GUIGetMsg()
        Select
            Case $var4 = $GUI_EVENT_CLOSE
                _main();Exit
            Case $var4 = $var10
                MsgBox(0, "Title6", "text")
        EndSelect
    WEnd
EndFunc  ;==>_click_button9

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Your problem come from the fact that you are using several incomplete While loop checking only some event and that the $GUI_EVENT_CLOSE get confuse of the GUI you are in as you create several GUI and several loop msg checking.

I think the easiest is to use the opt("GUIOnEventMode",1) that will force you to define a routine by event and do the action you want inside.

Look at the doc I hope it is not too complicated to understand.

Good luck

Link to comment
Share on other sites

or simply

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        nitekram
;
; Script Function:
;   GUI Testing
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIconstants.au3>
;Global $var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8, $var9, $var10, $var11, $running = 1







$GUI_1 = GUICreate("Title1");, "", "", -1, -1, "" )
$var1 = GUICtrlCreateButton("button1", 0, 0)
$var2 = GUICtrlCreateButton("button2", 50, 0)
$var3 = GUICtrlCreateButton("button3", 100, 0)
GUISetState()

$GUI_2 = GUICreate("Title2")
$var5 = GUICtrlCreateButton("button4", 0, 0)
GUISetState(@SW_HIDE)


$GUI_4 = GUICreate("Title4")
$var6 = GUICtrlCreateButton("button5", 76, 249)
$var7 = GUICtrlCreateButton("button6", 155, 75)
$var8 = GUICtrlCreateButton("button7", 250, 247)
$var9 = GUICtrlCreateButton("button8", 155, 300)
;GUICtrlCreatePic("Pic1", 100, 100)
GUISetState(@SW_HIDE)

$Gui_5 = GUICreate("Title5")
$var10 = GUICtrlCreateButton("button9", 0, 0)
;GUICtrlCreatePic("Pic1", 100, 100)
GUISetState(@SW_HIDE)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            
            If WinActive($GUI_2) Then
                GUISetState(@SW_HIDE, $GUI_2)
            ElseIf WinActive($GUI_4) Then
                GUISetState(@SW_HIDE, $GUI_4)
            ElseIf WinActive($Gui_5) Then
                GUISetState(@SW_HIDE, $Gui_5)
            ElseIf WinActive($GUI_1) Then
                Exit
            EndIf
            $msg = ""
        Case $msg = $var1
            GUISetState(@SW_SHOW, $GUI_2)
        Case $msg = $var2
            GUISetState(@SW_SHOW, $GUI_4)
        Case $msg = $var3
            GUISetState(@SW_SHOW, $Gui_5)
        Case $msg = $var5
            MsgBox(4096, "Title3", "Text1" & @CRLF & @CRLF & "text2" & @CRLF & @CRLF & "text3" & @CRLF & @CRLF & "text4" & @CRLF & @CRLF & "text5" & @CRLF & @CRLF & "text6")
        Case $msg = $var6
            MsgBox(0, "button5-Title4", "text")
        Case $msg = $var7
            MsgBox(0, "button6-Title5", "text")
        Case $msg = $var8
            MsgBox(0, "button7-Title6", "text")
        Case $msg = $var9
            MsgBox(0, "button8-Title7", "text")
        Case $msg = $var10
            MsgBox(0, "Title6", "text")
            
    EndSelect
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

or simply

You make it look so simple - all you. I do not mean anything when I say that - I really do admire

your abilities - that is why I want to learn so I can be that good. I really like the communication that you all share with us wantabees. As for the coding that you did - I understand the code, but I am having

a hard time with writing it. I would never even thought about it with out an example - you could say I am a tweaker (not drugs) with scripts I read as many as I can and I can change the easy stuff but when it comes to writing well - THATS HARD - I am going to work on this and really try to understand it and see what I can come up with.

Thanks Valuater

I think the easiest is to use the opt("GUIOnEventMode",1) that will force you to define a routine by event and do the action you want inside.

Look at the doc I hope it is not too complicated to understand.

jpm - Can you tell me where I can find more info on 'opt()' I search for it through help and could not located it. What doc - ?

I have to go but I will work on this later - and again thanks

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

You make it look so simple - all you. I do not mean anything when I say that - I really do admire

your abilities - that is why I want to learn so I can be that good. I really like the communication that you all share with us wantabees. As for the coding that you did - I understand the code, but I am having

a hard time with writing it. I would never even thought about it with out an example - you could say I am a tweaker (not drugs) with scripts I read as many as I can and I can change the easy stuff but when it comes to writing well - THATS HARD - I am going to work on this and really try to understand it and see what I can come up with.

Thanks Valuater

jpm - Can you tell me where I can find more info on 'opt()' I search for it through help and could not located it. What doc - ?

I have to go but I will work on this later - and again thanks

Ifyou type opt in the search tab you get the first one which is AutoItSetOption.

But for your case you better read the GUI OnEvent Mode page

:)

Link to comment
Share on other sites

Ifyou type opt in the search tab you get the first one which is AutoItSetOption.

But for your case you better read the GUI OnEvent Mode page

:)

OK - I guess this is way to hard for me - so I will ask the experts:

This came from the help area - but is does not show the second window..."Dummy window for testing"

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 
$mainwindow = GUICreate("Hello World", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")

$dummywindow = GUICreate("Dummy window for testing ", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUISwitch($mainwindow)
GUISetState(@SW_SHOW)

While 1
  Sleep(1000) ; Idle around
WEnd

Func OKButton()
 ;Note: at this point @GUI_CTRLID would equal $okbutton

  MsgBox(0, "GUI Event", "You pressed OK!")
  
EndFunc

Func CLOSEClicked()
 ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
 ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
  EndIf 
EndFunc

I can not figure it out -

The code that I tried below, I would think would work - but does not - please tell me how I can use GuiOnEvent to open another function that will create a window that I can close and still keep the main (first window open)

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 
$mainwindow = GUICreate("Hello World", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")

$dummywindow = GUICreate("Dummy window for testing ", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUISwitch($mainwindow)
GUISetState(@SW_SHOW)

While 1
  Sleep(1000) ; Idle around
WEnd

Func OKButton()
 ;Note: at this point @GUI_CTRLID would equal $okbutton
  GUISwitch($dummywindow)  ;  This does not work
  GUISetState(@SW_SHOW) ; This does not work
  MsgBox(0, "GUI Event", "You pressed OK!")
  
EndFunc

Func CLOSEClicked()
 ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
 ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
  EndIf 
EndFunc

- another question I would have - it is possible to send variables with the function call

When I try this I get an ERROR

- GUISetOnEvent($somebuttonpressed, "buttonPressed(some variable)")

C:\programming\gui-sample.au3(8,47) : ERROR: OKButton($test)(): undefined function.

GUICtrlSetOnEvent($okbutton, "OKButton($test)")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\programming\gui-sample.au3 - 1 error(s), 0 warning(s)

When I try this I get an ERROR

- GUISetOnEvent($somebuttonpressed, "buttonPressed"(some variable))

C:\programming\gui-sample.au3(8,40) : ERROR: syntax error

GUICtrlSetOnEvent($okbutton, "OKButton"(

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\programming\gui-sample.au3(5,47) : ERROR: CLOSEClicked(): undefined function.

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\programming\gui-sample.au3 - 2 error(s), 0 warning(s)

When I try this I get an ERROR

- GUISetOnEvent($somebuttonpressed, buttonPressed(some variable))

States that I am using a variable before being declared - I have the variable set as global

Any help would be a great help to me - thanks again

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

OK - I guess this is way to hard for me - so I will ask the experts:

This came from the help area - but is does not show the second window..."Dummy window for testing"

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode 
$mainwindow = GUICreate("Hello World", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")

$dummywindow = GUICreate("Dummy window for testing ", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUISwitch($mainwindow)
GUISetState(@SW_SHOW)

While 1
  Sleep(1000); Idle around
WEnd

Func OKButton()
;Note: at this point @GUI_CTRLID would equal $okbutton

  MsgBox(0, "GUI Event", "You pressed OK!")
  
EndFunc

Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
  EndIf 
EndFunc
oÝ÷ Øz-~(.­è­¢ëSç(uëajÒ-®'méhÀ(ºWm)äÂ¥w
+»­v¬iæ¬z×¥g¡£j{¬xk¢:q/z{m¢^©è¶«~éܶ*'¶­Â)er·µæ°whÂØZ´Éh±æ§vËbYzazf¢ø«²Ü"Ú0¢§2"¯zê]j×­ç(uëh¶¼¬¢g­)àz[jwb¶Z(ÉbëazÇ¢wpwhÂÈhÂÆî´z-rZ,z+H«Þj¢·Úòx-¡ø º·­+(ºÒ;¬¶z-jÉ"è®Ç+HÁ©í¶§uê쵩ÝÒè¢F­¶­­ªl¶­"¯z)é§jw^½êò¶§Z(ÊânØ¥"Úòjw¶¬yÊ'w]ºi²ßÜ"Ú0jëh×6
#include <GUIConstants.au3>
global $test=1
Opt("GUIOnEventMode", 1); Change to OnEvent mode 
$mainwindow = GUICreate("Hello World", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")
;GUICtrlSetOnEvent($okbutton, OKButton($test))

$dummywindow = GUICreate("Dummy window for testing ", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUISwitch($mainwindow)
GUISetState(@SW_SHOW)

While 1
  Sleep(1000); Idle around
WEnd

;Func OKButton($test)
Func OKButton()

;Note: at this point @GUI_CTRLID would equal $okbutton
  GUISetState(@SW_HIDE)
  GUISwitch($dummywindow)
  if $dummywindow = "Dummy window for testing " & @GUI_WINHANDLE =  "Dummy window for testing " then  MsgBox('',"@GUI_WINHANDLE",@GUI_WINHANDLE)
  
  GUISetState(@SW_SHOW)
   GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
  MsgBox(0, "GUI Event", "You pressed OK!")
  
 
EndFunc

Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
ElseIf @GUI_WINHANDLE =  "Dummy window for testing " then  
      MsgBox('',"GUI Event", "@GUI_WINHANDLE = Dummy window for testing ")
      GUIDelete(@GUI_WINHANDLE)
  EndIf 
EndFunc
oÝ÷ Ù*+¯&¢ëméZ²×(u楲¬"w¯z»h¢J.¶Ø^r¦z{hØ^«-)Þ'Úº[ç$¶¬¢ëHë-¦·¬±çBMÒ¶§)ත¶¬Â¥vƯzl©¢Ëe¢S²)Üxz-­êeÊÚ&Ê'¦-"­jÇ«½êÞ®º+!©©¢Ëb ÞÁÊy«­¢+Ø(¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì)±½°ÀÌØíÑÍÐôÄ)=ÁÐ ÅÕ½ÐíU%=¹Ù¹Ñ5½ÅÕ½Ðì°Ä¤ì
¡¹Ñ¼=¹Ù¹Ðµ½(ÀÌØíµ¥¹Ý¥¹½ÜôU%
ÉÑ ÅÕ½Ðí!±±¼]½É±ÅÕ½Ðì°ÈÀÀ°ÄÀÀ¤)U%MÑ=¹Ù¹Ð ÀÌØíU%}Y9Q}
1=M°ÅÕ½Ðí
1=M
±¥­ÅÕ½Ðì¤)U%
Ñɱ
ÉÑ1° ÅÕ½Ðí!±±¼Ý½É±ÌÌì!½ÜÉå½ÔüÅÕ½Ðì°ÌÀ°ÄÀ¤(ÀÌØí½­ÕÑѽ¸ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí=,ÅÕ½Ðì°ÜÀ°ÔÀ°ØÀ¤)U%
ÑɱMÑ=¹Ù¹Ð ÀÌØí½­ÕÑѽ¸°ÅÕ½Ðí=- ÕÑѽ¸ÅÕ½Ðì¤(íU%
ÑɱMÑ=¹Ù¹Ð ÀÌØí½­ÕÑѽ¸°=-   ÕÑѽ¸ ÀÌØíÑÍФ¤((ÀÌØíÕµµåÝ¥¹½ÜôU%
ÉÑ ÅÕ½ÐíÕµµäÝ¥¹½Ü½ÈÑÍÑ¥¹ÅÕ½Ðì°ÈÀÀ°ÄÀÀ¤)U%MÑ=¹Ù¹Ð ÀÌØíU%}Y9Q}
1=M°ÅÕ½Ðí
1=M
±¥­ÅÕ½Ðì¤()U%MÝ¥Ñ  ÀÌØíµ¥¹Ý¥¹½Ü¤)U%MÑMÑÑ¡M]}M!=¤()]¡¥±Ä(M±À ÄÀÀÀ¤ì%±É½Õ¹)]¹((íÕ¹=-   ÕÑѽ¸ ÀÌØíÑÍФ)Õ¹=-  ÕÑѽ¸ ¤((í9½ÑèÐÑ¡¥ÌÁ½¥¹ÐU%}
QI1%ݽձÅÕ°ÀÌØí½­ÕÑѽ¸(U%MÑMÑÑ¡M]}!%¤(U%MÝ¥Ñ  ÀÌØíÕµµåÝ¥¹½Ü¤(¥ÀÌØíÕµµåÝ¥¹½ÜôÅÕ½ÐíÕµµäÝ¥¹½Ü½ÈÑÍÑ¥¹ÅÕ½ÐìµÀìU%}]%9!91ôÀÌØíÕµµåÝ¥¹½ÜÑ¡¸5Í ½à ÌäìÌäì°ÅÕ½ÐíU%}]%9!91ÅÕ½Ðì±U%}]%9!91¤((U%MÑMÑÑ¡M]}M!=¤(U%MÑ=¹Ù¹Ð ÀÌØíU%}Y9Q}
1=M°ÅÕ½Ðí
1=M
±¥­ÅÕ½Ðì¤(5Í  ½à À°ÅÕ½ÐíU$Ù¹ÐÅÕ½Ðì°ÅÕ½Ðíe½ÔÁÉÍÍ=,ÌÌìÅÕ½Ðì¤(()¹Õ¹()Õ¹
1=M
±¥­ ¤(í9½ÑèÐÑ¡¥ÌÁ½¥¹ÐU%}
QI1%ݽձÅÕ°ÀÌØíU%}Y9Q}
1=(íU%}]%9!91Ý¥±°¥Ñ¡ÈÀÌØíµ¥¹Ý¥¹½Ü½ÈÀÌØíÕµµåÝ¥¹½Ü(%U%}]%9!91ôÀÌØíµ¥¹Ý¥¹½ÜQ¡¸(%5Í  ½à À°ÅÕ½ÐíU$Ù¹ÐÅÕ½Ðì°ÅÕ½Ðíe½Ô±¥­
1=M¥¸Ñ¡µ¥¸Ý¥¹½ÜÌÌìá¥Ñ¥¹¸¸¸ÅÕ½Ðì¤(%á¥Ð)±Í%U%}]%9!91ôÀÌØíÕµµåÝ¥¹½ÜÑ¡¸($5Í ½à ÌäìÌäì°ÅÕ½ÐíU$Ù¹ÐÅÕ½Ðì°ÅÕ½ÐíU%}]%9!91ôÕµµäÝ¥¹½Ü½ÈÑÍÑ¥¹ÅÕ½Ðì¤($U%±Ñ¡U%}]¥¹!¹±¤ìQ¡¥Ì¥¹½Ðݽɬ´±½ÍÑ¡Áɽɴ´ÕХе¥¡ÐÍÑ¥±°Ý½É­¥¹($%U%MÝ¥Ñ  ÀÌØíµ¥¹Ý¥¹½Ü¤($%U%MÑMÑÑ¡M]}M!=¤$(¹%)¹Õ¹((

Now the looping problem is that I cannot do it twice - any ideas

EDIT 10/14/06 changed the tags to [*autoit] [*/autoit]

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

update some code and would like some direction - thanks

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Sorry about the double post - but I think I am really close to fixing my issue - I am just woried about the timing - after the first pass the dummy gui seems to have a pause before it is created again.

Can someone look at this and help me find out what I am doing wrong - even if you have to be BLUNT i just want to learn -

Again remember I am a new programmer so my mind does not work like yours - i still think in 10's and you all think in 1's & 0's

Thanks for any help.

#include <GUIConstants.au3>
Global $test = 1, $dummywindow
Opt("GUIOnEventMode", 1); Change to OnEvent mode
$mainwindow = GUICreate("Hello World", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")
;GUICtrlSetOnEvent($okbutton, OKButton($test))

CreateDummyWindow()
While 1
    Sleep(1000); Idle around
WEnd

Func CreateDummyWindow()
    
    $dummywindow = GUICreate("Dummy window for testing ", 200, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    
    GUISwitch($mainwindow)
    GUISetState(@SW_SHOW)
    WinActivate($mainwindow);trying to make it active
    
    
EndFunc ;==>CreateDummyWindow

;Func OKButton($test)
Func OKButton()
    CreateDummyWindow()
;Note: at this point @GUI_CTRLID would equal $okbutton
    If @GUI_WinHandle = $mainwindow Then
        GUISetState(@SW_HIDE)
        GUISwitch($dummywindow)
        GUISetState(@SW_SHOW)
        WinActivate($dummywindow);trying to make it active
;  if $dummywindow = "Dummy window for testing " & @GUI_WINHANDLE = $dummywindow then  MsgBox('',"@GUI_WINHANDLE",@GUI_WINHANDLE)
        
        
        GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    ElseIf @GUI_WinHandle = $dummywindow Then
        GUISwitch($dummywindow)
        GUISetState(@SW_SHOW)
        
        WinActivate($dummywindow);trying to make it active
;MsgBox(0, "pressed the OK BUTTON", $dummywindow)
        
        
        MsgBox('', "GUI Event", "@GUI_WINHANDLE = Dummy window for testing " & $dummywindow)
    EndIf
    
    
    
;  if $dummywindow = "Dummy window for testing " & @GUI_WINHANDLE = $dummywindow then  MsgBox('',"@GUI_WINHANDLE",@GUI_WINHANDLE)
    
;   GUISetState(@SW_SHOW)
;   GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
;MsgBox(0, "GUI Event", "You pressed OK!")
    
    
EndFunc ;==>OKButton

Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
    If @GUI_WinHandle = $mainwindow Then
        MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
        Exit
    ElseIf @GUI_WinHandle = $dummywindow Then
        MsgBox('', "GUI Event", "@GUI_WINHANDLE = Dummy window for testing ")
        GUIDelete(@GUI_WinHandle); This did not work - removed the gui 'dummy'
;                                                                               - but it might still be working-> need to recreate the GUI
        GUISwitch($mainwindow)
        GUISetState(@SW_SHOW)
        WinActivate($mainwindow);trying to make it active
    EndIf
EndFunc ;==>CLOSEClicked

EDIT - fixed the comments so it did not appear in code

@jpm - please see my new code and see if this work and how without just hiding the window I can create the 'dummy' window quicker - I might have many different 'dummy' gui's and I do not want to take up a lot of memory - unless the windows are really nothing - again I am still a beginner on a quest

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

update some code and would like some direction - thanks

If you use GUIDelete you will not be able to use the corresponding anymor it is really deleted. I think what you want is to hide the GUI
Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
ElseIf @GUI_WINHANDLE =  $dummywindow then  
      MsgBox('',"GUI Event", "@GUI_WINHANDLE = Dummy window for testing ")

        GUISetState(@SW_HIDE)     
;;      GUIDelete(@GUI_WinHandle); This did not work - closed the program - but it might still be working
        GUISwitch($mainwindow)
        GUISetState(@SW_SHOW)     
  EndIf 
EndFunc
Link to comment
Share on other sites

If you use GUIDelete you will not be able to use the corresponding anymor it is really deleted. I think what you want is to hide the GUI

Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
ElseIf @GUI_WINHANDLE =  $dummywindow then  
      MsgBox('',"GUI Event", "@GUI_WINHANDLE = Dummy window for testing ")

        GUISetState(@SW_HIDE)     
;;      GUIDelete(@GUI_WinHandle); This did not work - closed the program - but it might still be working
        GUISwitch($mainwindow)
        GUISetState(@SW_SHOW)     
  EndIf 
EndFunc
I reposted about the same time as you with new code - can you please look at it - thanks

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

I am doing it again - sorry - but I think I have it I would still like someone to tell me how I did it? I am really trying to learn so some of my code may not be needed and I need someone to tell me why? I know I am asking for a lot but I would be thankful for any help!!!

; create 2 gui's and have one main and one dummy - the program should not end until the main gui is closed
; after closing the dummy gui the user should be albe to continue with the main gui

; QUESTION - because I am not a programmer - I am not sure if all my code is needed - is there a better way to write this code?
; I do not need the dummy window to be open (hidden) once the dummy gui is closed
; I want the main gui to remain open throughout the life of the program


#include <GUIConstants.au3>
Global $test = 1, $dummywindow, $dummyActive = 1
Opt("GUIOnEventMode", 1); Change to OnEvent mode


; Create main GUI - not to be deleted until top right X is clicked
$mainwindow = GUICreate("Hello World", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")

; Create dummy - that can be deleted when hitting top right X but does not close main gui
CreateDummyWindow($dummyActive)

While 1
    Sleep(1000); Idle around
WEnd

Func CreateDummyWindow($dummyActive)
    
    $dummywindow = GUICreate("Dummy window for testing ", 200, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    GUISetState(@SW_SHOW)
    If $dummyActive = 1 Then
        GUISwitch($mainwindow)
        GUISetState(@SW_SHOW)
        WinActivate($mainwindow)
    EndIf
EndFunc ;==>CreateDummyWindow


; If OK button was pressed should make dummy window visable
Func OKButton()
    If Not WinActivate($dummywindow) Then
        $dummyActive = 0
        CreateDummyWindow($dummyActive)
    ElseIf @GUI_WinHandle = $mainwindow Then
        GUISwitch($dummywindow)
        GUISetState(@SW_SHOW)
        WinActivate($dummywindow)
        GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    EndIf
EndFunc ;==>OKButton


; I only want the dummy gui to close not the main gui
Func CLOSEClicked()
    If @GUI_WinHandle = $mainwindow Then
        MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
        Exit
    ElseIf @GUI_WinHandle = $dummywindow Then
        MsgBox('', "GUI Event", "@GUI_WINHANDLE = Dummy window for testing ")
        GUISetState(@SW_HIDE)
        GUIDelete(@GUI_WinHandle)
        GUISwitch($mainwindow)
        GUISetState(@SW_SHOW)
        WinActivate($mainwindow)
    EndIf
EndFunc ;==>CLOSEClicked

Also has anyone looked at sending variables to function on event and if so how do I proceed - still very new and sorry about all the questions.

Thanks again

*****EDIT

CLEANED UP CODE

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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