Jump to content

Back and Forward buttons inside of a GUI


Recommended Posts

Ehh...ok...the helpfile is really good with gui...but..heres some info:

look up

GuiCtrlCreateButton()

...thats all you need i belive...

Maybe GUICtrlSetImage would help.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

He doesnt need an image... (i think) martin...but...that makes colorful buttons right?

no swift i don't need an image a regular button would work? still looking at scripts to figure out the exact code.

would this work GuiCtrlCreateButton("whatever i want the botton to say")

send("info")

Edited by program builder
Link to comment
Share on other sites

Moin,

please, press 'F1' on your Keyboard or in SciTE menu click 'Help' !!!

#include <GUIConstants.au3>

GUICreate("My GUI  Button") ;  will create a dialog box that when displayed is centered

Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Run Notepad",  10,  30,  100)
$Button_2 = GUICtrlCreateButton  ( "Button  Test",  0, -1)

GUISetState ()      ; will display an  dialog box with 2  button

; Run the GUI until the dialog is  closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            Run('Notepad.exe')    ; Will Run/Open Notepad
        Case $msg = $Button_2
            MsgBox(0,  'Testing',  'Button 2 was pressed')    ; Will demonstrate Button 2 being  pressed
    EndSelect
Wend

Greetz

Greenhorn

Link to comment
Share on other sites

no swift i don't need an image a regular button would work? still looking at scripts to figure out the exact code.

would this work GuiCtrlCreateButton("whatever i want the botton to say")

send("info")

This all depends on what you are trying to move through. I have code that I use to move forward and back between Tab items if that's the kind of thing you were looking at. It could als be adapted to work forward/back through child windows without a tremendous amount of work.

here is an image to look at. I used the second tab for the SS because in the first tab the Back button is disabled and in the last tab the Forward button is disabled.

Posted Image

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I Belive...hes tring to be able to use a button...try this out...VERY Simple Code

GUICreate("test..ok", 200, 200);gui window...
$BUTTON = GUICtrlCreateButton("button", 50, 50, 50, 50)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button
Msgbox(0, "you press a button", "you pressed a button...congrats")
WEnd
Edited by Swift
Link to comment
Share on other sites

I Belive...hes tring to be able to use a button...try this out...VERY Simple Code

GUICreate("test..ok", 200, 200);gui window...
$BUTTON = GUICtrlCreateButton("button", 50, 50, 50, 50)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button
Msgbox(0, "you press a button", "you pressed a button...congrats")
WEnd
Could be but until that is stated I will go by the title of the thread.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Could be but until that is stated I will go by the title of the thread.

I know how to do buttons, i need to know why when i create a next button, or back botton it brings up another page, and then when i try to put a send("{altdown}{tab}{altup}") into the code and then an esc, to bring up the page that i don't want up there and take it down, it shuts down the intire program. thats what i want to know.

Link to comment
Share on other sites

Just did this for someone else the other day

#include <GuiConstants.au3>

Dim $show = 0, $Child_[6], $children = 5, $Radio[11]

$Main = GUICreate("MyGUI", 516, 323, (@DesktopWidth - 516) / 2, (@DesktopHeight - 323) / 2)

$Button_1 = GUICtrlCreateButton("&Next >", 335, 290, 80, 25)
$Button_2 = GUICtrlCreateButton("< &Back", 250, 290, 80, 25)
$Button_3 = GUICtrlCreateButton("&Exit", 420, 290, 80, 25)
$Button_4 = GUICtrlCreateButton("&Done", 165, 290, 80, 25)
$Button_6 = GUICtrlCreateButton("", 10, 270, 495, 3, -1, $WS_EX_STATICEDGE)

GUISetState()

$Child_[1] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 1.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[1] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[2] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState()

$Child_[2] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 2.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[3] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[4] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState(@SW_HIDE)

$Child_[3] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 3.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[5] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[6] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState(@SW_HIDE)

$Child_[4] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 4.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[7] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[8] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState(@SW_HIDE)

$Child_[5] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 5.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[9] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[10] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState(@SW_HIDE)


While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_3
            ExitLoop
        Case $msg = $Button_1
            Set_Next()
        Case $msg = $Button_2
            Set_Back()
        Case $msg = $Button_4
            Set_Done()
            ;;;
    EndSelect
WEnd


;--------- Functions -------------------

Func Set_Done()
for $x = 1 to UBound($radio) -1
    If _IsChecked($radio[$x]) Then MsgBox(0x0,"#" & $x, "You selected Radio " & $x, 2)
    Next
EndFunc

Func Set_Next()

    For $x = 1 To $children - 1
        $Nwin = WinGetState($Child_[$x])
        If $Nwin > 5 Then
            GUISetState(@SW_HIDE, $Child_[$x])
            GUISetState(@SW_SHOW, $Child_[$x + 1])
            Return
        EndIf
    Next

EndFunc   ;==>Set_Next

Func Set_Back()

    For $x = $children To 1 Step - 1
        $Nwin = WinGetState($Child_[$x])
        If $Nwin > 5 Then
            GUISetState(@SW_HIDE, $Child_[$x])
            GUISetState(@SW_SHOW, $Child_[$x - 1])
            Return
        EndIf
    Next

EndFunc   ;==>Set_Back

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

8)

NEWHeader1.png

Link to comment
Share on other sites

<---- Mine! Yep Valuate...Stole my code!.. :D just kidding

How Would you edit this...to once it reaches the last GUI...it would change the 'next' button to Done?

Edited by Swift
Link to comment
Share on other sites

Could you post your program/file as is...right now?

Here is the code. I hope it helps

#include <IE.au3>

#include <GuiConstants.au3>

$Mother_GUI = GUICreate("Poet In A Box, Demo 100 lines!!!",-1,-1,-1,-1,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GUICtrlCreateButton("button 1", 5, 5, 70, 20)

GUICtrlSetResizing(-1,$GUI_DOCKALL)

$Button_next = GUICtrlCreateButton("next ",5,30,70,20)

GUICtrlSetResizing(-1,$GUI_DOCKALL)

GUISetState(@SW_SHOW, $Mother_GUI)

while 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $button_1

MsgBox(4096, "AutoIt", "This is button 1")

Case $button_next

#include <IE.au3>

#include <GuiConstants.au3>

$Mother_GUI = GUICreate("Poet In A Box, Demo 100 lines!!!",-1,-1,-1,-1,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_2 = GUICtrlCreateButton("button 2", 5, 5, 70, 20)

GUICtrlSetResizing(-1,$GUI_DOCKALL)

$Button_back = GUICtrlCreateButton("back ",5,30,70,20)

GUICtrlSetResizing(-1,$GUI_DOCKALL)

GUISetState(@SW_SHOW, $Mother_GUI)

while 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $button_2

MsgBox(4096, "AutoIt", "This is button 2")

Case $button_back

MsgBox(4096, "AutoIt", "Not untill i get the next button working")

endswitch

wend

endswitch

wend

Link to comment
Share on other sites

thanks

Your best solution is to use what @Valuater posted or to create small custom GUIs to replace the MsgBox. The standard MS MsgBoxes don't have provision for Forward and Back. Also if you search Example Scripts there are a couple of Message Box UDFs in there. I think one of them allows you to change the button text of a standard message box.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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