Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System
- Imports System.IO
- Imports System.Diagnostics
- Imports System.Threading
- Public Class Form1 ' My class
- Private _Lines As String() ' Creates an array for my lines
- Dim fifa15configfile As StreamWriter ' Declare the variable for writing to the config file
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Upon loading my form do...
- If My.Computer.FileSystem.FileExists(".\config.txt") Then ' Check for file existing
- _Lines = File.ReadAllLines(".\config.txt") ' If it exists, put the text in _Lines variable
- TextBox1.Text = _Lines(0) ' Text box displays the 1st line inside ".\config.txt"
- Else ' If it doesn't exist
- fifa15configfile = My.Computer.FileSystem.OpenTextFileWriter(".\config.txt", True) ' create this text file
- fifa15configfile.WriteLine("") ' Write an empty line
- fifa15configfile.Close() ' Close the file
- End If
- If My.Computer.FileSystem.FileExists("C:\Program Files (x86)\Origin\Origin Games\FIFA 15\fifa15.exe") Then ' If this file exists then...
- TextBox1.Text = "C:\Program Files (x86)\Origin\Origin Games\FIFA 15\fifa15.exe" ' Set the textbox to this path
- Else ' Otherwise do nothing
- End If
- Dim lines() As String = System.IO.File.ReadAllLines(".\config.txt") ' Read this config file into the array
- If lines(0).Contains(".exe") Then ' If array(0) contains .exe then...
- Button1.PerformClick() ' Simulate the Go button being pressed
- End If
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' When go is clicked
- Dim fifa15 As New ProcessStartInfo
- Dim fifa15config As FileInfo
- If TextBox1.Text = "" Then ' If the textbox is empty...
- MsgBox("Please select the fifa15.exe", MsgBoxStyle.Critical, "Error") ' Display this message
- Else ' If it's not
- fifa15config = My.Computer.FileSystem.GetFileInfo(TextBox1.Text) ' Get full path of .exe file
- Dim fifa15configpath As String = fifa15config.DirectoryName ' Get the directory of the .exe without including the /XXXX.exe part
- fifa15.WorkingDirectory = fifa15configpath ' Set the working directory to the path of the .exe
- fifa15.FileName = TextBox1.Text ' Set the process to be started to match that of what is in the textbox
- Process.Start(fifa15) ' Start the fifa15.exe process
- Dim lines() As String = System.IO.File.ReadAllLines(".\config.txt") ' Read every line in config.txt
- lines(0) = TextBox1.Text ' Line 0 is set to whatever is inside Textbox1.text
- File.WriteAllLines(".\config.txt", lines) ' Write every line inside the lines array into the config.txt
- End If
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- Me.Close() ' Close the program
- End Sub
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- Dim openFile As New OpenFileDialog
- If My.Computer.FileSystem.FileExists("C:\Program Files (x86)\Origin\Origin Games\FIFA 15\fifa15.exe") Then ' If this file exists then...
- openFile.InitialDirectory = "C:\Program Files (x86)\Origin\Origin Games\FIFA 15" ' Set the initial window when you click Browse to this location
- Else ' Or
- openFile.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ' Set it to My Computer/This PC, this is the GUID
- TextBox1.Text = ""
- End If
- openFile.FileName = "" ' Sets the Browse textbox as blank
- openFile.Multiselect = False ' Disables selecting multiple files
- openFile.Filter = "FIFA 15 (fifa15.exe)|fifa15.exe" ' Display the first part in the drop down | only allow the selection and viewing of fifa15.exe
- If openFile.ShowDialog = DialogResult.OK Then ' If the file is opened successfully
- Dim fileName As String = openFile.SafeFileName ' Set this variable as the file path that has just been opened
- TextBox1.Text = openFile.FileName ' Sets the text box as the file path
- End If
- End Sub
- Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
- MsgBox("Made by ellessess," & vbNewLine & "http://steamcommunity.com/id/infused_essy/" & vbNewLine & vbNewLine & "For Jakey!", MsgBoxStyle.OkOnly, "About") ' Parameters for the About window
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- Dim CheckFIFAConfigProcess = Process.GetProcessesByName("fifaconfig") ' Search for fifaconfig.exe
- If CheckFIFAConfigProcess.Count > 0 Then ' If the process is found
- AppActivate("FIFA 15") ' Activate the fifaconfig window
- SendKeys.Send("{ENTER}") ' Simulate an enter key press
- CheckFIFAConfigProcess(0).CloseMainWindow() ' Close the process window after enter has been sent
- Thread.Sleep(5000) ' Wait for five seconds
- End ' End my program, it's not needed anymore as it has fufilled function
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment