Sign in to follow this  
Followers 0
8879899714

Help with GUI input

4 posts in this topic

hi people,

need some help here ... i am trying to write a GUI interface whereby i can save the inputs to a file and then load them back when i start the interface.

i am not getting anywhere, especially after i tried loading, the input is blank. can anyone look into my script and correct me?

thanks :)

#include <GUIConstants.au3>

Global $start

Global $way1x, $way1y

GUICreate("Testscript", 300, 420)

$savebotbutt=GUICtrlCreateButton("Save", 160, 390, 60, 30) ; show the Save button

$exitbotbutt=GUICtrlCreateButton("Exit", 220, 390, 80, 30) ; show the Exit button

$showGUI = 0 ; setting the GUI condition

HotKeySet("{F6}","show") ; using hotkey to show menu

GUICtrlCreateTab (0, 0, 300, 390)

$tab2=GUICtrlCreateTabitem ("WayPoints")

GUICtrlCreateLabel ("Training Ground Location", 10, 30, 200, 20)

$checkCN = GUICtrlCreateCheckbox ("", 20, 50, 20, 20) ; 1st checkbox location

GUICtrlCreateLabel ("X : ", 60, 50, 15, 20)

;~ $way1x = Int(IniRead(".\testscript.ini","Waypoints","1x","-1"))

GUICtrlCreateInput ($way1x, 80, 50, 50, 20)

GUICtrlCreateLabel ("Y : ", 150, 50, 15, 20)

;~ $way1y = Int(IniRead(".\testscript.ini","Waypoints","1y","-1"))

GUICtrlCreateInput ($way1y, 170, 50, 50, 20)

Func show()

If $showGUI = 0 Then

Read()

GUISetState(@SW_SHOW) ; show the menu when hotkey pressed

$showGUI = 1

Else

GUISetState(@SW_HIDE) ; hide the menu when hotkey pressed

$showGUI = 0

EndIf

EndFunc

While 1 ; main body of program, loop till condition met

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE ; when the top right cancel button is pressed

Exit

Case $msg = $savebotbutt ; pressing the Save button

Write()

MsgBox(64, "Test Box", "You clicked on Save!")

Case $msg = $exitbotbutt ; pressing the Exit button

Exit

EndSelect

Wend

Func Write()

IniWrite(".\testscript.ini","Waypoints","1x",$way1x)

IniWrite(".\testscript.ini","Waypoints","1y",$way1y)

EndFunc

Func Read()

$way1x = Int(IniRead(".\testscript.ini","Waypoints","1x","-1"))

$way1y = Int(IniRead(".\testscript.ini","Waypoints","1y","-1"))

EndFunc

Share this post


Link to post
Share on other sites



Maybe...

#include <GUIConstants.au3>

Global $start
Global $way1x, $way1y
$showGUI = 0 ; setting the GUI condition

HotKeySet("{F6}", "show") ; using hotkey to show menu

Read()

GUICreate("Testscript", 300, 420)
$savebotbutt = GUICtrlCreateButton("Save", 160, 390, 60, 30) ; show the Save button
$exitbotbutt = GUICtrlCreateButton("Exit", 220, 390, 80, 30) ; show the Exit button
GUICtrlCreateTab(0, 0, 300, 390)
$tab2 = GUICtrlCreateTabItem("WayPoints")
GUICtrlCreateLabel("Training Ground Location", 10, 30, 200, 20)
$checkCN = GUICtrlCreateCheckbox("", 20, 50, 20, 20) ; 1st checkbox location
GUICtrlCreateLabel("X : ", 60, 50, 15, 20)
;~ $way1x = Int(IniRead(".\testscript.ini","Waypoints","1x","-1"))
$input_x = GUICtrlCreateInput($way1x, 80, 50, 50, 20)
GUICtrlCreateLabel("Y : ", 150, 50, 15, 20)
;~ $way1y = Int(IniRead(".\testscript.ini","Waypoints","1y","-1"))
$input_y = GUICtrlCreateInput($way1y, 170, 50, 50, 20)
GUISetState(@SW_HIDE)


While 1 ; main body of program, loop till condition met
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE ; when the top right cancel button is pressed
            Exit
        Case $msg = $savebotbutt ; pressing the Save button
            Write()
            MsgBox(64, "Test Box", "You clicked on Save!")
        Case $msg = $exitbotbutt ; pressing the Exit button
            Exit
    EndSelect
WEnd

;;-------------------------------------- Functions --------------------------------

Func show()
    If $showGUI = 0 Then
        Read()
        GUISetState(@SW_SHOW) ; show the menu when hotkey pressed
        $showGUI = 1
    Else
        GUISetState(@SW_HIDE) ; hide the menu when hotkey pressed
        $showGUI = 0
    EndIf
EndFunc   ;==>show

Func Write()
    IniWrite(".\testscript.ini", "Waypoints", "1x", GUICtrlRead($input_x))
    IniWrite(".\testscript.ini", "Waypoints", "1y", GUICtrlRead($input_y))
EndFunc   ;==>Write

Func Read()
    $way1x = Int(IniRead(".\testscript.ini", "Waypoints", "1x", "-1"))
    $way1y = Int(IniRead(".\testscript.ini", "Waypoints", "1y", "-1"))
EndFunc   ;==>Read

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Hi Valuater,

thanks for the help. it works wonder :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi Valuater,

thanks for the help. it works wonder :)

Welcome

whats the phone number for???

8)

Thanks for sharing

Posted Image

Edited by Valuater

NEWHeader1.png

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