Guest User

tab closer vb.et MatriX Coder

a guest
Sep 29th, 2013
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.35 KB | None | 0 0
  1. 'thanks to simon benyo for coding this
  2. Imports System.Runtime.InteropServices
  3. Public Module SiteBlocker
  4.     <DllImport("user32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Unicode, EntryPoint:="keybd_event", ExactSpelling:=True, SetLastError:=True)> _
  5.     Public Function keybd_event(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32) As Boolean
  6.     End Function
  7.     <DllImport("PSAPI")> _
  8.     Private Function EmptyWorkingSet(ByVal hProc As IntPtr) As IntPtr
  9.     End Function
  10.     Sub Block(ByVal sSite As String)
  11.         Dim i As New Threading.Thread(AddressOf TS)
  12.         i.Start(sSite)
  13.     End Sub
  14.     Sub TS(ByVal str As String)
  15.         Do
  16.             For Each x As Process In Process.GetProcessesByName("chrome")
  17.                 If LCase(x.MainWindowTitle).Contains(str) Then
  18.                     Dim Control As Byte = &H11
  19.                     Dim KEYUP As Byte = &H2
  20.                     keybd_event(Control, 0, 0, 0)
  21.                     keybd_event(Keys.W, 0, 0, 0)
  22.                     keybd_event(Control, 0, KEYUP, 0)
  23.                     keybd_event(Keys.W, 0, KEYUP, 0)
  24.                 End If
  25.             Next
  26.             EmptyWorkingSet(-1) 'We Must Clean After What We Done its rude to let the place dirty
  27.             Threading.Thread.Sleep(400)
  28.         Loop
  29.     End Sub
  30. End Module
Advertisement
Add Comment
Please, Sign In to add comment