Jump to content

Run same function each click


Recommended Posts

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <SendMessage.au3>
#include <Misc.au3>
#include <Reduct.au3>
#include <AutoItConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
Global $GGame, $GStart, $Name, $Race, $Age, $Gold, $Str, $Dex, $Vit, $Health
Global Const $SC_DRAGMOVE = 0xF01
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

    Local $iHeight = 640    , $iWidth = 800

    Local $hGUI = GUICreate('', $iWidth, $iHeight, Default, Default, BitOR($WS_POPUP, $WS_BORDER))
    GUICtrlCreateGroup('', 0, -5, $iWidth, $iHeight + 5, $WS_THICKFRAME)
    GUICtrlCreateGroup('', -99, -99, 1, 1)
    GUICtrlCreatePic('starmain.jpg', 0, 0, 0, 0, $GUI_DISABLE)
 GUISetState(@SW_SHOW, $hGUI)
    Local $2Height = 100, $2width = 800
    Local $Form2 = GUICreate('', $2width, $2Height, Default, 68, BitOR($WS_POPUP, $WS_BORDER))
    GUICtrlCreatePic('navimg.jpg', 0, 0, 0, 0, $GUI_DISABLE)
    Local $iClose = GUICtrlCreateButton('Exit', 760, 60)
    GUICtrlSetOnEvent($iClose, "exitall")

   GUISetState(@SW_SHOW, $Form2)

    Local $AvaHeight = 80, $AvaWidth = 80
    Local $hAva = GUICreate('', $AvaWidth, $AvaHeight, 250, 80, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)
    GUICtrlCreatePic('avatar.gif', 0, 0, 0, 0, $GUI_DISABLE)
    GUISetState(@SW_SHOW, $hAva)


    Local $hPheight = 50, $hPwidth = 50
    Local $iPlan1 = GUICreate('', $hPwidth, $hPheight, 504, 634, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)
    Local $iPbut1 = GUICtrlCreateButton("miniplanet", -1, -1, 51, 51, $BS_BITMAP)
    GUICtrlSetImage($iPbut1, "miniplanet.BMP")
    GUICtrlSetOnEvent($iPbut1, "miniplanet")
    GUISetState(@SW_SHOW, $iPlan1)

Local $hDLL = DllOpen("user32.dll")
Local $infoPheight = 250, $infoPwidth = 250
Local $infoGu1 = GUICreate('Info', $infoPwidth, $infoPheight, 504, 634, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)
Local $infoEx1 = GUICtrlCreateButton("Exit", 220, 220, 25, 25, $WS_EX_TOPMOST)
Local $infoTex1 = GUICtrlCreateLabel("This is a lot of information about a planet!", 5, 5)
GUICtrlSetOnEvent($infoEx1, "infoexit")

Func miniplanet()
GUISetState(@SW_SHOW, $infoGu1)
EndFunc

Func infoexit()
 Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $infoEx1
        EndSwitch
          GUIDelete($infoGu1)
          Return
EndFunc

Local $hPheight1 = 50, $hPwidth1 = 50
Local $iPlan2 = GUICreate('', $hPwidth1, $hPheight1, 768, 214, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)
Local $iPbut2 = GUICtrlCreateButton("miniplanet2", -1, -1, 51, 51, $BS_BITMAP)
GUICtrlSetImage($iPbut2, "miniplanet.BMP")
GUICtrlSetOnEvent($iPbut2, "miniplanet2")
GUISetState(@SW_SHOW, $iPlan2)

Local $hDLL = DllOpen("user32.dll")
Local $infoPheight = 250, $infoPwidth = 250
Local $infoGu2 = GUICreate('Info', $infoPwidth, $infoPheight, 504, 634, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)
Local $infoEx2 = GUICtrlCreateButton("Exit", 220, 220, 25, 25, $WS_EX_TOPMOST)
Local $infoTex2 = GUICtrlCreateLabel("This is a lot of information about a planet!", 5, 5)
GUICtrlSetOnEvent($infoEx2, "infoexit2")

Func miniplanet2()
GUISetState(@SW_SHOW, $infoGu2)
EndFunc

Func infoexit2()
 Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $infoEx2
        EndSwitch
          GUIDelete($infoGu2)
          Return
                EndFunc
While 1
    WEnd

Func exitall()
     Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $iClose
        EndSwitch
          GUIDelete($iPlan1)
          GUIDelete($hAva)
            GUIDelete($Form2)
            GUIDelete($hGUI)
            Exit
EndFunc

After I click on of the miniplanet.bmp it shows up a gui with a label and it works fine.
but after I press exit I cannot press the miniplanet again, I am unsure where/if I should put a while loop and I have been struggling a bit for the past few hours, thanks in advance!

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