Jump to content

Menu and web page question


Recommended Posts

The trouble I am having is with the menus inside a web page I created.

When I click on the login set up inside the file menu it pulls up the setup box. But when it saves and closes, the exit no longer works from the file menu. wondering how to get around that. Here's the code I have so far.

Global $msg, $exititem, $email, $pw, $save, $em1, $pw1


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <StaticConstants.au3>
#include <Misc.au3>

main()

Func Main()

    Local $msg, $exititem, $loginset
    

    _IEErrorHandlerRegister()

    $oIE = _IECreateEmbedded()
    GUICreate("www.autoit.com", 800, 600, 5, 5, 1, $WS_EX_TOPMOST)
    GUICtrlCreateLabel("test", 300, 1)
    $GUIActiveX = GUICtrlCreateObj($oIE, 5, 20, 780, 450)

    $filemenu = GUICtrlCreateMenu("&File")
    $exititem = GUICtrlCreateMenuItem("Close", $filemenu)
    $loginset = GUICtrlCreateMenuItem("Login Setup", $filemenu)
    $Logonbut = GUICtrlCreateButton("Log on", 10, 480, 100)



    GUISetState() ;Show GUI

    _IENavigate($oIE, "www.autoit.com")

    ; Waiting for user to close the window
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            case $msg = $exititem
                exit
            case $msg = $loginset
                    logon()
            EndSelect
    WEnd


endfunc
  ;==>main



Global $msg, $exititem, $email, $pw, $save, $em1, $pw1, $logon

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
Opt('MustDeclareVars', 1)


Func logon()
    Local $msg
    $logon = GUICreate("test - Login Info", 230, 130, 100, 100, 1, $WS_EX_TOPMOST)
    GUICtrlCreateLabel("Email Address", 5, 5)
    GUICtrlCreateLabel("Password", 5, 40)
    $em1 = iniread(@scriptdir & "\settings.ini", "Login", "EM", "")
    $email = GUICtrlCreateInput($em1, 100, 5, 100)
    $pw1 = iniread(@scriptdir & "\settings.ini", "Login", "PW", "")
    $pw = GUICtrlCreateInput($pw1, 100, 40, 100)
    $save = GUICtrlCreateButton("Save", 70, 75, 100)
    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $save
                IniWrite(@ScriptDir & "\settings.ini", "Login", "EM", GUICtrlRead($email))
                IniWrite(@ScriptDir & "\settings.ini", "Login", "PM", GUICtrlRead($pw))
                guidelete($logon)


        EndSelect
    WEnd

EndFunc   ;==>logon

Anyone have any idea. Hope the question was understandable.

As always thanks in advance.

Cue ( :idea: )

Link to comment
Share on other sites

Your stuck in second loop that dont have case $msg = $exititem

Youl probably need to exit form second loop (ExitLoop [level]) when you Case $msg = $save or to make it on one loop or to add case $msg = $exititem to last loop.

Becose i dont see the reason (note that if im not wrong $msg = GUIGetMsg() will get msgs from all guis) for second loop i would suggest you to make it all on the first loop (and you dont need double includes or Global-s, only one of them on top of the script is enought to make it work).

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Thanks Bog

I have tried

Global $msg, $exititem, $email, $pw, $save, $em1, $pw1


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <StaticConstants.au3>
#include <Misc.au3>

main()

Func Main()

    Local $msg, $exititem, $loginset
    

    _IEErrorHandlerRegister()

    $oIE = _IECreateEmbedded()
    GUICreate("www.autoit.com", 800, 600, 5, 5, 1, $WS_EX_TOPMOST)
    GUICtrlCreateLabel("test", 300, 1)
    $GUIActiveX = GUICtrlCreateObj($oIE, 5, 20, 780, 450)

    $filemenu = GUICtrlCreateMenu("&File")
    $exititem = GUICtrlCreateMenuItem("Close", $filemenu)
    $loginset = GUICtrlCreateMenuItem("Login Setup", $filemenu)
    $Logonbut = GUICtrlCreateButton("Log on", 10, 480, 100)



    GUISetState() ;Show GUI

    _IENavigate($oIE, "www.autoit.com")

    ; Waiting for user to close the window
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            case $msg = $exititem
                exit
            case $msg = $loginset
                    logon()
            EndSelect
    WEnd


endfunc
  ;==>main



Global $msg, $exititem, $email, $pw, $save, $em1, $pw1, $logon

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
Opt('MustDeclareVars', 1)


Func logon()
    Local $msg
    $logon = GUICreate("test - Login Info", 230, 130, 100, 100, 1, $WS_EX_TOPMOST)
    GUICtrlCreateLabel("Email Address", 5, 5)
    GUICtrlCreateLabel("Password", 5, 40)
    $em1 = iniread(@scriptdir & "\settings.ini", "Login", "EM", "")
    $email = GUICtrlCreateInput($em1, 100, 5, 100)
    $pw1 = iniread(@scriptdir & "\settings.ini", "Login", "PW", "")
    $pw = GUICtrlCreateInput($pw1, 100, 40, 100)
    $save = GUICtrlCreateButton("Save", 70, 75, 100)
    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $save
                IniWrite(@ScriptDir & "\settings.ini", "Login", "EM", GUICtrlRead($email))
                IniWrite(@ScriptDir & "\settings.ini", "Login", "PM", GUICtrlRead($pw))
                guidelete($logon)
                [color="#FF0000"]exitloop 2[/color]

        EndSelect
    WEnd

EndFunc   ;==>logon

With the exitloop level but it crashes everytime.

Then I tried to add the

case $msg = $exititem
exit

to the second loop

but that also crashes it. hmm not sure what else to ry. Anyone else have any ideas? Or where I can goto look for the info on it?

Thanks

Cue

Link to comment
Share on other sites

1. I think that it shud b ExitLoop 1 instead of 2

2. you did not try to "and you don't need double includes or Global-s"

3. "i would suggest you to make it all on the first loop "

Its funny that you have 100+ posts and you do not have some more expiriance with guis :idea:

Hope that i did not make any mistake while editing this script

#include <IE.au3>
#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
Global $msg, $exititem, $email, $pw, $save, $em1, $pw1, $logon
$oIE = _IECreateEmbedded()
$gui = GUICreate("www.autoit.com", 800, 600, 5, 5, 1, $WS_EX_TOPMOST)
GUICtrlCreateLabel("test", 300, 1)
$GUIActiveX = GUICtrlCreateObj($oIE, 5, 20, 780, 450)
$filemenu = GUICtrlCreateMenu("&File")
$exititem = GUICtrlCreateMenuItem("Close", $filemenu)
$loginset = GUICtrlCreateMenuItem("Login Setup", $filemenu)
$Logonbut = GUICtrlCreateButton("Log on", 10, 480, 100)
GUISetState(@SW_SHOW,$gui)
_IENavigate($oIE, "www.google.com")

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $exititem
            exit
        Case $msg = $loginset
            logon()
        Case $msg = $save And $save <> ""
            IniWrite(@ScriptDir & "\settings.ini", "Login", "EM", GUICtrlRead($email))
            IniWrite(@ScriptDir & "\settings.ini", "Login", "PM", GUICtrlRead($pw))
            GUIDelete($logon)
    EndSelect
WEnd

Func logon()
    $logon = GUICreate("test - Login Info", 230, 130, 100, 100, 1, $WS_EX_TOPMOST)
    GUICtrlCreateLabel("Email Address", 5, 5)
    GUICtrlCreateLabel("Password", 5, 40)
    $email = GUICtrlCreateInput($em1, 100, 5, 100)
    $pw = GUICtrlCreateInput($pw1, 100, 40, 100)
    $save = GUICtrlCreateButton("Save", 70, 75, 100)
    GUISetState()
    $em1 = IniRead(@scriptdir & "\settings.ini", "Login", "EM", "")
    $pw1 = IniRead(@scriptdir & "\settings.ini", "Login", "PW", "")
EndFunc

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Bog thank you again for a reply.

Its funny that you have 100+ posts and you do not have some more experience with guis ;)

The number of posts 1 has does not equal experience. I am learning everyday. Still working on different items, trying different ideas.

Although I appreciate the code you had posted, I never ask for something to be done for me. 99.9% of the time I try to figure things out on my own, and if i get stuck I ask for direction. If I gave my children the answers to their homework what have they learned?

but as I had said thank you for your reply, And I will take your example and try and figure out why and how it is written as such.

cue

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