Okay this is my whole code.
Code:
Option Explicit On
Imports System.IO
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
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
Exit Function
End If
Next
End Function
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As UIntPtr, ByVal lParam As IntPtr) As IntPtr
Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox5.Text = GetSetting("WorkingSettings.exe", "Settings", "Text")
Dim reader As String
reader = My.Computer.FileSystem.ReadAllText("C:\Users\*****\Documents\Testss.txt")
Dim strs() As String
strs = Split(reader, Environment.NewLine)
For Each s As String In strs
Accounts.Items.Add(s)
Next
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim OpenFileDialog1 As New OpenFileDialog
OpenFileDialog1.InitialDirectory = "Desktop"
OpenFileDialog1.Filter = "exe files (*.exe)|*.exe|All files (*.*)|*.*"
OpenFileDialog1.FilterIndex = 1
OpenFileDialog1.RestoreDirectory = True
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
TextBox5.Text = OpenFileDialog1.FileName
SaveSetting("WorkingSettings.exe", "Settings", "Text", TextBox5.Text)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CheckProcess("Wow.exe")
If TextBox5.Text = "" Then
MsgBox("Please select your .exe", vbCritical, "Error")
ElseIf CheckProcess("Wow.exe") = True Then
SendKeys.Send(UserTxt.Text)
SendKeys.Send("{TAB}")
SendKeys.Send(PassTxt.Text)
SendKeys.Send("{ENTER}")
ElseIf CheckProcess("Wow.exe") = False Then
System.Diagnostics.Process.Start(TextBox5.Text)
Sleep(5000)
SendKeys.Send(UserTxt.Text)
SendKeys.Send("{TAB}")
SendKeys.Send(PassTxt.Text)
SendKeys.Send("{ENTER}")
End If
End Sub
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", "Users", NewUserTxt.Text, NewUserTxt.Text)
SaveSetting("AutoLogin.exe", "Pass", NewUserTxt.Text, NewPassTxt.Text)
NewUserTxt.Clear()
NewPassTxt.Clear()
Dim writer As New IO.StreamWriter("C:\Users\*****\Documents\Testss.txt")
For i As Integer = 0 To Accounts.Items.Count - 1
writer.WriteLine(Accounts.Items.Item(i))
Next
writer.Close()
End Sub
Private Sub Accounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accounts.SelectedIndexChanged
UserTxt.Text = GetSetting("AutoLogin.exe", "Users", Accounts.SelectedItem)
PassTxt.Text = GetSetting("AutoLogin.exe", "Pass", Accounts.SelectedItem)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Accounts.Items.Remove(Accounts.SelectedItem)
End Sub
End Class
And the only problems I'm currently experiencing are:
1. After closing and re-opening the program, the saved listbox entries all work fine but there is always a new blank listbox entry created each startup.

Here's an SS of problem #1.
The error is occuring with this line of code:
Code:
Private Sub Accounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accounts.SelectedIndexChanged
UserTxt.Text = GetSetting("AutoLogin.exe", "Users", Accounts.SelectedItem)
PassTxt.Text = GetSetting("AutoLogin.exe", "Pass", Accounts.SelectedItem)
End Sub
Problem number 2. When I press button4 (To delete an account from the list) The same error occurs on the same line of code.
If you need more info just tell me i'll be up for a while.