
Option Explicit On
Imports System.IO
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
Dim sfile As String
Public Sub ListBox_Save(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamWriter
Dim i As Short
'create a new streamwriter
oStream = New IO.StreamWriter(sFile)
'count each listbox item
For i = 0 To ListBox.Items.Count - 1
oStream.WriteLine(ListBox.Items(i))
Next
'close streamwriter
oStream.Close()
End Sub
Public Sub ListBox_Read(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamReader
Dim sLine As String
' Clear listbox
ListBox.Items.Clear()
' Check if file exists
Dim oFile As New IO.FileInfo(sFile)
'if the list.dat exists then read it...
If oFile.Exists() = True Then
oStream = New IO.StreamReader(sFile)
' read file
Do
'read each line
sLine = oStream.ReadLine()
If IsNothing(sLine) Then Exit Do
'add items to the listbox
ListBox.Items.Add(sLine)
'loop until it's done
Loop
'close the stream
oStream.Close()
End If
End Sub
Private Sub savelb()
'save a list.dat with listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Save(Accounts, sfile)
End Sub
Private Sub loadlb()
'load a list.dat to fill in listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Read(Accounts, sfile)
End Sub
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")
Try
loadlb()
Catch
MsgBox(ErrorToString)
End Try
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
savelb()
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
If Not Accounts.Items.Contains(NewUserTxt.Text) Then
Accounts.Items.Add(NewUserTxt.Text)
Else
MsgBox("Account is already in list.")
End If
If Not NewUserTxt.Text = "" Then
SaveSetting("AutoLogin.exe", "Users", NewUserTxt.Text, NewUserTxt.Text)
End If
If Not NewPassTxt.Text = "" Then
SaveSetting("AutoLogin.exe", "Pass", NewPassTxt.Text, NewPassTxt.Text)
End If
NewUserTxt.Clear()
NewPassTxt.Clear()
savelb()
End Sub
Private Sub Accounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accounts.SelectedIndexChanged
Try
UserTxt.Text = GetSetting("AutoLogin.exe", "Users", Accounts.SelectedItem)
Catch
MsgBox(ErrorToString)
End Try
Try
PassTxt.Text = GetSetting("AutoLogin.exe", "Pass", Accounts.SelectedItem)
Catch
MsgBox(ErrorToString)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Accounts.Items.Remove(Accounts.SelectedItem)
savelb()
End Sub
End Class
ElseIf CheckProcess("Wow.exe") = True Then
Somewhere here i need to bring "Wow.exe" to front.
SendKeys.Send(UserTxt.Text)
SendKeys.Send("{TAB}")
SendKeys.Send(PassTxt.Text)
SendKeys.Send("{ENTER}")
Dim Process As New Process()
ComboBox1.Items.Clear()
For Each Process In Process.GetProcesses(My.Computer.Name)
On Error Resume Next
ComboBox1.Items.Add(Process.ProcessName)
Next

