Jump to content

Recommended Posts

Posted (edited)

Okay, this should be easy, but after beating my head against the wall for hours, I have decided to post here and be humiliated by the simplicity of the answer I know I will receive :o

Within a GUI I have created, I create another GUI. When I attempt to close the second GUI, it won't close, to wit:

==============================

Func SelectList()

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

; I have also tried this without the above code

GuiCreate("Select Customer List", 398, 122,(@DesktopWidth-398)/2, (@DesktopHeight-122)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_EX_TOPMOST)

; I have also tried this without the above WS strings

$Instructions = GuiCtrlCreateLabel("A bunch of text", 10, 10, 380, 70)

$bOK = GuiCtrlCreateButton("OK", 90, 80, 60, 25)

$bCancel = GuiCtrlCreateButton("Cancel", 250, 80, 60, 25)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $bOK ;--After the user clicks 'OK', I want to close the window I just created

and return control to the calling function

;=========PROBLEM AREA==========

WinClose("Select Customer List") ;---This doesn't work for some reason. I have

;checked for typos like leading/trailing spaces, etc.

;When this didn't work, I tried this:

WinKill("Select Customer List") ; Same thing. No worky.

;=========END OF PROBLEM AREA=====

ExitLoop

Case $msg = $bCancel ;---If the user clicks Cancel, the entire script stops executing as intended

Exit

EndSelect

WEnd

EndFunc

======================================

Of course, if I run the second GUI (above function) on its own (not within the first GUI I created, for which I have not provided the sample code), it detects and closes the window properly. Does that make sense?

All I REALLY want to do is have a message box pop-up and remain on top while a user makes a selection from an underlying IE window and then give the user one last opportunity to continue execution of the script. I can't seem to make anything else remain on top aside from a new GUI, i.e. I tried MsgBox(), but I cannot get it to remain on top while the user navigates the underlying window.

Apologies extended in advance, but I really have tried to make this sucker work, but to no avail.....

Edited: I don't know how to make my code post in the forum properly (with indentations, etc.), so sorry for the difficult "readability" of my post.

Edited by LovinItAll
Posted

Try:

Func SelectList()
 If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
; I have also tried this without the above code
 
 $gui_clist = GUICreate("Select Customer List", 398, 122, (@DesktopWidth - 398) / 2, (@DesktopHeight - 122) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_EX_TOPMOST)
; I have also tried this without the above WS strings
 
 $Instructions = GUICtrlCreateLabel("A bunch of text", 10, 10, 380, 70)
 $bOK = GUICtrlCreateButton("OK", 90, 80, 60, 25)
 $bCancel = GUICtrlCreateButton("Cancel", 250, 80, 60, 25)
 
 While 1
  $msg = GUIGetMsg()
  Select
   Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
   Case $msg = $bOK;--After the user clicks 'OK', I want to close the window I just created
    ExitLoop
   Case $msg = $bCancel;---If the user clicks Cancel, the entire script stops executing as intended
    Exit
  EndSelect
 WEnd
 GUIDelete($gui_clist)
EndFunc  ;==>SelectList

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted

Damnation! I posted the wrong code! What I posted before was a 'fix' I was trying. Yes, I tried ExitLoop, but it does not close the window for some strange reason. The code below is what I am trying to make work. Sorry for the misstep....

P.S. The following code does not stay 'OnTop', but I have that figured out....

P.P.S And I figured out how to make my code appear in the post correctly!

Func SelectList()
sleep(5000)
$SelectList = GUICreate("Select Customer List", 400, 193, 192, 125, -1) 
GUICtrlSetFont(-1, 10, 400, 0, "Times New Roman")
GUICtrlCreateLabel("A bunch of text", 8, 8, 617, 40)
$bOK = GUICtrlCreateButton("OK",76, 80, 113, 41)
$bQuit = GUICtrlCreateButton("Quit",260, 80, 113, 41)
;GUICtrlSetFont(-1, 10, 400, 0, "Times New Roman")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE;---User clicks 'X'. Bail the whole program
        Exit
    Case $msg = $bOK ;---User has selected list and control is returned to main() 
        WinClose("Select Customer List");---I have tried WinKill("") and WinClose("")
        ExitLoop
    Case $msg = $bQuit  ;---User clicks "Quit" and the program stops executing
        Exit
    EndSelect
WEnd
EndFunc
Posted

Damnation! I posted the wrong code! What I posted before was a 'fix' I was trying. Yes, I tried ExitLoop, but it does not close the window for some strange reason. The code below is what I am trying to make work. Sorry for the misstep....

P.S. The following code does not stay 'OnTop', but I have that figured out....

P.P.S And I figured out how to make my code appear in the post correctly!

Func SelectList()
sleep(5000)
$SelectList = GUICreate("Select Customer List", 400, 193, 192, 125, -1) 
GUICtrlSetFont(-1, 10, 400, 0, "Times New Roman")
GUICtrlCreateLabel("A bunch of text", 8, 8, 617, 40)
$bOK = GUICtrlCreateButton("OK",76, 80, 113, 41)
$bQuit = GUICtrlCreateButton("Quit",260, 80, 113, 41)
;GUICtrlSetFont(-1, 10, 400, 0, "Times New Roman")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE;---User clicks 'X'. Bail the whole program
        Exit
    Case $msg = $bOK;---User has selected list and control is returned to main() 
        WinClose("Select Customer List");---I have tried WinKill("") and WinClose("")
        ExitLoop
    Case $msg = $bQuit ;---User clicks "Quit" and the program stops executing
        Exit
    EndSelect
WEnd
EndFunc

just add GuiDelete($SelectList) after the Wend

don't need the WinClose

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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
×
×
  • Create New...