Jump to content
Sign in to follow this  
Crome_BAD

IEBlocker Finally!

Recommended Posts

Ok, after alot of testing, and very, messy code. Its Done!

#include <GUIConstants.au3>

Global $a = 0
Global $b = 0
Global $c

$INIValue = IniRead(@ScriptDir & "\Version.ini", "Version", "Version", "")


;Registry Settings
;=================
$RKey = RegRead("HKEY_CURRENT_USER\Software\IEBlocker", "MainDir")
$Version = RegRead("HKEY_CURRENT_USER\Software\IEBlocker", "Version")
$Blocked = RegRead("HKEY_CURRENT_USER\Software\IEBlocker", "BlockedPages")

SplashImageOn("", @ScriptDir & "\Skins\Startup\startup.jpg", 250, 100, -1, -1, 1)

Update($Version)

If $RKey = "" Then
   RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "", "REG_SZ", "")
   RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "MainDir", "REG_SZ", @ScriptDir)
EndIf

If $Version = "" Then
   RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "Version", "REG_SZ", $INIValue)
EndIf

If $Blocked = "" Then
   RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "BlockedPages", "REG_SZ", "0")
EndIf
;=======================================================================

Opt("WinTitleMatchMode", 2)

$MainGUI = GUICreate("IE Blocker " & $Version, 400, 100)

;Background Picture
;==================
GUICtrlCreatePic(@ScriptDir & "\Skins\b1.jpg", 0, 0, 400, 100, $GUI_DISABLE)

;IE Buttons
;==========
$BlockIE = GUICtrlCreateButton("Block IE Pages", 5, 5, 100, 20)
$StopBlock = GUICtrlCreateButton("Stop Block", 5, 25, 100, 20, $WS_DISABLED)

$Exit = GUICtrlCreateButton("Exit", 5, 45, 100, 20)

;PC Time
;========
$TimeInput = GUICtrlCreateInput("", 220, 5, 170, 20, $WS_DISABLED)

;Webpages Blocked Input
;======================
$WebBlock = GUICtrlCreateInput("0 Webpage(s) Blocked", 240, 45, 150, 20, $WS_DISABLED)

;Previously Blocked Pages
;========================
GUICtrlCreateInput("Blocked Last Run: " & $Blocked, 240, 70, 150, 20, $WS_DISABLED)

;Update Button
;=============
$UpdateB = GUICtrlCreateButton("Update", 5, 75, 100, 20)

GUISetState()

Sleep(1500)

SplashOff()

While 1
   
   $msg = GUIGetMsg()
   
   If $msg = $Exit Then
      RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "BlockedPages", "REG_SZ", $a)
      Exit
   EndIf
   
   If $msg = $BlockIE Then
      GUICtrlSetState($BlockIE, $GUI_DISABLE)
      GUICtrlSetState($StopBlock, $GUI_ENABLE)
      GUICtrlSetState($Exit, $GUI_DISABLE)
      $b = 1
   EndIf
   
   If $b = 1 Then
      If WinExists(" - Microsoft Internet Explorer") Then
         WinClose(" - Microsoft Internet Explorer")
         $a = $a + 1
         GUICtrlSetData($WebBlock, $a & " Webpage(s) Blocked")
      EndIf
   EndIf
         
   If $msg = $StopBlock Then
      GUICtrlSetState($BlockIE, $GUI_ENABLE)
      GUICtrlSetState($StopBlock, $GUI_DISABLE)
      GUICtrlSetState($Exit, $GUI_ENABLE)
      $b = 0
   EndIf
   
   If $msg = $UpdateB Then
      $c = 1
      Update($Version)
   EndIf
   
   Call("Time")
   
WEnd

Func Time()
   
   $Hour = @HOUR
   $Min = @MIN
   $Sec = @SEC
   
  ;AM Or PM Check
  ;==============
   If $Hour = "12" And $Min = "00" And $Sec = "01" Or $Hour > "12" Then
      $NorD = "PM"
   Else
      $NorD = "AM"
   EndIf
   
   If $Hour > "12" Then
      $Hour = $Hour - 12
   EndIf
   
  ;GUI Update
  ;==========
   GUICtrlSetData($TimeInput, "Current PC Time: " & $Hour & ":" & $Min & ":" & $Sec & "  " & $NorD)
EndFunc

Func Update($Version)
   
   $IEVer = InetGet("http://www.autoitscript.com/fileman/users/public/Crome_BAD/IE%20Blocker/version.ini", @ScriptDir & "version.ini")
   
   $Read = IniRead(@ScriptDir & "\version.ini", "Version", "Version", "")
   If $Version < $Read Then
      $Msg = MsgBox(49, "New Update!", "Would You Like To Download Update?")
      If $Msg = 1 Then
         InetGet("http://www.autoitscript.com/fileman/users/public/Crome_BAD/IE%20Blocker/ieblocker.exe", @ScriptDir & "Temp\IEBlock.exe")
         $b = 1
      EndIf
   EndIf
   
   If $b = 1 Then
      RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "Version", "REG_SZ", $Read)
      FileCopy(@ScriptDir & "\Temp\IEBlock.exe", @ScriptDir & "IEBlocker.exe")
      FileDelete(@ScriptDir & "\Temp")
      Exit
   EndIf
   
   If $c = 1 Then
      MsgBox(48, "No New Updates", "No New Updates At This Time")
   EndIf
   
EndFunc

The WHOLE File AND Backgrounds:

http://www.autoitscript.com/fileman/users/public/Crome_BAD/IE%20Blocker/ieblocker.zip

Also, Somemore commands people would like, or functionality, would be appreciated!

Crome

Edited by Crome_BAD

Share this post


Link to post
Share on other sites

;Time Conversions
 ;================
   If $Hour = "00" Then
      $Hour = "12"
   EndIf
  
   If $Hour = "13" Then
      $Hour = "01"
   EndIf
  
   If $Hour = "14" Then
      $Hour = "02"
   EndIf
  
   If $Hour = "15" Then
      $Hour = "03"
   EndIf
  
   If $Hour = "16" Then
      $Hour = "04"
   EndIf
  
   If $Hour = "17" Then
      $Hour = "05"
   EndIf
  
   If $Hour = "18" Then
      $Hour = "06"
   EndIf
  
   If $Hour = "19" Then
      $Hour = "07"
   EndIf
  
   If $Hour = "20" Then
      $Hour = "08"
   EndIf
  
   If $Hour = "21" Then
      $Hour = "09"
   EndIf
  
   If $Hour = "22" Then
      $Hour = "10"
   EndIf
  
   If $Hour = "23" Then
      $Hour = "11"
   EndIf
  
   If $Hour = "24" Then
      $Hour = "12"
   EndIf

C'mon, you gotta be able to find the pattern in that :lmao:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

Func Loop1($BlockIE, $StopBlock, $TimeInput, $WebBlock, $Exit)
  
   GUICtrlSetData($WebBlock, "0 Webpage(s) Blocked")
  
While 1
  
   $msg = GUIGetMsg()
  
   If $msg = -3 Or $msg = $Exit Then
      $Previous = RegRead("HKEY_CURRENT_USER\Software\IEBlocker", "BlockedPages")
      RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "BlockedPages", "REG_SZ", ($Previous + $a))
      Exit
   EndIf
  
   If $msg = $BlockIE Then
      GUICtrlSetState($BlockIE, $GUI_DISABLE)
      GUICtrlSetState($StopBlock, $GUI_ENABLE)
      GUICtrlSetState($Exit, $GUI_DISABLE)
      Loop2($BlockIE, $StopBlock, $TimeInput, $WebBlock, $Exit)
   EndIf
  
   Call("Time")
   Sleep(10)
  
WEnd
EndFunc

Func Loop2($BlockIE, $StopBlock, $TimeInput, $WebBlock, $Exit)

$a = 0

While 1
  
   $msg = GUIGetMsg()
  
   If $msg = $StopBlock Then
      GUICtrlSetState($BlockIE, $GUI_ENABLE)
      GUICtrlSetState($StopBlock, $GUI_DISABLE)
      GUICtrlSetState($Exit, $GUI_ENABLE)
      Global $a = $a
      Loop1($BlockIE, $StopBlock, $TimeInput, $WebBlock, $Exit)
   EndIf
  
   If WinExists(" - Microsoft Internet Explorer") Then
      WinClose(" - Microsoft Internet Explorer")
      $a = $a + 1
      GUICtrlSetData($WebBlock, $a & " Webpage(s) Blocked")
   EndIf
  
   Call("Time")
   Sleep(10)
  
WEnd
EndFunc

That's even funnier... I really hope you fix that :lmao:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

;Registry Settings
;=================
$RKey = RegRead("HKEY_CURRENT_USER\Software\IEBlocker", "MainDir")
$Version = RegRead("HKEY_CURRENT_USER\Software\IEBlocker", "Version")
$Blocked = RegRead("HKEY_CURRENT_USER\Software\IEBlocker", "BlockedPages")

If $RKey = "" Then
   RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "", "REG_SZ", "")
   RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "MainDir", "REG_SZ", @ScriptDir)
EndIf

If $Version = "" Then
   RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "Version", "REG_SZ", "v.03")
EndIf

If $Blocked = "" Then
   RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "BlockedPages", "REG_SZ", "0")
EndIf
;=======================================================================

Opt("WinTitleMatchMode", 2)

$MainGUI = GUICreate("IE Blocker " & $Version, 400, 100)

;Background Picture
;==================
GUICtrlCreatePic(@ScriptDir & "\Skins\b1.jpg", 0, 0, 400, 100, $GUI_DISABLE)

;IE Buttons
;==========
$BlockIE = GUICtrlCreateButton("Block IE Pages", 5, 5, 100, 20)
$StopBlock = GUICtrlCreateButton("Stop Block", 5, 25, 100, 20, $WS_DISABLED)

$Exit = GUICtrlCreateButton("Exit", 5, 45, 100, 20)

;PC Time
;========
$TimeInput = GUICtrlCreateInput("", 220, 5, 170, 20, $WS_DISABLED)

;Webpages Blocked Input
;======================
$WebBlock = GUICtrlCreateInput("0 Webpage(s) Blocked", 240, 45, 150, 20, $WS_DISABLED)

;Previously Blocked Pages
;========================
GUICtrlCreateInput("Blocked Last Run: " & $Blocked, 240, 70, 150, 20, $WS_DISABLED)

GUISetState()

While 1
   
   $msg = GUIGetMsg()
   
   If $msg = $Exit Then
      RegWrite("HKEY_CURRENT_USER\Software\IEBlocker", "BlockedPages", "REG_SZ", $a)
      Exit
   EndIf
   
   If $msg = $BlockIE Then
      GUICtrlSetState($BlockIE, $GUI_DISABLE)
      GUICtrlSetState($StopBlock, $GUI_ENABLE)
      GUICtrlSetState($Exit, $GUI_DISABLE)
      Do
         
         $msg = GUIGetMsg()
         
         If WinExists(" - Microsoft Internet Explorer") Then
            WinClose(" - Microsoft Internet Explorer")
            $a = $a + 1
            GUICtrlSetData($WebBlock, $a & " Webpage(s) Blocked")
         EndIf
         
         If $msg = $StopBlock Then
            GUICtrlSetState($BlockIE, $GUI_ENABLE)
            GUICtrlSetState($StopBlock, $GUI_DISABLE)
            GUICtrlSetState($Exit, $GUI_ENABLE)
            ExitLoop
         EndIf
         
         Call("Time")
         Sleep(10)
      Until 1 = 2
   EndIf
   
   Call("Time")
   
WEnd

Func Time()
   
   $Hour = @HOUR
   $Min = @MIN
   $Sec = @SEC
   
  ;AM Or PM Check
  ;==============
   If $Hour = "12" And $Min = "00" And $Sec = "01" Or $Hour > "12" Then
      $NorD = "PM"
   Else
      $NorD = "AM"
   EndIf
   
   If $Hour > "12" Then
      $Hour = $Hour - 12
   EndIf
   
  ;GUI Update
  ;==========
   GUICtrlSetData($TimeInput, "Current PC Time: " & $Hour & ":" & $Min & ":" & $Sec & "  " & $NorD)
EndFunc

Alittle Better?

Share this post


Link to post
Share on other sites

Tons better

But why do you go from a While loop to a Do loop? I think that looks tacky, but it's your script... :lmao:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

ADDED:

- Updater

- Made Coder ALITTLE More Sexxier

- Splash Startup

- Added Default Skin

More To Come

Crome

Also, More Suggestions welcome...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...