четверг, 21 марта 2013 г.

Process Explorer Project




Imports System.Runtime.InteropServices
Public Class Form1
    Dim WithEvents pr As Process
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each Process In System.Diagnostics.Process.GetProcesses() ' Получаем Все процессы в LB
            ListBox1.Items.Add(Process.ProcessName)
        Next
    End Sub
    Private Sub TaskHook()
        pr = Process.GetProcessesByName(ListBox1.SelectedItem)(0) ' Отлавливаем завершение процесса
        pr.EnableRaisingEvents = True
    End Sub
    Private Sub ProcEx() Handles pr.Exited
        MsgBox("Process Closed")
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ListBox1.SelectedItems.Clear()
        For i As Integer = 0 To ListBox1.Items.Count - 1
            If ListBox1.Items(i).ToString().Contains(TextBox1.Text) Then ' Исчем процесс в списке
                ListBox1.SetSelected(i, True)
            End If
        Next
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            TaskHook()
            Dim классскрина As New СкриншотОкнаПоЗаголовку
            Dim process1 As Process = Process.GetProcessesByName(ListBox1.SelectedItem)(0)
            Dim title As String = process1.MainWindowTitle()
            Label1.Text = "H_WT :" & title.ToString
            PictureBox1.Image = классскрина.скрин_отдельного_окна(title)
            'Label2.Text = process1.MainModule.FileVersionInfo.ProductName
            Label3.Text = process1.MainModule.FileVersionInfo.CompanyName
            Label4.Text = process1.MainModule.FileVersionInfo.ProductVersion
            Label5.Text = process1.MainModule.FileVersionInfo.FileDescription
        Catch ex As Exception
            Label2.Text = "none"
            Label3.Text = "none"
            Label4.Text = "none"
            Label5.Text = "none"
        End Try

    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

    End Sub
End Class

Public Class СкриншотОкнаПоЗаголовку
     _
    Private Shared Function FindWindow( _
      ByVal lpClassName As String, _
      ByVal lpWindowName As String) As IntPtr
    End Function
    Public Shared Function FindWindow1(ByVal windowName As String, ByVal wait As Boolean) As Integer
        Dim hWnd As Integer = FindWindow(Nothing, windowName)
        While wait AndAlso hWnd = 0
            System.Threading.Thread.Sleep(500)
            hWnd = FindWindow(Nothing, windowName)
        End While
        Return hWnd
    End Function
    Function скрин_отдельного_окна(ByVal заголовок_окна As String) As Image
        Return CaptureWindow(FindWindow1(заголовок_окна, False))
    End Function
    Public Shared Function CaptureWindow(ByVal WindowHandle As IntPtr) As Image

        Dim windowRect As New User32.RECT()
        User32.GetWindowRect(WindowHandle, windowRect)
        Dim width As Integer = windowRect.right - windowRect.left + 1
        Dim height As Integer = windowRect.bottom - windowRect.top + 1

        User32.SetWindowPos(WindowHandle, CType(User32.HWND_TOPMOST, System.IntPtr), 0, 0, 0, 0, _
         User32.SWP_NOMOVE Or User32.SWP_NOSIZE Or User32.SWP_FRAMECHANGED)

        Dim hdcSrc As IntPtr = User32.GetWindowDC(WindowHandle)
        Dim hdcDest As IntPtr = GDI32.CreateCompatibleDC(hdcSrc)

        Dim hBitmap As IntPtr = GDI32.CreateCompatibleBitmap(hdcSrc, width, height)

        Dim hOld As IntPtr = GDI32.SelectObject(hdcDest, hBitmap)

        GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, _
         0, 0, GDI32.SRCCOPY)

        User32.SetWindowPos(WindowHandle, CType(User32.HWND_NOTOPMOST, System.IntPtr), 0, 0, 0, 0, _
         User32.SWP_NOMOVE Or User32.SWP_NOSIZE Or User32.SWP_FRAMECHANGED)

        GDI32.SelectObject(hdcDest, hOld)
        GDI32.DeleteDC(hdcDest)
        User32.ReleaseDC(WindowHandle, hdcSrc)
        Dim img As Image = Image.FromHbitmap(hBitmap)
        GDI32.DeleteObject(hBitmap)
        Return img
    End Function
    Private Class User32

        Public Const SWP_FRAMECHANGED As Integer = &H20
        Public Const SWP_NOMOVE As Integer = &H2
        Public Const SWP_NOSIZE As Integer = &H1
        Public Const SWP_NOZORDER As Integer = &H4
        Public Const HWND_TOPMOST As Integer = -1
        Public Const HWND_NOTOPMOST As Integer = -2

         _
        Public Structure RECT
            Public left As Integer
            Public top As Integer
            Public right As Integer
            Public bottom As Integer
        End Structure

         _
        Public Shared Function GetWindowDC(ByVal hWnd As IntPtr) As IntPtr
        End Function

         _
        Public Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As IntPtr
        End Function

         _
        Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef rect As RECT) As IntPtr
        End Function

         _
        Public Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, _
         ByVal uFlags As UInteger) As  Boolean
        End Function
    End Class
    Private Class GDI32

        Public Const SRCCOPY As Integer = &HCC0020

         _
        Public Shared Function BitBlt(ByVal hObject As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hObjectSource As IntPtr, _
         ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As Integer) As Boolean
        End Function

         _
        Public Shared Function CreateCompatibleBitmap(ByVal hDC As IntPtr, ByVal nWidth As Integer, ByVal nHeight As Integer) As IntPtr
        End Function

         _
        Public Shared Function CreateCompatibleDC(ByVal hDC As IntPtr) As IntPtr
        End Function

         _
        Public Shared Function DeleteDC(ByVal hDC As IntPtr) As Boolean
        End Function

         _
        Public Shared Function DeleteObject(ByVal hObject As IntPtr) As Boolean
        End Function

         _
        Public Shared Function SelectObject(ByVal hDC As IntPtr, ByVal hObject As IntPtr) As IntPtr
        End Function
    End Class
End Class

среда, 20 марта 2013 г.

Listbox Tutorial


[Save , Load , Search , Clear]


Public Class Form1

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add(TextBox1.Text)
    End Sub 'Add

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim ofd As New SaveFileDialog
        With ofd
            .FileName = "*.txt"
            .Title = "Choose a dir..."
            .Filter = "TxtFile(*.txt)|*.txt"
            .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                Try
                    Dim w As New IO.StreamWriter(.FileName)
                    For i = 0 To ListBox1.Items.Count - 1
                        w.WriteLine(ListBox1.Items.Item(i))
                    Next
                    w.Close()
                Catch ex As Exception
                    MsgBox(ex.ToString)
                End Try
            End If
        End With
    End Sub 'Save

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox1.Items.Clear()
    End Sub 'Clear

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        For i As Integer = 0 To ListBox1.Items.Count - 1
            If ListBox1.Items(i).ToString().Contains(TextBox1.Text) Then
                ListBox1.SetSelected(i, True)
            Else
                ListBox1.SelectedItems.Clear()
            End If
        Next
    End Sub 'Search
End Class


среда, 23 января 2013 г.

Adf.ly bot






Source Code [v 0.1]

Imports Microsoft.Win32
Public Class Form1
    Dim proxy As New wvp
    Dim one As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = False
        helpfunction()
    End Sub
    Sub setproxy()
        If Form2.ListBox1.Items.Count = 0 Then
            If MsgBox(" No proxy countine?", vbYesNo, "") = vbYes Then
                navigate()
            Else
                Button1.Enabled = True
                Return
            End If
        Else
            Try
                If one = Nothing Then
                    Form2.ListBox1.SelectedIndex = 0
                    one = "FUCK !"
                End If
                    Dim items As String = Form2.ListBox1.SelectedItem.ToString
                    Dim ip As String = items.Split(":"c).First
                    Dim port As String = items.Split(":"c).Last
                    Form2.ListBox1.SelectedIndex += 1
                    proxy.SetProxy(ip.ToString, Convert.ToInt16(port.ToString))
                    TextBox4.Text = "Wait for loading proxy..."
                    WaitCounter.Start()
                    Delay(20)
                    navigate()
            Catch ex As Exception
                If MsgBox("Bad proxy. Countine with out it?" + vbNewLine + " [" + ex.ToString + "]", vbYesNo, "") = vbYes Then
                    navigate()
                Else
                    Return
                End If
            End Try
        End If
    End Sub
    Private Function helpfunction()
        setproxy()
    End Function
    Private Function navigate()
        If TextBox1.Text = Nothing Then
            MsgBox("No Link", vbOKOnly, "")
            Button1.Enabled = True

        Else
            WebBrowser1.Navigate(TextBox1.Text)
            TextBox4.Text = "Navigating borwser..."
            WaitCounter.Start()
            Delay(20)
            Try
                WebBrowser1.Document.GetElementById("skip_button").InvokeMember("click")
                TextBox3.Text = TextBox3.Text + 1
                TextBox4.Text = "Skip Button clicked !"
                Delay(10)
                setproxy()
            Catch ex As Exception
                TextBox4.Text = "Excaption!" & ex.ToString
                TextBox5.Text = +1
                Delay(10)
                setproxy()
            End Try
        End If
    End Function
    Private Sub Wait_tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WaitCounter.Tick
        TextBox2.Text = TextBox2.Text + 1

        TextBox1.Enabled = False
        Button1.Enabled = False

        Button3.Enabled = False
        Button4.Enabled = False
        Button5.Enabled = False
        If TextBox2.Text > 30 Then
            WaitCounter.Stop()

            TextBox1.Enabled = True
            Button1.Enabled = True
            Button3.Enabled = True
            Button4.Enabled = True
            Button5.Enabled = True
            TextBox2.Text = 0
        End If
    End Sub
    ' -------> ------> ------> ' Not used functions !
    Sub Delay(ByVal dblSecs As Double)
        Const OneSec As Double = 1.0# / (1440.0# * 60.0#)
        Dim dblWaitTil As Date
        Now.AddSeconds(OneSec)
        dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)
        Do Until Now > dblWaitTil
            Application.DoEvents() ' Allow windows messages to be processed
        Loop
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Form2.Show()
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        WaitCounter.Start()
        Delay(20)
        proxy.DisableProxy()
        WebBrowser1.Navigate("http://www.ipaddrs.com/")
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL inetcpl.cpl")
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Application.Restart()
    End Sub
End Class
REM x M4TPAC 
Public Class wvp
    Sub DisableProxy()
        Dim regKey As RegistryKey
        Try
            regKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", RegistryKeyPermissionCheck.ReadWriteSubTree)
            regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)
            regKey.Close()

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
    Public Sub SetProxy(ByVal ServerName As String, ByVal port As Integer)
        Dim regkey1 As RegistryKey
        regkey1 = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", RegistryKeyPermissionCheck.ReadWriteSubTree)
        regkey1.SetValue("ProxyServer", ServerName + ":" + port.ToString(), RegistryValueKind.Unknown)
        regkey1.SetValue("ProxyEnable", RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryValueKind.DWord)
        regkey1.Close()
    End Sub
End Class

Download Project !