Sign in to follow this  
Followers 0
as5bcr

simple gui-help

14 posts in this topic

i want to make a simple interface. one that has only a button, start/stop. how can i make this? :)

Share this post


Link to post
Share on other sites



The easy way to learn is to use the Koda FormDesigner (Alt+m from the SciTE editor). Use that to see how it lays out the form and then you can extend it yourself.

Here's an example of what you asked for...

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 625, 445, 193, 115)
$Button1 = GUICtrlCreateButton("AButton1", 232, 192, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $Button1
            ; do something whem button is pressed
            
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

done. thanks. now i ve got another question. i ve added another button. one is for start and one for stop. but once i ve clicked on "start" i can t click "stop". why??

Share this post


Link to post
Share on other sites

done. thanks. now i ve got another question. i ve added another button. one is for start and one for stop. but once i ve clicked on "start" i can t click "stop". why??

need to show us the code so we can see what it is doing..

post code like this

[ code] ; no spaces

; past code here

[ /code] ; no spaces

or you can use [ autoit] and [ /autoit]

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Well it is a program that sends F5 until the user clicks on "Stop". but i can't understand how to do this.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 225, 145, 93, 15)
$Button1 = GUICtrlCreateButton("Start", 50, 30, 90, 25, 0)
$Button2 = GUICtrlCreateButton("Stop", 50, 70, 90, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
       
        Case $Button1
         Do
         Send("{F5}")
         Until *what*?

EndSwitch
WEnd

i tried to do somehing like:

Case $Button2
Exit

but when i click on button 2 it does nothing.

Edited by as5bcr

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <Misc.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 225, 145, 93, 15)
$Button1 = GUICtrlCreateButton("Start", 50, 30, 90, 25, 0)
$Button2 = GUICtrlCreateButton("Stop", 50, 70, 90, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
      
        Case $Button1
         Do
         Send("{F5}")
         Until _IsPressed($Button2)
EndSwitch
WEnd

Un-Tested

Share this post


Link to post
Share on other sites

it gives an error that says:

Until _IsPressed($Button2)
Until ^ ERROR

Error: Unknown function name.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

@Secure_ICT : That you hadn't tested it wasn't needed to point out, as it was pretty obvious :)

@as5bcr : : In your While/WEnd-loop you're using GUIGetMsg, however that's not the case in your

Do/Until-loop. So, how do you expect that any actions you do in your GUI is going to affect anything

at all in your script ? It's not like it can glance at GUIGetMsg from the outer loop and automagically

figure out what to do accordingly.

EDIT : What version are you using ?

Edited by Helge

Share this post


Link to post
Share on other sites

i use autoit 3. what can i do to solve my problem?

Share this post


Link to post
Share on other sites

I got that alright, but could you tell the exact version-number ? The latest is 3.2.2.0.

Run this script and tell us what it says :

MsgBox(64, "", @AutoItVersion)

Share this post


Link to post
Share on other sites

it is 3.2.0.1. shall i update it?

Share this post


Link to post
Share on other sites

it is 3.2.0.1. shall i update it?

I'd suggest yes - update to the current version.

Here's one method that should do what you want.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 225, 145, 93, 15)
$Button1 = GUICtrlCreateButton("Start", 50, 30, 90, 25, 0)
$Button2 = GUICtrlCreateButton("Stop", 50, 70, 90, 25, 0)
$Label1 = GUICtrlCreateLabel("Counter", 50, 110, 90, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$KeepLooping = 1
$Count = -1

While $KeepLooping
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
       
        Case $Button1 ; use this to start
            $Count = 0
         
        Case $Button2 ; use this to stop
            $KeepLooping = 0

    EndSwitch
    
    If $Count >= 0 Then ; put the stuff to repeat in this loop
        $Count = $Count + 1
        GUICtrlSetData($Label1, $Count)
    EndIf
    
WEnd

Share this post


Link to post
Share on other sites

thanks a lot , it works now.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

it gives an error that says:

Until _IsPressed($Button2)
Until ^ ERROR

Error: Unknown function name.

did you happen to include misc.au3?

#include <Misc.au3>

although I'm not sure if _ispressed is a function in there.. but seeing as it says unknown functino name, its nice to know what yove included XD

but seeing as your problem is solved never mind XD

Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/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