Sign in to follow this  
Followers 0
Oddball

Multiple GUYs in 1 script

6 posts in this topic

#1 ·  Posted (edited)

Hello

I'm using AutoIt v.3 for about a week, maybe 2. But I ran into a problem, I have made a script, in several parts, and I want to have 2 GUIs running at the same time. Both GUIs have an OK button, some text, one has an Input box and the other has an Combo box. This isn't a problem, that occurs when I want to close one of them and continue using the other. With my, limited, knowledge of AutoIt I can not solf this problem, hopefully you guys can help me out with a push in the right direction or a piece of script.

Thanx in advance

Edited by Oddball

I like work: it fascinates me. I can sit and look at it for hours.

Share this post


Link to post
Share on other sites



GUIGetMsg(1) should do the trick for ya!


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

EWW GUY's

but for real. we could help you alot faster if you posted a snippet of your code.

<{POST_SNAPBACK}>

OK, first of all, I made a typo in the title, stupid :)

Second, as I said, I have my script in parts, as I am still learning the language, so I'm gone send the bit I have on the multiple GUIs now, the problem is that I can't close only one, but they both close.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode

$test = GUICreate("test", 200, 100)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUICtrlCreateLabel("test test! test test test?", 30, 10)

$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)

GUICtrlSetOnEvent($okbutton, "OKButton")

GUISetState(@SW_SHOW)

$test2 = GUICreate("test2", 200, 100)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked2")

GUICtrlCreateLabel("test test2! test2 test2 test2?", 30, 10)

$okbutton2 = GUICtrlCreateButton("OK", 70, 50, 60)

GUICtrlSetOnEvent($okbutton2, "OKButton2")

GUISetState(@SW_SHOW)

While 1

  Sleep(1000)  ; Idle around

WEnd

Func OKButton()

  ;Note: at this point @GUI_CTRLID would equal $okbutton,

  ;and @GUI_WINHANDLE would equal $test

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

EndFunc

Func OKButton2()

  ;Note: at this point @GUI_CTRLID would equal $okbutton2,

  ;and @GUI_WINHANDLE would equal $test2

  MsgBox(0, "GUI Event", "You pressed OK2!")

EndFunc

Func CLOSEClicked()

  ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,

  ;and @GUI_WINHANDLE would equal $test

  MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")

  Exit

EndFunc

Func CLOSEClicked2()

  ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,

  ;and @GUI_WINHANDLE would equal $test 2

  MsgBox(0, "GUI Event2", "You clicked CLOSE2! Exiting2...")

  Exit

EndFunc

I copied a great deal from the documentation and modified it but I can't get any further.

I like work: it fascinates me. I can sit and look at it for hours.

Share this post


Link to post
Share on other sites

something like this ?

Global $counttillclose = 0

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$test = GUICreate("test", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("test test! test test test?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUISetState(@SW_SHOW)

$test2 = GUICreate("test2", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("test test2! test2 test2 test2?", 30, 10)
$okbutton2 = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton2, "OKButton2")
GUISetState(@SW_SHOW)

While 1
  Sleep(1000) ; Idle around
  If $counttillclose = 2 Then ExitLoop
WEnd

Func OKButton()
 ;Note: at this point @GUI_CTRLID would equal $okbutton,
 ;and @GUI_WINHANDLE would equal $test
  MsgBox(0, "GUI Event", "You pressed OK!")
EndFunc

Func OKButton2()
 ;Note: at this point @GUI_CTRLID would equal $okbutton2,
 ;and @GUI_WINHANDLE would equal $test2
  MsgBox(0, "GUI Event", "You pressed OK2!")
EndFunc

Func CLOSEClicked()
 ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
 ;and @GUI_WINHANDLE would equal $test
  MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
  GUIDelete(@GUI_WinHandle)
  $counttillclose += 1
EndFunc

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

Thanks, it works!!

Now I can continue to make my complete script.

One question, the "Global" thing on the first line, what does it stand for, I can't find it in the documentation.

Oh, and the + in front of the = sign on the first to last line has to be removed, otherwise it will generate an error message.


I like work: it fascinates me. I can sit and look at it for hours.

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