Jump to content

Change between GUIs


Recommended Posts

document.au3

Hello guys! 

I've searched many times in AutoIt Forum and Help file examples to find-out how to change between two GUIs in two function, but i didn't understand well about Gui Event Mode and so on.

 

under this post, i have uploaded my source-code, but second gui's buttons doesn't work even Close Button! 

 

 

 

Edited by Colduction
Link to comment
Share on other sites

  • Moderators

Colduction,

Try reading the Managing Multiple GUIs tutorial in the Wiki - that should help you understand how to get your GUIs playing together nicely.

M23

Edit: And I have given up trying to amend your script to make it function as the logic flow is so tortuous that I have no idea just what is supposed to be happening. What I will say is that you have a (non-terminated) infinite While loop with no escape condition in your MainActivity function - which you also call recursively several times from within other functions. Basically the whole thing is a mess. If you explain carefully what you are trying to do, we might be able to get you something that does work.

 

Edited by Melba23

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

2 hours ago, Melba23 said:

explain carefully what you are trying to do

i had created another script that writes something to microsoft writing tools such as Word, but in this script i wrote close word.exe process if is running after 1-hour, then i can goto login stage with Hot-Key to set some characters to write on word.exe

3 hours ago, Melba23 said:

Try reading the Managing Multiple GUIs 

I've red this article more than 5 times, but it's difficult for me to understand

Link to comment
Share on other sites

  • Moderators

Colduction,

What aspect of the tutorial is giving you problems? Do the examples not make it clear what is happening in the various cases?

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers
9 minutes ago, Colduction said:

I'm new to AutoIt, i don't know how to change between forms with function, also buttons doesn't work for me

it's so little hard for me to understand experts

That still doesn't answer why the linked tutorial is difficult to understand, unless you didn't follow it and tried each step yourself.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Yea right... so why do you think it will ever go any further that this part?:

MainActivity()
Func MainActivity()
   While 1
; Sleep for decrease CPU Usage
      Sleep(2000)
; Check process existing
      For $i = 0 To UBound($BMProcesses) - 1 Step 1
         If ProcessExists($BMProcesses[$i]) Then ProcessWaitClose($BMProcesses[$i], 3600)
      Next
; Sleep for decrease CPU Usage
      Sleep(100)
; Terminate process
      For $i = 0 To UBound($BMProcesses) - 1 Step 1
         ProcessClose($BMProcesses[$i])
      Next
EndFunc

EDIT: Skip that: Your code it totally screwed up! RUn Tidy on it and Run AU3Check before even asking any question here!

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Ok, so how do we replicate your problem as you haven't described that yet and what is that problem? 

Looking at your script a little closer it is clear you do not understand the basics of Func calling yet as you start the  Func MainActivity()  again after Func LoginForm() is done. You need to simply return from  Func LoginForm() as the MainActivity() is still running and will continue.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

No ... reread my post please!

This part probably needs to be like this: (untested)

Func LoginForm()
    ; Authentication form for accessing main form
    Global $LoginForm = GUICreate("Login", 201, 161, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
    Global $CloseBTN = GUICtrlCreateButton("Close", 7, 126, 62, 25)
    Global $SignInBTN = GUICtrlCreateButton("Sign-in", 71, 126, 90, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    Global $PasswordInput = GUICtrlCreateInput("admin", 8, 88, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_PASSWORD))
    Global $UsernameInput = GUICtrlCreateInput("admin", 8, 40, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
    Global $UsernameLBL = GUICtrlCreateLabel("Username:", 8, 21, 55, 17)
    Global $PasswordLBL = GUICtrlCreateLabel("Password:", 8, 68, 53, 17)
    Global $ResetCredIcon = GUICtrlCreateButton("res", 160, 126, 32, 25)
    GUICtrlSetTip(-1, "Reset Credentials via PSIC")
    GUICtrlSetCursor(-1, 0)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $CloseBTN
                GUIDelete($LoginForm)
                Return
            Case $SignInBTN
                If AuthProcess(GUICtrlRead($UsernameInput), GUICtrlRead($PasswordInput)) = 1 Then
                    MsgBox(64, "", "Welcome!")
                    GUIDelete($LoginForm)
                    Return
                EndIf
            Case $ResetCredIcon
                GUIDelete($LoginForm)
                PSICGenerator()
        EndSwitch

        If GUICtrlRead($UsernameInput) = "" Or GUICtrlRead($PasswordInput) = "" And BitAND(GUICtrlGetState($SignInBTN), $GUI_ENABLE) Then
            GUICtrlSetState($SignInBTN, $GUI_DISABLE)
        EndIf
        If GUICtrlRead($UsernameInput) <> "" And GUICtrlRead($PasswordInput) <> "" And BitAND(GUICtrlGetState($SignInBTN), $GUI_DISABLE) Then
            GUICtrlSetState($SignInBTN, $GUI_ENABLE)
        EndIf

        For $i = 0 To UBound($BMProcesses) - 1 Step 1
            If ProcessExists($BMProcesses[$i]) Then
                GUIDelete($LoginForm)
                Return
            EndIf
        Next

        AdlibRegister("MainActivity", 250)
    WEnd
EndFunc   ;==>LoginForm

You have the same problem in Func PSICGenerator()... DO NOT call the calling function but use return to go back to it!

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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