Sign in to follow this  
Followers 0
®edeem

Button

12 posts in this topic

hi,

i was making a script and decided to use a GUI to make it look a bit better

OK so...i made the GUI using the GUI builder in scite,

now i want to get the button to make the rest of the script go, here's an image of the interface if it helps understand what i mean

Posted Image

and also the code for the GUI part of the script

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>

GuiCreate("Text Flooder", 300, 165,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$pre = GuiCtrlCreateInput("Start", 5, 10, 290, 20)
$rep = GuiCtrlCreateInput("Text To Repeat", 5, 40, 290, 20)
$suf = GuiCtrlCreateInput("End", 5, 70, 290, 20)
$prev = GuiCtrlCreateLabel($pre & $rep & $suf, 5, 100, 290, 20)
$OK = GuiCtrlCreateButton("Make It Happen!", 5, 130, 290, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd

Exit
#endregion --- GuiBuilder generated code End ---

and also i wanted the preview part to add up the input boxs, so if the top one says "HE" and the second one says "L" then the last one says "P" i want to make the preveiw part read "HELP" but it isn't adding up, it's just displaying "345"

can anyone help me with this?


Share this post


Link to post
Share on other sites



This should get you started:

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>

GUICreate("Text Flooder", 300, 165, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$pre = GUICtrlCreateInput("Start", 5, 10, 290, 20)
$rep = GUICtrlCreateInput("Text To Repeat", 5, 40, 290, 20)
$suf = GUICtrlCreateInput("End", 5, 70, 290, 20)
$prev = GUICtrlCreateLabel("", 5, 100, 290, 20)
$OK = GUICtrlCreateButton("Make It Happen!", 5, 130, 290, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $OK
            ; whatever you want the button to do here
        Case Else
            ;;;
    EndSelect
    GUICtrlSetData($prev, GUICtrlRead($pre) & GUICtrlRead($rep) & GUICtrlRead($suf))
    Sleep(50)
WEnd

Exit
#endregion --- GuiBuilder generated code End ---

Share this post


Link to post
Share on other sites

thanks for the help, the preview now works, but i am obv pretty thick and i do apologise, but...

Case $OK

; whatever you want the button to do here

Case Else

;;;

now what would i be putting in here if i wonted it to just conitue with the script that was writen below?

Share this post


Link to post
Share on other sites

thanks for the help, the preview now works, but i am obv pretty thick and i do apologise, but...

now what would i be putting in here if i wonted it to just conitue with the script that was writen below?

It depends on what the rest of your script is doing. Do you need the preview to keep updating? Do you still want the GUI visible? Please explain with more detail so we can give a more detailed answer.

Share this post


Link to post
Share on other sites

i'm sry yeah, i want the GUI to close, as the script is to a text flooder made mainly to annoy my freinds, specific enough??

again, sry for seeming thick, but it's a new thing to me


Share this post


Link to post
Share on other sites

i'm sry yeah, i want the GUI to close, as the script is to a text flooder made mainly to annoy my freinds, specific enough??

again, sry for seeming thick, but it's a new thing to me

No, not really. :D

Does it need to pass data to the rest of the script (i.e. from the input boxes)?

Share this post


Link to post
Share on other sites

yes it does (sry for long reply, i had to sleep)

it needs to pass data from the inputs and continue with the script, i made one exactly the same before only, without using a GUI, just 3 inputs, so that is still set the same and i have named the inputs the same also

yet again, sry for seeming thick


Share this post


Link to post
Share on other sites

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>

GUICreate("Text Flooder", 300, 165, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$pre = GUICtrlCreateInput("Start", 5, 10, 290, 20)
$rep = GUICtrlCreateInput("Text To Repeat", 5, 40, 290, 20)
$suf = GUICtrlCreateInput("End", 5, 70, 290, 20)
$prev = GUICtrlCreateLabel("", 5, 100, 290, 20)
$OK = GUICtrlCreateButton("Make It Happen!", 5, 130, 290, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $OK
            Go()
        Case Else
            ;;;
    EndSelect
    GUICtrlSetData($prev, GUICtrlRead($pre) & GUICtrlRead($rep) & GUICtrlRead($suf))
    Sleep(50)
WEnd

Exit
#endregion --- GuiBuilder generated code End ---

Func Go()
;your code here
EndFunc

Just place your script in the Go() function


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites

well i did that and i think it got it working, but errors (big ones)

# the flooding didn't wait for the gui to close

# the gui didn't close when i click the button

# it would only flood 345 for some reason

i think it might help if you had the whole code

Global $Paused
HotKeySet("{ESC}", "TogglePause")
HotKeySet("{F9}", "Terminate")

Func Terminate()
    Exit 0
EndFunc

Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
TrayTip("Flooding", "Is Paused", "")
WEnd
TrayTip("Flooding", "Will Now Resume", "300")
Sleep(300)
EndFunc

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>

GUICreate("Text Flooder", 300, 165, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$pre = GUICtrlCreateInput("Start", 5, 10, 290, 20)
$rep = GUICtrlCreateInput("Text To Repeat", 5, 40, 290, 20)
$suf = GUICtrlCreateInput("End", 5, 70, 290, 20)
$prev = GUICtrlCreateLabel("", 5, 100, 290, 20)
$OK = GUICtrlCreateButton("Make It Happen!", 5, 130, 290, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $OK
            Go()
        Case Else
            ;;;
    EndSelect
    GUICtrlSetData($prev, GUICtrlRead($pre) & GUICtrlRead($rep) & GUICtrlRead($suf))
    Sleep(50)
WEnd

Exit
#endregion --- GuiBuilder generated code End ---

Func Go()

Sleep(10000)
ToolTip("Flooding Activated, Pause With Esc Or Close With F9",0,0)
While 1
$i = 1
$z = 1
$peter = 0

If $i = 1 Then
    $peter = 0
EndIf

While $peter = 0
$z = $i
Send($pre)
While $z > 0
    $z = $z-1
    Send($rep)
WEnd
send($suf &"{Enter}")
$i = $i+1

If $i = 7 Then
    $peter = 1
EndIf

WEnd

While $peter = 1
$z = $i
Send($pre)
While $z > 1
    $z = $z-1
    Send($rep)
WEnd
Send($suf &"{Enter}")
$i = $i-1

If $i = 1 Then
    $peter = 0
EndIf


WEnd
WEnd
EndFunc

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Case $Msg = $OK not Case $OK and your GO() function doesn't ever check what the GUIGetMsg() is, so while your there the GUI options will never work.

On the 345 thing, that sounds like a recurrsion issue, the code is too hard to follow to really go into detail on it myself, maybe if you clean it up with Tidy in SciTe it would be easier to read.

Edit:

Also, your Signature Pic really slows down loading of any posts you do, you might think of making it smaller before one of the Mod's or Jon ask/make you :D .

I'm on 10mbs down / 1012 kb's up and it takes a good 10 to 15 seconds to load.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Edit:

Also, your Signature Pic really slows down loading of any posts you do, you might think of making it smaller before one of the Mod's or Jon ask/make you :D .

I'm on 10mbs down / 1012 kb's up and it takes a good 10 to 15 seconds to load.

yeah that would be teh server that hosts it, it's a bit crap

i will sort it out asap

edit:

Case $Msg = $OK not Case $OK and your GO() function doesn't ever check what the GUIGetMsg() is, so while your there the GUI options will never work.

no sure about what you're implying to do there, :D Edited by ®edeem

Share this post


Link to post
Share on other sites

no sure about what you're implying to do there, :D

Well what part are you not sure about?

$Msg contains the input that GUIGetMsg() retrieves ... Correct?

We use Case $Msg = 'ControlId or GUIControl' ... Correct?

... In your example you posted it says Case $OK, not Case $Msg = $OK as it should.

So if we use GUIGetMsg() to retrieve what commands were sent to GUI, then when we are outside the initial While / WEnd loop that contains GUIGetMsg() then we are never able to retrieve a command, when you go to your GO() function, there's no GUIGetMsg() and no commands incase there was something sent to the GUI, so it's never recognized.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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