Jump to content

Recommended Posts

Posted (edited)

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

Share this post


Link to post
Share on other sites
Posted (edited)

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

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

@Melba23,

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

Share this post


Link to post
Share on other sites
9 minutes ago, Colduction said:

also buttons doesn't work for me

Laziness apart, where is your code?


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Posted (edited)

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
4 minutes ago, Jos said:

Run AU3Check before even asking any question here!

I've ran AU3Check, it doesn't show me any errors

Share this post


Link to post
Share on other sites
Posted (edited)

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
3 minutes ago, Jos said:

what is that problem? 

buttons in 2nd GUI doesn't work even Close button

How to call GUIs that they are in different Func without these problems? (such as buttons are not correctly work)

Share this post


Link to post
Share on other sites
8 minutes ago, Jos said:

start the  Func MainActivity()  again after Func LoginForm() is done

you mean that AdlibRegister is my problem?

Share this post


Link to post
Share on other sites
Posted (edited)

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Posted (edited)
4 minutes ago, Jos said:

DO NOT call the calling function but use return to go back to it!

Thanks @Jos,

You are best and more active person in this Forum!❤️

if i get any error, i will tell again

Edited by Colduction

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

×
×
  • Create New...