Page 1 of 3 123 LastLast
Results 1 to 15 of 37
  1. #1
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow

    [Help]Saving settings[Solved]

    Okay this is kinda hard to explain so I'll post a pic of my form as well as it may help this make more sense.

    Here's my form:


    Okay basically it's a game auto-login I'm making for a friend of mine. To give a brief overview of what the program does: You browse for your game .exe using the browse button provided. Then you select your account from the list box and hit the big login button. The button first checks whether the game is running or not, if no it runs the given file path and then inputs the username and password of the given account into the game. If the game is running it simply inputs the account details.

    The add account button is pretty self explanatory, you put in your new account password and username and it will save it to the listbox under the given username.

    This brings me to the problem I'm having. What I would like to happen is when the person goes to the "Add new account" menu and inputs a username and password and presses "Save Details" I would like the following to happen:

    1. The username given to be saved as a new listbox entry (Already done)
    2. Have both the username and password saved somewhere so they can be recalled after the form has been shut and re-opened.

    Now when the person selects their account from the listbox I would like the "Username" box to come up with the username they inputted for their account and the "Password" textbox to come up with their inputted password (*** out of course but that's simple enough)

    So my question is, how do I save their inputted information from the "Add new account" section so that when they choose their username from the listbox, both the username and password will come up in their respective boxes?

    Hope someone understands what I'm asking, if you need more information please ask and I shall try and give it to you.

    Thanks,

    J-Deezy.
    Last edited by KING; 04-29-2010 at 02:43 PM.

  2. #2
    niccoletto's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Florence - Italy ♥
    Posts
    30
    Reputation
    10
    Thanks
    1
    My Mood
    Amazed
    It's a bit unsafe, waiting for someone who will test it. I won't do it.
    I'm Italian. Italy is falling down.
    I come from the Count of Tuscany (Dream Theater)

  3. #3
    wtfiwantthatname's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Posts
    260
    Reputation
    10
    Thanks
    39
    My Mood
    Bored
    Store them internally or in an ini file.
    "I don't believe in an afterlife, so I don't have to spend my whole life fearing hell, or fearing heaven even more. For whatever the tortures of hell, I think the boredom of heaven would be even worse." - Isaac Asimov

  4. #4
    MJLover's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Neverland
    Posts
    759
    Reputation
    33
    Thanks
    110
    My Mood
    Cheerful
    Use SaveSetting on exiting the form, and GetSetting on form's load event.

    Format is:

    Code:
    SaveSetting(Application.ProductName,"Settings","ReplaceWithSettingName","ReplaceWithSettingValue")
    And GetSetting:

    Code:
    Dim val as string = GetSetting(Application.ProductName,"Settings","ReplaceWithSettingName","ReplaceWithDefaultValue")
    Then assign this value where it belongs !!

  5. #5
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Quote Originally Posted by niccoletto View Post
    It's a bit unsafe, waiting for someone who will test it. I won't do it.
    It's not even a download


     


     


     



    The Most complete application MPGH will ever offer - 68%




  6. #6
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Okay thanks for that MJ I'll test it out when I get home from school. I've also hit another snag, could someone please tell me how to check if a process is already running? I googled around but most of it was some huge code which didn't really relate to what I wanted.

    All i want to happen is to have a timer running constantly in the background checking whether the process is running or not and check/uncheck the checkbox accordingly.

    Thanks,
    J-Deezy

  7. #7
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Create a Function

    [php]
    Function CheckProcess(ByVal strProcess)
    Dim Process, strObject
    CheckProcess = False
    strObject = "winmgmts://"
    For Each Process In GetObject(strObject).InstancesOf("win32_process")
    If UCase(Process.name) = UCase(strProcess) Then
    CheckProcess = True
    ' MsgBox("explorer.exe")
    Exit Function
    End If
    Next
    End Function
    [/php]

    Now you can use form load, or a button , or whatever to determine if a process is running

    CheckProcess("Process to check for")

    Example, If I want to check for explorer.exe

    CheckProcess("explorer.exe")

    If it is true it will turn on the flag "CheckProcess" , then you do whatever you want

    [php]
    If CheckProcess=True then
    Yada yada
    Else
    Yada Yada
    End If
    [/php]

    You can ignore the 'MessageBox part, I was testing to be sure it was working right



     


     


     



    The Most complete application MPGH will ever offer - 68%




  8. The Following User Says Thank You to NextGen1 For This Useful Post:

    Jason (04-27-2010)

  9. #8
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Thanks, just by looking at it seems to be exactly what I'm looking for. I'm currently sitting in last period so I can't actually test it but I'll be sure to thank you after I give it a test. Been considering how I can use the "SaveSettings" to save each individual account and I think I have a solution haha. We'll see.

    Thanks again for all your help.

    J-Deezy.

  10. #9
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Not a prob, No need to thank, it's just a button , You already said it .

    @ settings, the tut section has 1 or 2 setting tutorials that may help as well.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  11. #10
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Quote Originally Posted by NextGen1 View Post
    [FONT="Tahoma"]

    [php]
    Function CheckProcess(ByVal strProcess)
    Dim Process, strObject
    CheckProcess = False
    strObject = "winmgmts://"
    For Each Process In GetObject(strObject).InstancesOf("win32_process")
    If UCase(Process.name) = UCase(strProcess) Then
    CheckProcess = True
    ' MsgBox("explorer.exe")
    Exit Function
    End If
    Next
    End Function
    [/php]
    [php] Public Function IsProcessOpen(ByVal name As String) As Boolean

    For Each clsProcess As Process In Process.GetProcesses

    If clsProcess.ProcessName.Contains(name) Then


    Return True

    End If
    Next
    ' Do nothing
    Return False
    End Function[/php]

    Code:
    If Isprocessopen("process") then
    whatever
    end if
    Code:
    If not isprocessopen("process") then
    whatever
    end if



  12. #11
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    I like Blubbs version better, effective and clean, good job.

    My version can check applications running on a server as well though


     


     


     



    The Most complete application MPGH will ever offer - 68%




  13. #12
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Okay thanks for that guys. It's now checking processes perfectly. The only problem I'm having at the moment is if the process is already running, bring it to the topmost window. Because I'm using SendKeys.Send to send the text I need the application to be at the top to successfully get the inputted user/pass.

    Is there any way to bring it to top? I've heard that with OS changes microsoft did something to change the old VB code to bring to top and since most tuts i found via google are for VB6 or earlier, they aren't much help.

    Cheers,

    J-Deezy

  14. #13
    Invidus's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    2,167
    Reputation
    23
    Thanks
    650
    My Mood
    Bored
    Me.Topmost = True

    That'll bring the form to the top, but you'll need some edits to bring the process. Waiting for NextGen input..

  15. #14
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Woot! After much brainstorming I managed to come up with a code for saving the settings that works! For once I managed to figure something out without using Google haha, I must be progressing.

    Sure, it's not the prettiest code in the world but it's effective.

    This is the "Save Details" button code
    Code:
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    
            Accounts.Items.Add(NewUserTxt.Text)
    
            SaveSetting("AutoLogin.exe", NewUserTxt.Text, "User", NewUserTxt.Text)
    
            SaveSetting("AutoLogin.exe", NewUserTxt.Text, "Pass", NewPassTxt.Text)
    
    
        End Sub
    And this is how it pulls the information of each account according to whichever is selected in the listbox:

    Code:
        Private Sub Accounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accounts.SelectedIndexChanged
    
            UserTxt.Text = GetSetting("AutoLogin.exe", Accounts.SelectedItem, "User")
    
            PassTxt.Text = GetSetting("AutoLogin.exe", Accounts.SelectedItem, "Pass")
        End Sub
    So yeah that works perfectly despite it being a bit clumsy.

    The only thing left to do is figure out how to move the process to the top window if it's already running (for example after I do (CheckProcess("Notepad.exe")) if the value is true then Notepad should become to focus window)

    Any ideas? Thanks so much for your help on this guys, really made it a lot less frustrating haha

    J-Deezy.

    EDITTT: Spoke wayyy too soon. While that code is all fine and dandy while the app is still running, I'm having trouble recalling all the usernames into the ListBox on start. More brainstorming it seems

    Okay EDIT2: I changed the order of the "SaveSetting(" to
    Code:
     SaveSetting("AutoLogin.exe", "Users", NewUserTxt.Text, NewUserTxt.Text)
    Because I figure in theory using "Listbox1.Items.Add(GetSetting("AutoLogin.Exe" , "Users")"
    Would simply load all the .text saved into the "Users" folder into separate Listbox entries. Apparently not. Is there any way to do this?

    Cheers. (Still need help on the "bring process to top" question )
    Last edited by Jason; 04-27-2010 at 03:33 AM.

  16. #15
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    EDIT3: Okay it appears the only way to save the contents of a listbox is to save to a .txt file and get them from there upon form reload. I'm currently googling it at the moment but if anyone wants to provide a quick snippet to save time feel free

    Still working on trying to call process to top :@ it's annoying haha, so close to being finished.

Page 1 of 3 123 LastLast

Similar Threads

  1. [Help]Saving ListView[Solved]
    By Lyoto Machida in forum Visual Basic Programming
    Replies: 19
    Last Post: 02-11-2011, 08:33 PM
  2. [Help]Save track bar settings[Solved]
    By jajarem64 in forum Visual Basic Programming
    Replies: 16
    Last Post: 06-17-2010, 11:03 PM
  3. [Help] save settings.
    By hopefordope in forum Visual Basic Programming
    Replies: 12
    Last Post: 05-17-2010, 07:05 AM
  4. [Help]Save Text[Solved]
    By Shark23 in forum Visual Basic Programming
    Replies: 7
    Last Post: 04-15-2010, 11:08 AM
  5. [Help]Saving Settings of a form[solved]
    By poneboy00 in forum Visual Basic Programming
    Replies: 9
    Last Post: 03-20-2010, 09:18 AM