Sign in to follow this  
Followers 0
OmenSWE

Trying to save my labels

11 posts in this topic

#1 ·  Posted (edited)

Hello i'am new :D

i want to save the text that you put in to you Input so you can load it later.

i have try and try and i cant get it to work. :D

Pleas help a beginner. :)

CODE

#include <GUIConstants.au3>

#include <GuiTab.au3>

#include <File.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

Opt('MustDeclareVars', 1)

Dim $input[20],$Label[20],$btnExit, $tab, $tab0, $tab1, $tab1combo,$btntab2,$tab2,$btnSave,$file

$file = FileOpen("test.txt", 0)

GUICreate("Keypad typer", 330, 350)

GUISetFont(9, 300)

;;;;;;;;;;;;;;;;;;;Pad send text;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;Hide background and add color;;;;;;;;;;;;;;;;;;;;

GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

;;;; Pad that start the text ;;;;

HotKeySet("{NUMPAD0}", "Speak0")

HotKeySet("{NUMPAD1}", "Speak1")

HotKeySet("{NUMPAD2}", "Speak2")

HotKeySet("{NUMPAD3}", "Speak3")

HotKeySet("{NUMPAD4}", "Speak4")

HotKeySet("{NUMPAD5}", "Speak5")

HotKeySet("{NUMPAD6}", "Speak6")

HotKeySet("{NUMPAD7}", "Speak7")

HotKeySet("{NUMPAD8}", "Speak8")

HotKeySet("{NUMPAD9}", "Speak9")

;;;;;;;;;;;Alt + numpad ;;;;;;;;;;;;;;;;;;

HotKeySet("^{NUMPAD0}", "Speak10")

HotKeySet("^{NUMPAD1}", "Speak11")

HotKeySet("^{NUMPAD2}", "Speak12")

HotKeySet("^{NUMPAD3}", "Speak13")

HotKeySet("^{NUMPAD4}", "Speak14")

HotKeySet("^{NUMPAD5}", "Speak15")

HotKeySet("^{NUMPAD6}", "Speak16")

HotKeySet("^{NUMPAD7}", "Speak17")

HotKeySet("^{NUMPAD8}", "Speak18")

HotKeySet("^{NUMPAD9}", "Speak19")

;;;;;;;;;;;;Tabs codes;;;;;;;;;;;;;;;;;;;;;;

$tab = GUICtrlCreateTab(10, 330, 293, 20,$TCS_MULTILINE + $TCS_FIXEDWIDTH)

GUICtrlSetBkColor($tab,$GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetState(-1, $GUI_SHOW) ; will be display first

GUICtrlCreatePic("Background.bmp" , 0, 0, 330, 350)

GuiCtrlSetState(-1,$GUI_DISABLE)

$tab0 = GUICtrlCreateTabItem("Welcome")

GUICtrlCreateLabel("Welcome", 140, 120)

GUICtrlCreateLabel("This program is freeware", 100, 130)

GUICtrlCreateLabel("This program is made for nwn2", 87, 140)

GUICtrlCreateLabel("It make you send message on key pad", 70, 150)

$btnExit = GUICtrlCreateButton("Exit", 140, 170, 60)

$btnSave = GUICtrlCreateButton("Save", 140, 190, 60)

GUICtrlSetOnEvent($btnExit, "_Terminate")

GUICtrlSetOnEvent($btnSave, "_Save")

GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("Numpad text")

$Label[0] = GUICtrlCreateLabel("Numpad 0", 25, 15)

$input[0] = GUICtrlCreateInput("", 125, 10, 180, 25)

$Label[1] = GUICtrlCreateLabel("Numpad 1", 25, 45)

$input[1] = GUICtrlCreateInput("", 125, 40, 180, 25)

$Label[2] = GUICtrlCreateLabel("Numpad 2", 25, 75)

$input[2] = GUICtrlCreateInput("", 125, 70, 180, 25)

$Label[3] = GUICtrlCreateLabel("Numpad 3", 25, 105)

$input[3] = GUICtrlCreateInput("", 125, 100, 180, 25)

$Label[4] = GUICtrlCreateLabel("Numpad 4", 25, 135)

$input[4] = GUICtrlCreateInput("", 125, 130, 180, 25)

$Label[5] = GUICtrlCreateLabel("Numpad 5", 25, 165)

$input[5] = GUICtrlCreateInput("", 125, 160, 180, 25)

$Label[6] = GUICtrlCreateLabel("Numpad 6", 25, 195)

$input[6] = GUICtrlCreateInput("", 125, 190, 180, 25)

$Label[7] = GUICtrlCreateLabel("Numpad 7", 25, 225)

$input[7] = GUICtrlCreateInput("", 125, 220, 180, 25)

$Label[8] = GUICtrlCreateLabel("Numpad 8", 25, 255)

$input[8] = GUICtrlCreateInput("", 125, 250, 180, 25)

$Label[9] = GUICtrlCreateLabel("Numpad 9", 25, 285)

$input[9] = GUICtrlCreateInput("", 125, 280, 180, 25)

For $i = 0 To 9

GUICtrlSetBkColor($Label[$i],$GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ($Label[$i],0xff0000)

Next

GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("Ctrl numpad text")

$Label[10] = GUICtrlCreateLabel("Numpad 0", 25, 15)

$input[10] = GUICtrlCreateInput("", 125, 10, 180, 25)

$Label[11] = GUICtrlCreateLabel("Numpad 1", 25, 45)

$input[11] = GUICtrlCreateInput("", 125, 40, 180, 25)

$Label[12] = GUICtrlCreateLabel("Numpad 2", 25, 75)

$input[12] = GUICtrlCreateInput("", 125, 70, 180, 25)

$Label[13] = GUICtrlCreateLabel("Numpad 3", 25, 105)

$input[13] = GUICtrlCreateInput("", 125, 100, 180, 25)

$Label[14] = GUICtrlCreateLabel("Numpad 4", 25, 135)

$input[14] = GUICtrlCreateInput("", 125, 130, 180, 25)

$Label[15] = GUICtrlCreateLabel("Numpad 5", 25, 165)

$input[15] = GUICtrlCreateInput("", 125, 160, 180, 25)

$Label[16] = GUICtrlCreateLabel("Numpad 6", 25, 195)

$input[16] = GUICtrlCreateInput("", 125, 190, 180, 25)

$Label[17] = GUICtrlCreateLabel("Numpad 7", 25, 225)

$input[17] = GUICtrlCreateInput("", 125, 220, 180, 25)

$Label[18] = GUICtrlCreateLabel("Numpad 8", 25, 255)

$input[18] = GUICtrlCreateInput("", 125, 250, 180, 25)

$Label[19] = GUICtrlCreateLabel("Numpad 9", 25, 285)

$input[19] = GUICtrlCreateInput("", 125, 280, 180, 25)

For $i = 10 To 19

GUICtrlSetBkColor($Label[$i],$GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ($Label[$i],0xff0000)

Next

GUICtrlCreateTabItem("") ; end tabitem definition

;;;;;;;Let start it all;;;;;;;;;;

GUISetState()

_GUICtrlTabSetMinTabWidth ($tab, 15)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

While 1

Sleep(0)

WEnd

Func _Terminate()

Exit

EndFunc

Func _Save()

_FileWriteToLine($file, 1, GUICtrlRead($input[1]), 1)

_FileWriteToLine($file, 2, GUICtrlRead($input[2]), 1)

_FileWriteToLine($file, 3, GUICtrlRead($input[3]), 1)

_FileWriteToLine($file, 4, GUICtrlRead($input[4]), 1)

_FileWriteToLine($file, 5, GUICtrlRead($input[5]), 1)

_FileWriteToLine($file, 6, GUICtrlRead($input[6]), 1)

_FileWriteToLine($file, 7, GUICtrlRead($input[7]), 1)

_FileWriteToLine($file, 8, GUICtrlRead($input[8]), 1)

_FileWriteToLine($file, 9, GUICtrlRead($input[9]), 1)

_FileWriteToLine($file, 0, GUICtrlRead($input[0]), 1)

_FileWriteToLine($file, 11, GUICtrlRead($input[11]), 1)

_FileWriteToLine($file, 12, GUICtrlRead($input[12]), 1)

_FileWriteToLine($file, 13, GUICtrlRead($input[13]), 1)

_FileWriteToLine($file, 14, GUICtrlRead($input[14]), 1)

_FileWriteToLine($file, 15, GUICtrlRead($input[15]), 1)

_FileWriteToLine($file, 16, GUICtrlRead($input[16]), 1)

_FileWriteToLine($file, 17, GUICtrlRead($input[17]), 1)

_FileWriteToLine($file, 18, GUICtrlRead($input[18]), 1)

_FileWriteToLine($file, 19, GUICtrlRead($input[19]), 1)

_FileWriteToLine($file, 10, GUICtrlRead($input[10]), 1)

EndFunc

;;;; Toggle Pause and Splash On/Off Start ;;;;

Func Speak0()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[0]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak1()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[1]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak2()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[2]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak3()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[3]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak4()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[4]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak5()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[5]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak6()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[6]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak7()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[7]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak8()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[8]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak9()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[9]))

Sleep(200)

Send("{ENTER}")

EndFunc

;;;;;;;;;alt + nupad talk;;;;;;;;;;;;;;;;;

Func Speak10()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[10]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak11()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[11]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak12()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[12]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak13()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[13]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak14()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[14]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak15()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[15]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak16()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[16]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak17()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[17]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak18()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[18]))

Sleep(200)

Send("{ENTER}")

EndFunc

Func Speak19()

Send("{ENTER}")

Sleep(50)

Send(GUICtrlRead($input[19]))

Sleep(200)

Send("{ENTER}")

EndFunc

Edited by OmenSWE

Share this post


Link to post
Share on other sites



What's exactly problem? Your script looks good.

Thank :)

The problem is that it dont write any text in the txt file when you press save

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank :)

The problem is that it dont write any text in the txt file when you press save

$file = FileOpen("test.txt", 0)oÝ÷ ÙÈZ­¡«­¢+ØÀÌØí¥±ô¥±=Á¸ ÅÕ½ÐíÑÍйÑáÐÅÕ½Ðì°È¤oÝ÷ ÚÚºÚ"µÍÌÍÙ[HH ][ÝÝÝ    ][Ý
Edited by Zedna

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

no did not help :)

After you re-edit it still dont work

Wait wait wait it looks like it works :">

just look like it is slow

Edited by OmenSWE

Share this post


Link to post
Share on other sites

How do i clear the txt file?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

no did not help :)

After you re-edit it still dont work

_FileWriteToLine() is complicated (inside it) and isn't effective, so rather use better way:

$file = FileOpen("test.txt", 2)
...

FileWrite($file, GUICtrlRead($input[1]) & @CRLF)
FileWrite($file, GUICtrlRead($input[2]) & @CRLF)
...
FileWrite($file, GUICtrlRead($input[19]) & @CRLF)
FileClose($file)

EDIT: or even better with INI files, look into HelpFile at IniWrite()

Edited by Zedna

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

_FileWriteToLine() is complicated (inside it) and isn't effective, so rather use better way:

$file = FileOpen("test.txt", 2)
...

FileWrite($file, GUICtrlRead($input[1]) & @CRLF)
FileWrite($file, GUICtrlRead($input[2]) & @CRLF)
...
FileWrite($file, GUICtrlRead($input[19]) & @CRLF)
FileClose($file)

EDIT: or even better with INI files, look into HelpFile at IniWrite()

Made it to a ini file now how to make it load it all? Edited by OmenSWE

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

IniRead and GUICtrlSetData, see HelpFile

thank some thing like this?

GUICtrlSetData(-1,$input[0], IniRead("saved.ini", "Numpad", "text0", ""))

This code dont work ok :)

Edited by OmenSWE

Share this post


Link to post
Share on other sites

Wait i removed the controlID = -1, thing now it work perfect=)

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