Jump to content

Recommended Posts

Posted

Hell all,

I have been trying to figure out to how do this for a long time now. Basically I have a autoit script with a GUI. When a button is pushed, i need the GUI to open a new GUI that has a combo box and an okay button. I want the okay button to read the data from the combo box and return control back to the main gui. When the x button is pressed on the popup gui, it should close just that gui and not the main one as well. My problem is that i cannot get the Gui to read the input from the combo, close after okay is pressed or just close with the x. Here is the part of my main script where the second GUI should pop out.

Case $secondgui
    $who = GUICtrlRead($input)
    $secondgui=GUICreate("newgui",250, 250)
    GUISetState()
    $getffs=GUICtrlCreateCombo("Choice1",0, 0, 100)
    $rank=GUICtrlRead($getffs)
    $okay=GUICtrlCreateButton("Okay",50,50,-1)
Switch GUIGetMsg()
        Case $okay
                WinActivate("window")
                Send("{ESC}")
                sleep(500)
                Send("t")
                sleep(300)
                Send("$who & $rank2)
                Send("{Enter}")


EndSwitch

Any help would be greatly appreciated.

Posted

I hope this will help you:

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

$hGUI = GUICreate("Main GUI",500,400);Create main GUI
$hButton1 = GUICtrlCreateButton("Open 2nd GUI!!",20,20, 100,20)
$hLabel1 = GUICtrlCreateLabel("",20, 50, 100,20);Create label where the result is displayed
GUISetState()

$hGUI2 = GUICreate("Popup GUI", 200, 200);Create POPUP GUI
$hButtonX = GUICtrlCreateButton("X",20,20,25,25);Create X button
$hCombo = GUICtrlCreateCombo("",20,50, 100, 20);Create Combo
GUICtrlSetData($hCombo, "Data1|Data2|Data3");Set data of combo

GUISetState(@SW_HIDE, $hGUI2)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton1
            GUISetState(@SW_SHOW, $hGUI2)
        Case $hButtonX
            $result = GUICtrlRead($hCombo)
            GUICtrlSetData($hLabel1, $result)
            GUISetState(@SW_HIDE, $hGUI2)
    EndSwitch
WEnd
PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.
  • Moderators
Posted

PPowerHouseK,

  Quote

When the x button is pressed on the popup gui, it should close just that gui and not the main one as well.

I recommend the Managing Multiple GUIs tutorial in the Wiki - it shows you how to avoid that particular problem. And it might well help you with the others as well ;)

After having read the tutorial please come back if you have any further questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...