Sign in to follow this  
Followers 0
pvr1

Any help for a novice?

10 posts in this topic

#1 ·  Posted (edited)

Hi there,

just to let you know I am an absolute beginner, no experience with any coding at all (apart from the odd batch file). Any help and advice would be very much appreciated. I've done a load of tutorials and read alot of helpfiles etc and done some forum searching but I'm still very much scratching my head. I guess the best way to learn is by asking questions from helpful people and learning that way!

I really have a couple of questions that relate to the following that I have been playing with:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START GUI1 GUI section ###
Global $GUI1 = GUICreate("Test GUI1", 321, 264, 350, 275)
GUISetIcon("D:\temp\icon.ico")
Global $Upper = GUICtrlCreateGroup("", 8, 6, 304, 104)
Global $Icon = GUICtrlCreatePic("", 16, 20, 89, 81, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
Global $Name = GUICtrlCreateLabel(" Name", 140, 30, 35, 17, $WS_GROUP)
Global $Version = GUICtrlCreateLabel("Version", 144, 54, 39, 17)
Global $Author = GUICtrlCreateLabel("Author", 144, 78, 35, 17)
Global $ACEforNEXTPVR = GUICtrlCreateLabel("Test Prog", 200, 30, 87, 17)
Global $V = GUICtrlCreateLabel("1.0", 200, 54, 19, 17)
Global $SteebPVR = GUICtrlCreateLabel("Me", 200, 78, 54, 17)
Global $About = GUICtrlCreateLabel("About", 144, 116, 32, 17, $SS_CENTER)
Global $Info = GUICtrlCreateGroup("", 8, 130, 305, 88)
Global $Inf = GUICtrlCreateLabel("Info about the prog here", 16, 143, 290, 66)
Global $NextButton = GUICtrlCreateButton("Next", 240, 228, 74, 25)
GUISetState(@SW_SHOW, $GUI1)
#EndRegion ### START GUI1 GUI section ###

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $NextButton


        Case $GUI_EVENT_CLOSE
            $event_close = MsgBox(49, "Close Event", "You clicked CLOSE! Are you sure you want to exit?")
            If $event_close = 1 Then
                GUIDelete()
                Exit
            EndIf
    EndSwitch
WEnd

#Region ### START GUI2 GUI section ###
Global $GUI2 = GUICreate("TestGUI2", 321, 264, 350, 275)

etc etc

The code was originally created with the KODA designer then I've been tweaking it.

My 1st question would be for this label:

Global $Inf = GUICtrlCreateLabel("Info about the prog here", 16, 143, 290, 66)

is it possible to load text from a .txt rather than directly write it into the label info? (it would be a long line of text).

and here:

$Msg = GUIGetMsg()

Switch $Msg

Case $NextButton

you will notice a big gap. At this point if the user has pressed the 'Next' button I would like the current GUI to close and open a new GUI. I have no idea how to accomplish this, do I need to create a function or an event for this?

I thank you in advance for any help/advice and apologise for my 'newbie-ness' but guess we all have to start somewhere?

Edited by pvr1

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

To answer your first. You can write your info to a txt file, then do a file read on it.

For example, you have your info saved in C:\info.txt

you could then do

$infotxt=FileRead("C:\info.txt")

$Inf = GUICtrlCreateLabel($infotxt, 16, 143, 290, 66)

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

For your 2nd part, I would try not to recreate the Guis if possible. Create both Guis at the beginning then you can use GuiSetState to hide or show the relevant gui

So in your missing block you could do

GuiSetState(@SW_HIDE,$GUI1)

GuiSetState(@SW_SHOW,$GUI2)


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

To answer your first. You can write your info to a txt file, then do a file read on it.

For example, you have your info saved in C:\info.txt

you could then do

$infotxt=FileRead("C:\info.txt")

$Inf = GUICtrlCreateLabel($infotxt, 16, 143, 290, 66)

Many thanks for this, this works brilliantly. I have currently placed the variable $infotxt here in the code:

#include <WindowsConstants.au3>

$infotxt = FileRead("D:\ACE Test\info.txt")

#Region ### START ACE1 GUI section ###

is that a good place for it? Are there good practices as to where things like this should go?

And now just for a further question on this. The next GUI will also require some lines of different text. Rather than create a new .txt such as info2.txt is it possible to get different sections of text to load from one info.txt by setting some kind of flag in the text and a parameter in the code?

many thanks

Share this post


Link to post
Share on other sites

To answer your first. You can write your info to a txt file, then do a file read on it.

For example, you have your info saved in C:\info.txt

you could then do

$infotxt=FileRead("C:\info.txt")

$Inf = GUICtrlCreateLabel($infotxt, 16, 143, 290, 66)

many thanks for setting me off on the right path. To answer my later question I have now seen that I can achieve what I need to even better with an ini file which I can use throughout the program for various settings and text references.

Share this post


Link to post
Share on other sites

I would be very grateful for some further help out there! I was trying my best to search for answers where possible but a few things are still elusive.

Currently the script I have is:

#include <ButtonConstants.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#NoTrayIcon

$checksettings = IniRead("\settings.ini", "usersettings", "user", 0) ; Read the settings file for previous use

$infotxt = IniRead("settings.ini", "start", "info", "NotFound")
$locate_backuptxt = IniRead("settings.ini", "locatebackup", "configbackup", "NotFound")

#Region ### START ACE1 GUI section ###
Global $ACE1 = GUICreate("ACE for NextPVR", 321, 264, 350, 275)
GUISetIcon("ace.jpg")
Global $Upper = GUICtrlCreateGroup("", 8, 6, 304, 104)
Global $Icon = GUICtrlCreatePic("ace.jpg", 16, 20, 89, 81, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
Global $Name = GUICtrlCreateLabel(" Name", 140, 30, 35, 17, $WS_GROUP)
Global $Version = GUICtrlCreateLabel("Version", 144, 54, 39, 17)
Global $Author = GUICtrlCreateLabel("Author", 144, 78, 35, 17)
Global $ACEforNEXTPVR = GUICtrlCreateLabel("ACE for NextPVR", 200, 30, 87, 17)
Global $V = GUICtrlCreateLabel("1.0", 200, 54, 19, 17)
Global $SteebPVR = GUICtrlCreateLabel("SteebPVR", 200, 78, 54, 17)
Global $About = GUICtrlCreateLabel("About", 144, 116, 32, 17, $SS_CENTER)
Global $Info = GUICtrlCreateGroup("", 8, 130, 305, 88)
Global $Inf = GUICtrlCreateLabel($infotxt, 16, 143, 290, 66)
Global $NextButton = GUICtrlCreateButton("Next", 240, 228, 74, 25)
GUISetState(@SW_SHOW, $ACE1)
#EndRegion ### START ACE1 GUI section ###

#Region ### START ACE2 GUI section ###
Global $ACE2 = GUICreate("ACE for NextPVR", 321, 264, 350, 275)
GUISetIcon("D:\006.ico")
Global $Upper = GUICtrlCreateGroup("", 8, 6, 304, 56)
Global $locate = GUICtrlCreateLabel($locate_backuptxt, 16, 16, 290, 40)
Global $OK1Button = GUICtrlCreateButton("OK", 240, 68, 74, 25)
Global $LocateBackupProgress = GUICtrlCreateProgress(8, 70, 230, 14)
GUICtrlSetState($LocateBackupProgress, $GUI_HIDE)
GUISetState(@SW_HIDE, $ACE2)
#EndRegion ### START ACE2 GUI section ###

While 1
    $xornextMsg = GUIGetMsg()
    Switch $xornextMsg
        Case $NextButton
            GUISetState(@SW_HIDE, $ACE1)
            GUISetState(@SW_SHOW, $ACE2)
        Case $GUI_EVENT_CLOSE
            $event_close = MsgBox(49, "Close Event", "You clicked CLOSE! Are you sure you want to exit ACE?")
            If $event_close = 1 Then
                GUIDelete()
                Exit
            EndIf
    EndSwitch
WEnd

While 1
    $locBupMsg = GUIGetMsg()
    Switch $locBupMsg
        Case $OK1Button
            FileCopy(@AppDataCommonDir & "\NPVR\config.xml", "\ConfigBackUp\", 9)
    EndSwitch
WEnd

I am not getting something right for the file copy at the end. When the user clicks OK I want to copy a particular file (config.xml) over to the same folder as my script is in to a new (as yet uncreated folder) called ConfigBackup. What I have just does not run when I click OK.

I was also trying to show the progress indicator on the GUI at the same time when the OK button is clicked:

Global $LocateBackupProgress = GUICtrlCreateProgress(8, 70, 230, 14)
GUICtrlSetState($LocateBackupProgress, $GUI_HIDE)

amongst other things I tried

While 1
    $locBupMsg = GUIGetMsg()
    Switch $locBupMsg
        Case $OK1Button
            FileCopy(@AppDataCommonDir & "\NPVR\config.xml", "\ConfigBackUp\", 9)
                        GUICtrlSetState($LocateBackupProgress, $GUI_SHOW)

    EndSwitch
WEnd

but that didn't do anything either. I really am most grateful for any advice. This is the best way of learning!

Share this post


Link to post
Share on other sites

I am assuming you wish to create a ConfigBackUp folder inside your NPVR folder?

try

FileCopy(@AppDataCommonDir & "\NPVR\config.xml", @AppDataCommonDir & "\NPVR\ConfigBackUp\", 9)


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I am assuming you wish to create a ConfigBackUp folder inside your NPVR folder?

try

FileCopy(@AppDataCommonDir & "\NPVR\config.xml", @AppDataCommonDir & "\NPVR\ConfigBackUp\", 9)

Hi kaotkbliss,

no actually I was trying to create it in the working directory of my script.

I had forgotten to put in a '.' so it was creating the directory one level up.

I now have this working if I put it at the top of my script as a standalone line:

FileCopy("C:\Users\Public\NPVR\config.xml", ".\ConfigBackUp\", 9)

[EDIT]Actually that is a 2nd place to look for the file in a Win7 environment, I haven't worked out how to look in both locations yet. The 1st location is:

FileCopy(@AppDataCommonDir & "\NPVR\config.xml", ".\ConfigBackUp\", 9) [EndEdit]

but if I cut it from there and insert it into my while section:

While 1
    $locBupMsg = GUIGetMsg()
    Switch $locBupMsg
        Case $OK1Button
            GUICtrlSetState($LocateBackupProgress, $GUI_SHOW)
            FileCopy(@AppDataCommonDir & "\NPVR\config.xml", ".\ConfigBackUp\", 9)
    EndSwitch
WEnd

it does not get created when I click on the button created by $OK1Button

I also cannot get any extra labels to show with the $GUI_SHOW when the button is pressed. Thank you so much for your time.

Edited by pvr1

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I guess I'm just not used to this and should be thinking ahead! The problem is that the file I am looking for (config.xml) could be in either location depending on the operating system.

I am using the full path for the Win7 system as I could not find an @ call for the Users/Public directory.

What I am trying to do is see if the file exists in the XP location or the Win7 location. I have tried using the 'FileExists' for this. Once I have found where the file is I want to write the location to the .ini file so that it can be referenced again.

When the OK button is pressed I want to copy the file from the location it was found in to the backup directory.

I also want to have some other buttons on the GUI hide/change during this.......

I am sure I will look back upon this with fondness but at the moment this is going way beyond anything I thought I understood from all the tutorials etc :-)

Edited by pvr1

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