Sign in to follow this  
Followers 0
Cloudsx

Open/Close dialog with button

9 posts in this topic

i want to make an Open/close dialog with button so if i press the button its must open and if i press the X to close but if i press the button again i cant open it again how can i find a solution for this problem????

Share this post


Link to post
Share on other sites



Would you perhaps mind adding the code you have so we can help? :D

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

oke wel this is the first game i made only itas has to be bug fix

$status=GUICtrlCreateButton("Status",25,200,40,40) 

While 1
$msg = GUIGetMsg($main_GUI)

If $msg = $GUI_EVENT_CLOSE Then
    If WinActive("elcaponis") then Exit
    If WinActive("Hunt") then GUIDelete($Hunt)
    If WinActive("Status") then GUIDelete($status)
EndIf
    If $msg = $hunt then Gui2create()
    if $msg = $status then Gui3create()
Wend


func Gui2create()
If WinExists("Hunt") then Return
$Hunt = GUICreate("",100,100,700,550)
GUISetBkColor(0x49bf49)
$button =  GUICtrlCreatePic("Blood Hund.jpg",18,18 ,64,64)
GUISetState (@SW_SHOW)
EndFunc

Func Gui3create()
if WinExists("Status") then Return
$status= GUICreate("Status",300,200,200,200)
GUISetBkColor(0xB7B7B7)
GUISetState(@SW_SHOW)
EndFunc
Edited by Cloudsx

Share this post


Link to post
Share on other sites

COould some one please help me with this

Share this post


Link to post
Share on other sites

COould some one please help me with this

HI,

that isn't the complete script. The Gui is missing. :">

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

yes sorry i have it put out but i will give u now the good example

#include <GUIconstants.au3>

$Player=IniRead("Player.ini", "Player", "PlayerName","NotSet"); Reads the player from the ini file

;if the ini file does not exist or no entry then load the file open dialogue.
If $Player = "NotSet" then
   MsgBox(4096,"Choose your picture", "choose you picture you want to use for the game")
   $Player=FileOpenDialog ("choose your picture","C:\","(*.*)")
EndIf

IniWrite ("Player.ini", "Player", "PlayerName", $Player);write the player back to the ini file


$main_GUI = GUICreate ("elcaponis" ,400,400)
GUISetState(@SW_SHOW)
GUICtrlCreatePic ($Player,25,70,64,64);you should be adjust at size your image

$exp = IniRead("Exp.ini", "Exp", "Exp",0)
$Lvl =  IniRead("Exp.ini", "Lvl", "Lvl",0)
$TNL = IniRead("Exp.ini", "TNL", "TNL",0) 
$HP = IniRead("HP.ini", "HP","HP",0)
$MP = iniRead("MP.ini", "MP","MP",0)

GUICtrlCreateLabel("Exp", 25,15, 25,25)
$exp = GuiCtrlCreateLabel($exp,50,15)

GUICtrlCreateLabel("Lvl", 70,15,25,25)
$Lvl = GUICtrlCreateLabel($Lvl,95,15)

GUICtrlCreateLabel("Tnl", 120,15,25,25)
$TNL=GUICtrlCreateLabel($TNL,145,15)

GUICtrlCreateLabel("HP:",30,150,25,25)
$HP=GUICtrlCreateLabel($HP,50,150)

GUICtrlCreateLabel("MP:",30,175,25,25)
$MP=GUICtrlCreateLabel($Mp,50,175)

if $exp > 50 Then $Lvl + 1
if $exp > 50 Then $HP + 12
if $exp > 50 then $MP + 6 
if $exp > 120 then $Lvl + 1
if $exp > 120 then $HP + 12
if $exp > 120 then $mp + 6
if $exp > 290 then $Lvl + 1
if $exp > 290 then $HP + 12
If $exp > 290 then $mp + 6
If $exp > 630 Then $Lvl + 1
if $exp > 630 then $HP + 12
if $exp > 630 then $MP + 6
    
    
    
Opt("GUICoordMode",4)
$Hunt=GUICtrlCreateButton("Hunt",200, 350, 40,40)
$status=GUICtrlCreateButton("Status",25,200,40,40) 

While 1
$msg = GUIGetMsg($main_GUI)

If $msg = $GUI_EVENT_CLOSE Then
    If WinActive("elcaponis") then Exit
    If WinActive("Hunt") then GUIDelete($Hunt)
    If WinActive("Status") then GUIDelete($status)
EndIf
    If $msg = $hunt then Gui2create()
    if $msg = $status then Gui3create()
Wend


func Gui2create()
If WinExists("Hunt") then Return
$Hunt = GUICreate("",100,100,700,550)
GUISetBkColor(0x49bf49)
$button =  GUICtrlCreatePic("Blood Hund.jpg",18,18 ,64,64)
GUISetState (@SW_SHOW)
EndFunc

Func Gui3create()
if WinExists("Status") then Return
$status= GUICreate("Status",300,200,200,200)
GUISetBkColor(0xB7B7B7)
GUISetState(@SW_SHOW)
EndFunc

Global $Pic1 = 100000000000000000
$main = GUICreate('')
$button = GUICtrlCreateButton("Create Pic Button", 10, 10, 100, 30)
GUISetState()


While 2
    $msg = GUIGetMsg()
    If $msg = $button Then
        $Pic1 = GUICtrlCreatePic(@MyDocumentsDir "F:\autoit base\autoit basis2", 10, 100, 100, 30)
    EndIf
    If $msg = $Pic1 Then
        MsgBox(0, 'Works', 'You clicked the button pic')
    EndIf
WEnd

this one better

Cloud

Share this post


Link to post
Share on other sites

please can some one help me with this

Share this post


Link to post
Share on other sites

Is this what you're trying to do?

While 42
    $msg = GUIGetMsg()
    If $msg = $button Then
        GUICtrlSetState($button, $GUI_DISABLE)
        $Pic1 = GUICtrlCreatePic(@MyDocumentsDir "F:\autoit base\autoit basis2", 10, 100, 100, 30)
    EndIf
    If $msg = $Pic1 Then
        MsgBox(0, 'Works', 'You clicked the button pic')
    EndIf
WEnd

p.s. It's best not to recreate controls in a loop, unless you're tracking each instance.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

oke thanks and can i also use to the line of endif and then i can use it

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
Sign in to follow this  
Followers 0