Jump to content

help needed


Guest Py7|-|[]/\/
 Share

Recommended Posts

Guest Py7|-|[]/\/

I need some help getting this script to work. Here it is:

Global $textbox1, $next1, $cancel1, $msg1, $msg2, $next2, $cancel2, $finish, $cancel3, $msg3
#include <GUIConstants.au3>
GUICreate("Test", 200,90,200,200) 
GuiSetBkColor(0x0E0FFFF)
GUISetFont(9, 300)
GUICtrlCreateLabel ("Test", 85,10,50,20) 
GUICtrlCreateLabel ("Enter text:", 10,30,53,20)
$textbox1=GUICtrlCreateInput ("", 68,30,117,20)
$next1=GUICtrlCreateButton ("Next", 85,60,50,20)
$cancel1 = GUICtrlCreateButton ("Cancel", 135,60,50,20)
GUISetState ()
While 1
      $msg1 = GUIGetMsg()
   If $msg1 = $next1 Then   
      GUICreate("Test", 200,90,200,200) 
      GuiSetBkColor(0x0E0FFE)
      GUISetFont(9, 300)
      GUICtrlCreateLabel ("Test", 85,10,50,20) 
      GUICtrlCreateLabel ("Enter text:", 10,30,53,20)
      $next2=GUICtrlCreateButton ("Next", 85,60,50,20)
      $cancel2=GUICtrlCreateButton ("Cancel", 135,60,50,20)
      GUISetState()
      EndIf
   If $msg1 = $cancel1 or $msg1 = $GUI_EVENT_CLOSE Then ExitLoop
      
   While 1   
         $msg2 = GUIGetMsg()
      If $msg2 = $next2 Then
         GUICreate("Test", 200,90,200,200) 
         GuiSetBkColor(0x0E0FFD)
         GUISetFont(9, 300)
         GUICtrlCreateLabel ("Test", 85,10,50,20) 
         GUICtrlCreateLabel ("Enter text:", 10,30,53,20)
         $finish=GUICtrlCreateButton ("Finish", 85,60,50,20)
         $cancel3=GUICtrlCreateButton ("Cancel", 135,60,50,20)
         GUISetState()
      EndIf
      If $msg2 = $cancel2 or $msg2 = $GUI_EVENT_CLOSE Then ExitLoop
      While 1
            $msg3 = GUIGetMsg()
         If $msg3 = $cancel3 or $msg3 = $GUI_EVENT_CLOSE Then ExitLoop
      Wend
   Wend
Wend

Sorry, my brother posted this message as me. Just to let you know!

Edited by Py7|-|[]/\/
Link to comment
Share on other sites

Guest Py7|-|[]/\/

Yah, thats what happened to me. When I run it as it is, it keeps putting up windows. I'm trying to get it to go from one window to another. Kind of like a set-up wizard, but I can't get it to work that way. I wan't an innital window to come up, then if you click on the first button it goes on to the next window closing out of the first, but if you click on the second button it exits. Thats basically it.

Link to comment
Share on other sites

Guest Py7|-|[]/\/

I think so too, but I don't know how to fix it... thats why I'm posting, heh. I've tried breaking it down into two loops but it won't let me move on to the next window like that. I also need to know how to make it close out of the previous GUI window then the 'next buttons' are pressed.

Link to comment
Share on other sites

I don't know what you wanna how it works, but I did some changes

of your coding.

And, it would be easier for us to look at your code if you indented

it ! Try this out, and of course it still has bugs as I'm not so good

in this yet.

#include <GUIConstants.au3>

Global $textbox1, $next1, $cancel1, $msg1, $msg2, $next2, $cancel2, $finish, $cancel3, $msg3

$flag = 0


GUICreate("1st Window", 200,90,200,200) 
GuiSetBkColor(0x0E0FFFF)
GUISetFont(9, 300)
GUICtrlCreateLabel ("Test", 85,10,50,20) 
GUICtrlCreateLabel ("Enter text:", 10,30,53,20)
$textbox1=GUICtrlCreateInput ("", 68,30,117,20)
$next1=GUICtrlCreateButton ("Next", 85,60,50,20)
$cancel1 = GUICtrlCreateButton ("Cancel", 135,60,50,20)
GUISetState ()

While 1
     $msg1 = GUIGetMsg()
     If $msg1 = $next1 Then   
        GUICreate("2nd Window", 200,90,200,200) 
        GuiSetBkColor(0x0E0FFE)
        GUISetFont(9, 300)
        GUICtrlCreateLabel ("Test", 85,10,50,20) 
        GUICtrlCreateLabel ("Enter text:", 10,30,53,20)
        $next2=GUICtrlCreateButton ("Next", 85,60,50,20)
        $cancel2=GUICtrlCreateButton ("Cancel", 135,60,50,20)
        GUISetState()
        $flag = 1
     EndIf

  If $msg1 = $cancel1 or $msg1 = $GUI_EVENT_CLOSE Then ExitLoop
     
  While $flag = 1   
        $msg2 = GUIGetMsg()

        If $msg2 = $next2 Then
           GUICreate("3rd Window", 200,90,200,200) 
           GuiSetBkColor(0x0E0FFD)
           GUISetFont(9, 300)
           GUICtrlCreateLabel ("Test", 85,10,50,20) 
           GUICtrlCreateLabel ("Enter text:", 10,30,53,20)
           $finish=GUICtrlCreateButton ("Finish", 85,60,50,20)
           $cancel3=GUICtrlCreateButton ("Cancel", 135,60,50,20)
           GUISetState()
           $flag = 0
        EndIf

     If $msg2 = $cancel2 or $msg2 = $GUI_EVENT_CLOSE Then 
        GuiDelete()
        $flag = 0
     Endif
  Wend
Wend
Edited by friends
Link to comment
Share on other sites

Your script is really messed up and I don't feel like debugging it.

I read what you want and made an example:

#include <GUIConstants.au3>
AutoItSetOption("TrayIconDebug", 1)

;Initialize variables
Global $style1
Global $IniFile
Global $GUIWidth
Global $GUIHeight

$GUIWidth = 250
$GUIHeight = 250
$IniFile = StringTrimRight(@ScriptFullPath, 3) & "ini"

;Only a close button:
;$style1 = BitOR($WS_POPUP, $WS_CAPTION, $WS_SYSMENU)
;GUICreate("New GUI", $GUIWidth, $GUIHeight, -1, -1, $style1)

$Window1 = GUICreate("Window 1", $GUIWidth, $GUIHeight)
   $button1_win1 = GUICtrlCreateButton("&Next", 50, 210, 70, 25)
   $button2_win1 = GUICtrlCreateButton("&Cancel", 130, 210, 70, 25)

$Window2 = GUICreate("Window 2", $GUIWidth, $GUIHeight)
   $button1_win2 = GUICtrlCreateButton("&Next", 50, 210, 70, 25)
   $button2_win2 = GUICtrlCreateButton("&Cancel", 130, 210, 70, 25)
   
$Window3 = GUICreate("Window 3", $GUIWidth, $GUIHeight)
   $button1_win3 = GUICtrlCreateButton("&Next", 50, 210, 70, 25)
   $button2_win3 = GUICtrlCreateButton("&Cancel", 130, 210, 70, 25)

GUISwitch($Window1)
GUISetState(@SW_SHOW)

While 1
   Sleep(25)
   $msg = GUIGetMsg()
   Select
   
      Case $msg = $GUI_EVENT_CLOSE OR $msg = $button2_win1 OR _
            $msg = $button2_win2 OR $msg = $button2_win3
         GUIDelete()
         Exit

      Case $msg = $button1_win1
         GUIDelete()
         GUISwitch($Window2)
         GUISetState(@SW_SHOW)

      Case $msg = $button1_win2
         GUIDelete()
         GUISwitch($Window3)
         GUISetState(@SW_SHOW)
         
   EndSelect

WEnd
Link to comment
Share on other sites

Guest Py7|-|[]/\/

Hey everyone, sorry about that. My brother is learning AutoIt also =) This was his first GUI script, he doesn't have an account so he used mine. And for some reason, (he uses SCiTE), he doesn't like indenting ... So he unindents the auto-indents LOL. I'll talk with him =).

Link to comment
Share on other sites

Guest Py7|-|[]/\/

Wow, thanks a lot SlimShady. I just made it the other way because I don't know everything about GUI. I just made it using the knowledge gained from testing some of the examples in the help file.. heh. Thanks a LOT.

-Py7|-|[]/\/'s brother.

Link to comment
Share on other sites

  • 2 weeks later...
Guest Py7|-|[]/\/

umm.. I've been trying some more stuff with GUI, and I cant seem to figure out how to display text. I've set it up so that I can enter text into a textbox, but I dont know how to make text display within a label (if I should even use a labelbox) according to what was put into the textbox. I've set up many different types of If..Then statements but what I really need to know is how to make the entered text a variable, and then how to make the labelbox's text a variable. This is an example of what I want it to do...

$var1 = GUICtrlCreateInputbox("", (various coordinates))
If $var1 = "Hi" Then
$var2 = "Hello
EndIf
GUICtrlCreateLabel( $var2, (various coordinates))

I cant get the label to display the text I want it to. Any help would be greatly appreciated.

Link to comment
Share on other sites

Here's an example:

#include <GUIConstants.au3>
AutoItSetOption("TrayIconDebug", 1)

;Initialize variables
Global $style1
Global $IniFile
Global $GUIWidth
Global $GUIHeight

$GUIWidth = 250
$GUIHeight = 250
$IniFile = StringTrimRight(@ScriptFullPath, 3) & "ini"

;Only a close button:
;$style1 = BitOR($WS_POPUP, $WS_CAPTION, $WS_SYSMENU)
;GUICreate("New GUI", $GUIWidth, $GUIHeight, -1, -1, $style1)

GUICreate("New GUI", $GUIWidth, $GUIHeight)

$input_1 = GUICtrlCreateInput("hi", 50, 50, 70, 20)
$label_1 = GUICtrlCreateLabel("", 50, 75, 70, 20)
$button_1 = GUICtrlCreateButton("OK", 100, 100, 70, 20)

GUISetState(@SW_SHOW)

While 1
   Sleep(25)
   $msg = GUIGetMsg()
   Select
   
      Case $msg = $GUI_EVENT_CLOSE
         GUIDelete()
         Exit

      Case $msg = $button_1
         $ReadInput = GUIRead($input_1)
         If $ReadInput = "hi" Then GUICtrlSetData($label_1, "hello")
         
   EndSelect

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