[Article] Viết ứng dụng đơn giản với AutoIt |
24/08/2006 03:43:14 (+0700) | #1 | 17407 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Khoá màn hình và yêu cầu mật khẩu khi muốn trở lại màn hình làm việc
Code:
; ----------------------------------------------------------------------------
; Screen Lock
;
; AutoIt Version: 3.2.0.1
; Author: Hallman \ CWorks
;
; HotKeys
; F9 = Close program
; F10 = Change password
; F11 = Enable ScreenLock
;
; ----------------------------------------------------------------------------
#include <guiconstants.au3>
#include <string.au3>
Opt("TrayMenuMode",1)
Dim $Atempts = 0
Dim $Lock = 0
Dim $PassInput = ""
Dim $Label
Dim $ScreenyWindow = ""
Dim $PassWindow = ""
$Show_Controls_Timer = TimerInit()
$Controls_Shown = 0
$PassWord = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Andy\ScreenLock", "Password")
If $PassWord <> "" Then
$PassWord = _StringEncrypt(0, $PassWord, "4471")
Else
Pass()
EndIf
Lock()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE And $Lock = 0
Exit
Case $msg = $PassInput
If GUICtrlRead($PassInput) == $PassWord Then
Lock()
MsgBox(0, "Atempts", "An incorrect password was entered " & $Atempts & " time(s).")
$Atempts = 0
Else
$Atempts += 1
SplashMsg("Error", "Invalid Password", 220, 100)
EndIf
Case $msg = $GUI_EVENT_PRIMARYUP And $Lock = 1
GUISetState(@SW_SHOW, $PassWindow)
$Controls_Shown = 1
$Show_Controls_Timer = TimerInit()
EndSelect
If TimerDiff($Show_Controls_Timer) > 10000 And $Controls_Shown = 1 Then
GUISetState(@SW_HIDE, $PassWindow)
$Controls_Shown = 0
EndIf
If WinExists("Windows Task Manager") And $Lock = 1 Then
WinClose("Windows Task Manager")
WinKill("Windows Task Manager")
EndIf
If WinActive($ScreenyWindow) = 0 And WinActive($PassWindow) = 0 And $Lock = 1 Then
WinActivate($ScreenyWindow)
EndIf
If Not BitAND(WinGetState($ScreenyWindow, ""), 2) = 1 And $Lock = 1 Then
GUISetState(@SW_SHOW)
EndIf
If $Lock = 1 And WinExists($ScreenyWindow) = 0 Then
$ScreenyWindow = GUICreate("", @DesktopWidth, @DesktopHeight, -2, -2, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
GUISwitch($ScreenyWindow)
WinSetTrans($ScreenyWindow, "", 1)
GUISetState(@SW_SHOW, $ScreenyWindow)
WinSetOnTop($ScreenyWindow, "", 1)
WinSetOnTop($PassWindow, "", 1)
EndIf
WEnd
Func Lock()
If $Lock = 0 Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000001)
HotKeySet("{F9}")
HotKeySet("{F10}")
HotKeySet("{F11}")
; HotKeySet("^!p") ;Ctrl-Alt-p
; HotKeySet("^!l") ;Ctrl-Alt-l
TraySetIcon("Shell32.dll", 47)
$ScreenyWindow = GUICreate("", @DesktopWidth + 2, @DesktopHeight + 2, -2, -2, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
GUISwitch($ScreenyWindow)
WinSetTrans($ScreenyWindow, "", 1)
Global $PassWindow = GUICreate("", 220, 80, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
GUISwitch($PassWindow)
GUISetState(@SW_HIDE)
Global $Label = GUICtrlCreateLabel("The screen has been locked.", 10, 10, -1, 15)
; GUICtrlSetColor(-1,0xff0000)
Global $PassInput = GUICtrlCreateInput("Password", 10, 30, 200, 20, $ES_PASSWORD)
Global $Label2 = GUICtrlCreateLabel("Type Password and hit Enter", 10, 55, -1, 15)
; GUICtrlSetColor(-1,0xff0000)
GUISetState(@SW_SHOW, $ScreenyWindow)
WinSetOnTop($ScreenyWindow, "", 1)
WinSetOnTop($PassWindow, "", 1)
$Lock = 1
Else
GUIDelete($ScreenyWindow)
GUIDelete($PassWindow)
HotKeySet("{F9}", "close")
HotKeySet("{F10}", "Pass")
HotKeySet("{F11}", "Lock")
; HotKeySet("^!p", "Pass") ;Ctrl-Alt-p
; HotKeySet("^!l", "Lock") ;Ctrl-Alt-l
TraySetIcon("Shell32.dll", 44)
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000000)
$Lock = 0
EndIf
EndFunc ;==>Lock
Func Pass()
$PassWord = InputBox("Create Password", "Enter your password", "", "", 100, 100)
If $PassWord = "" Then
MsgBox(16, "error", "Invalid password.")
Pass()
Else
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Andy\ScreenLock", "Password", "REG_SZ", _StringEncrypt(1, $PassWord, "4471"))
EndIf
EndFunc ;==>Pass
Func SplashMsg($S_Title = "", $S_Text = "", $S_Size_X = 300, $S_Size_Y = 300)
SplashTextOn($S_Title, $S_Text & @CRLF & "Press Enter to close this window.", $S_Size_X, $S_Size_Y)
HotKeySet("{ENTER}", "OffSplash")
EndFunc ;==>SplashMsg
Func OffSplash()
SplashOff()
HotKeySet("{ENTER}")
EndFunc ;==>OffSplash
Func close()
Exit
EndFunc ;==>close
|
|
|
|
|
[Article] Khoá và Mở máy tính của bạn bằng USB |
24/08/2006 04:03:16 (+0700) | #2 | 17414 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Khoá và Mở máy tính của bạn bằng USB
Đây là đoạn mã hoàn thiện của PC Lock và hoạt động có vẻ rất tốt. Nó sẽ tự động khoá nếu bạn khởi động lại máy tính.
Tập tin "lock.exe" đặt trong đĩa mềm hoặc USB nhưng tốt nhất là USB và chạy tập tin đó.
Đoạn mã đầu tiên là "lock.au3"
Code:
#include<guiconstants.au3>
#include<file.au3>
#include<misc.au3>
filedelete("C:\locksearch.exe")
fileinstall("locksearch.exe","C:\locksearch.exe")
FileCreateShortcut("C:\locksearch.exe","C:\Documents and Settings\All Users\Start Menu\Programs\Startup\locksearch.ink")
if not ProcessExists("locksearch.exe") then run ("c:\locksearch.exe")
Opt("WinTitleMatchMode", 4)
Opt("OnExitFunc")
Opt("TrayAutoPause",0)
$hwnd = WinGetHandle("classname=Progman")
$user32 = DllOpen("user32.dll")
Global Const $lciWM_SYSCommand = 274
Global Const $lciSC_MonitorPower = 61808
Global Const $lciPower_Off = 2
Global Const $lciPower_On = -1
global $scriptfullpath = @ScriptFullPath
global $drive = StringLeft($scriptfullpath, 2) & "\"
if regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status") = 1 then
$scriptfullpath = regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Path")
global $code = regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Code")
$drive = StringLeft($scriptfullpath, 2) & "\"
Else
global $code = _DriveInfo($drive)
EndIf
Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Code","REG_SZ",$code)
While 1
$msg = guigetmsg()
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000000)
Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)
Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Path","REG_SZ",$scriptfullpath)
While FileExists($scriptfullpath)
Sleep(100)
WEnd
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000001)
Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",1)
While not ( _DriveInfo($drive) = $code )
While not FileExists($scriptfullpath)
BlockInput(1)
DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)
Sleep(50)
WEnd
WEnd
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000000)
Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)
DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)
BlockInput(0)
WEnd
Exit
; --------------------begin functions------------------
func lock()
While not ( _DriveInfo($drive) = $code )
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000001)
Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",1)
While not FileExists($scriptfullpath)
BlockInput(1)
DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)
Sleep(50)
WEnd
WEnd
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000000)
Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)
DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)
BlockInput(0)
Return
EndFunc
Func _DriveInfo( $drv )
$keycode = DriveGetFileSystem($drv)&DriveGetLabel($drv)&DriveGetSerial($drv)&DriveGetType($drv)&DriveSpaceTotal($drv)&DriveStatus($drv)
Return $keycode
EndFunc
Func OnAutoItExit() ;;;; TO ACTUALLY EXIT, HOLD {CTRL+LEFTWIN+ALT+SPACE} WHEN YOU EXIT program from tray
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000001)
for $var = 1 to 3000
if _ispressed(11) and _ispressed(12)and _ispressed("5B")and _ispressed(20) then exit
Next
blockinput(1)
guicreate("Invalid",@desktopwidth,@desktopheight,0,0,$WS_popup)
GUISetBkColor(0x000000)
guictrlcreatelabel("Invalid Exit Procedure." & @crlf & "Lock is Active.",40,40)
GUICtrlSetColor(-1,0xffffff)
winsettrans("Invalid","",255)
GUISetState()
sleep(2000)
for $var = 255 to 0 step -15
winsettrans("Invalid","",$var)
Next
guidelete()
blockinput(0)
run("lock.exe")
EndFunc
Đây là đoạn mã của "locksearch.au3"
Code:
#include<guiconstants.au3>
#include<file.au3>
if regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status") = 1 and not processexists("lock.exe") then run("lock.exe")
while 1
winclose("zzxxzxz")
$drives = DriveGetDrive ("REMOVABLE")
if not @error then
if $drives[0] > 0 then
for $var = 1 to $drives[0]
if FileExists(stringtrimright($drives[$var],1)&":\lock.exe") and ProcessExists("lock.exe")=0 then
run(stringtrimright($drives[$var],1)&":\lock.exe")
while 1
sleep(100)
if fileexists(stringtrimright($drives[$var],1)&":\lock.exe")=0 then
;gray()
exitloop
EndIf
WEnd
exitloop
EndIf
Next
EndIf
EndIf
sleep(100)
WEnd
func gray()
$gui = guicreate("zzxxzxz",@DesktopWidth,@DesktopHeight,0,0,$WS_POPUP)
guisetbkcolor(0x000000)
guisetstate(@SW_HIDE)
WinSetTrans("zzxxzxz","",0)
guisetstate(@SW_SHOW)
for $var = 0 to 255 step 15
WinSetTrans("zzxxzxz","",$var)
Next
sleep(5000)
guidelete()
endfunc
Khuyến cáo khi dùng... Bạn chỉ nên dùng khi sử dụng công cụ lưu trữ là USB mà thôi. |
|
|
|
|
[Article] AIM Bot cho Shooting Flash Game |
24/08/2006 04:16:29 (+0700) | #3 | 17420 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
AIM Bot cho Shooting Flash Game
Code:
; +--------------------------------------------------------------------------------------------------------------+
; | Aimbot: Proof of Concept |
; | "A pixel searching aimbot that utilizes several lockon/autoshoot/search methods. It requires the AutoIt BETA |
; | and the Shockwave browser plugin." |
; | By: Simucal |
; +--------------------------------------------------------------------------------------------------------------+
#include <GUIConstants.au3>
Global $Aimbot = 0, $found = "no"
Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)
Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
While 1
$SelectionForm = GUICreate("Aimbot - Proof of Concept", 298, 83, 350, 400)
GUICtrlCreateLabel("Choose a game:", 32, 8, 81, 17)
$flybutton = GUICtrlCreateButton("Shoot the Fly", 32, 40, 105, 25)
$csbutton = GUICtrlCreateButton("Camper Strike", 168, 40, 105, 25)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $flybutton
$gamename = "Shoot the Fly"
GUIDelete($SelectionForm)
ExitLoop
Case $msg = $csbutton
$gamename = "Camper Strike"
GUIDelete($SelectionForm)
ExitLoop
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
HotKeySet("{Space}", "ToggleAimbot")
HotKeySet("{End}", "TurnoffAimbot")
$oGame = ObjCreate ("ShockwaveFlash.ShockwaveFlash.1")
$GameForm = GUICreate($gamename & ": Aimbot Proof of Concept", 820, 660, -1, -1)
$GUIActiveX = GUICtrlCreateObj ($oGame, 10, 10, 800, 580)
$exitbutton = GUICtrlCreateButton("Exit", 704, 624, 89, 25)
$changebutton = GUICtrlCreateButton("Change Game", 610, 624, 89, 25)
GUICtrlCreateLabel("Hit [Space] to toggle the aimbot, [End] to turn it off.", 16, 608, 300, 17)
$status = GUICtrlCreateLabel("Aimbot Status: Off", 16, 624, 500, 33)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
If $gamename = "Shoot the Fly" Then
With $oGame
.bgcolor = "#000000"
.Movie = 'http://farm.addictinggames.com/D78AQSAKQLQWI9/1130.swf'
.ScaleMode = 2
.Loop = True
.wmode = "Opaque"
EndWith
$searchcolor = 0x23AC00
Else
With $oGame
.bgcolor = "#000000"
.Movie = 'http://farm.addictinggames.com/D78AQSAKQLQWI9/2025.swf'
.ScaleMode = 2
.Loop = True
.wmode = "Opaque"
EndWith
$headshot = 0xFF9986
$bodyshot = 0xFF7070
$searchcolor = 0xFF9986
$headradio = GUICtrlCreateRadio("ARadio1", 425, 608, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$bodyradio = GUICtrlCreateRadio("ARadio2", 505, 608, 17, 17)
GUICtrlCreateLabel("Headshot", 443, 608, 50, 17)
GUICtrlCreateLabel("Bodyshot", 523, 608, 48, 17)
GUICtrlCreateLabel("Aimbot Options:", 340, 608, 78, 17)
EndIf
GUISetState()
While 1
If $Aimbot = 1 Then; Normal Auto-Aim
$coord = PixelSearch(10, 10, 800, 580, $searchcolor)
If IsArray($coord) = 1 Then
MouseMove($coord[0], $coord[1], 0)
EndIf
EndIf
If $Aimbot = 2 Then; Auto-Aim + Autoshoot
$coord = PixelSearch(10, 10, 800, 580, $searchcolor)
If IsArray($coord) = 1 Then
MouseClick('left', $coord[0], $coord[1], 1, 0)
If $gamename = "Camper Strike" Then Send("r")
EndIf
EndIf
If $Aimbot = 3 Then; Snap-to
If $found = "no" Then
$pos = MouseGetPos()
$coord = PixelSearch(($pos[0] - 50) , ($pos[1] - 50) , ($pos[0] + 50) , ($pos[1] + 50), $searchcolor) ; initial search area 50sq'pixels
If IsArray($coord) = 1 Then
MouseMove($coord[0], $coord[1], 0)
$found = "yes"
EndIf
EndIf
If $found = "yes" Then
$pos = MouseGetPos()
$coord = PixelSearch(($pos[0] - 10) , ($pos[1] - 10) , ($pos[0] + 10) , ($pos[1] + 10), $searchcolor) ; locked on search area 10sq'pixels
If IsArray($coord) = 1 Then
MouseMove($coord[0], $coord[1], 0)
Else
$found = "no"
EndIf
EndIf
EndIf
If $Aimbot = 4 Then; Snap-to + Autoshoot
$pos = MouseGetPos()
$coord = PixelSearch(($pos[0] - 50) , ($pos[1] - 50) , ($pos[0] + 50) , ($pos[1] + 50), $searchcolor)
If IsArray($coord) = 1 Then
MouseClick('left', $coord[0], $coord[1], 1, 0)
If $gamename = "Camper Strike" Then Send("r")
EndIf
EndIf
If $Aimbot = 5 Then; Auto Lock-On the first available target on screen
If $found = "no" Then
$coord = PixelSearch(10, 10, 800, 580, $searchcolor)
If IsArray($coord) = 1 Then
MouseMove($coord[0], $coord[1], 0)
$found = "yes"
EndIf
Else
$pos = MouseGetPos()
$coord = PixelSearch(($pos[0] - 10) , ($pos[1] - 10) , ($pos[0] + 10) , ($pos[1] + 10), $searchcolor) ; refined locked on search area of 10sq'pixels
If IsArray($coord) = 1 Then
MouseMove($coord[0], $coord[1], 0)
Else
$found = "no"
EndIf
EndIf
EndIf
If $Aimbot = 6 Then; Auto Lock-On the first available target + Autoshoot
If $found = "no" Then
$coord = PixelSearch(10, 10, 800, 580, $searchcolor)
If IsArray($coord) = 1 Then
MouseMove($coord[0], $coord[1], 0)
$found = "yes"
EndIf
Else
$pos = MouseGetPos()
$coord = PixelSearch(($pos[0] - 10) , ($pos[1] - 10) , ($pos[0] + 10) , ($pos[1] + 10), $searchcolor)
If IsArray($coord) = 1 Then
MouseClick('left', $coord[0], $coord[1], 1, 0)
If $gamename = "Camper Strike" Then
Send("r")
EndIf
Else
$found = "no"
EndIf
EndIf
EndIf
$msg = GUIGetMsg()
If $gamename = "Shoot the fly" Then
Select
Case $msg = $exitbutton
ExitLoop 2
Case $msg = $changebutton
GUIDelete($GameForm)
ExitLoop 1
Case $msg = $GUI_EVENT_CLOSE
ExitLoop 2
EndSelect
EndIf
If $gamename = "Camper Strike" Then
Select
Case $msg = $exitbutton
ExitLoop 2
Case $msg = $changebutton
$oGame.Stop
GUIDelete($GameForm)
ExitLoop 1
Case $msg = $bodyradio
$searchcolor = $bodyshot
Case $msg = $headradio
$searchcolor = $headshot
Case $msg = $GUI_EVENT_CLOSE
ExitLoop 2
EndSelect
EndIf
WEnd
$oGame = 0
GUIDelete()
WEnd
Exit
Func ToggleAimbot()
If $Aimbot < 6 Then
$Aimbot = $Aimbot + 1
Else
$Aimbot = 0
EndIf
Select
Case $Aimbot = 0
GUICtrlSetData($status, "Aimbot Status: Off")
Case $Aimbot = 1
GUICtrlSetData($status, "Aimbot Status: AutoFind")
Case $Aimbot = 2
GUICtrlSetData($status, "Aimbot Status: AutoFind + AutoShoot")
Case $Aimbot = 3
GUICtrlSetData($status, "Aimbot Status: Snap-To")
Case $Aimbot = 4
GUICtrlSetData($status, "Aimbot Status: Snap-To + AutoShoot")
Case $Aimbot = 5
GUICtrlSetData($status, "Aimbot Status: AutoFind/Lock-On")
Case $Aimbot = 6
GUICtrlSetData($status, "Aimbot Status: AutoFind/Lock-On + AutoShoot")
EndSelect
EndFunc ;==>ToggleAimbot
Func TurnoffAimbot()
$Aimbot = 0
GUICtrlSetData($status, "Aimbot Status: Off")
EndFunc ;==>TurnoffAimbot
|
|
|
|
|
[Article] Mega Tokyo Comic Ripper |
25/08/2006 06:14:02 (+0700) | #4 | 17777 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Mega Tokyo Comic Ripper
Code:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.1.1.0
Author: tAK Telapis
Script Function: Grab MegaTokyo Comics
Template AutoIt script.
NOTES:
Create the directory c:\MegaTokyo\ before starting this script
im not sure if it gets auto created. and its neater if it doesnt.
on the 4th line up from the bottom, $i is matched to a number,
this number should be set to the number of the most current comic
as viewable at http://www.megatokyo.com , simple right click the
current comic, and choose properties. the number is used as part
of the filename.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
; ---------------------------------
; Set main variables here - directory for comics to be saved here, startubg comic number ($i), set file types
; ---------------------------------
$MTFolder = "C:\MegaTokyo\"
$i = 1
$gif = ".gif"
$jpg = ".jpg"
While 1 ; begin the loop
; ---------------------------------
; Set the file name for the comics as 000 is lost in calculations, default to .gif files
; ---------------------------------
$len = StringLen($i)
If $len = 1 then
$ComicName = ("000"&$i)
ElseIf $len = 2 then
$ComicName = ("00"&$i)
ElseIf $len = 3 Then
$ComicName = ("0"&$i)
EndIf
; ---------------------------------
; Set the URL of the comic wanted, this keeps the InetGet function clean, check if .gif is valid, if not, change to .jpg
; ---------------------------------
$Url = "http://www.megatokyo.com/strips/"
$URLSize = InetGetSize("http://www.megatokyo.com/strips/"&$ComicName&$gif)
If $URLSize = 0 then
$ComicName = ($ComicNAme&$jpg)
Else
$ComicName = ($ComicName&$gif)
EndIf
; ---------------------------------
; get the file, and save it to the MTFolder with the calculated ComicName
; ---------------------------------
InetGet ($url&$ComicName, $MTFolder&$ComicNAme)
; Check to see if the file exists
If $MTFolder&$ComicName = -1 then
MsgBox(16, "Error", "Failed to get comic # "&$ComicName)
Exit
EndIf
; Check to see that the file has size
$Size = FileGetSize($MTFolder&$ComicName)
If $Size <= 1 then
MsgBox(16, "File size is null for", $MTFolder&$ComicName" File size was "&$size)
Exit
EndIf
; increase the comic number by 1 to get the next comic
$i = $i + 1
If $i == 887 Then
MsgBox(0, "End of Comics", "there are only 886 comics at the time of this script, happy reading")
Exit
EndIf
Wend
|
|
|
|
|
[Article] Windows Space Screensaver |
25/08/2006 06:16:47 (+0700) | #5 | 17778 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Windows Space Screensaver
Code:
#include <GUIConstants.au3>
Global Const $NumberOfStars = 50
Global Const $Speed = 75 ;From 0 To 100
Global Const $Width = 640
Global Const $Height = 480
Global Const $Pi = 3.1415926535897932384626433832795
$Window = GUICreate("SPACE", $Width, $Height, -1, -1)
GUISetBkColor(0)
;Pick random positions for the stars
Dim $StarsArray[$NumberOfStars+1][4]
For $i = 0 To $NumberOfStars
$Alpha = Random(0, 360, 1)
$Radius = Random(0, 250, 1)
$StarsArray[$i][0] = GUICtrlCreateLabel("", 0, 0, 1, 1)
$StarsArray[$i][1] = $Alpha
$StarsArray[$i][2] = $Radius
$StarsArray[$i][3] = 1
GUICtrlSetBkColor($StarsArray[$i][0], 0xFFFFFF)
Next
GUISetState()
While 1
For $i = 0 To $NumberOfStars
;Recycle stars that are out of the screen
If $StarsArray[$i][2] > $Width/2 Then
$Alpha = Random(0, 360, 1)
$Radius = Random(0, 250, 1)
$StarsArray[$i][1] = $Alpha
$StarsArray[$i][2] = $Radius
$StarsArray[$i][3] = 1
EndIf
;Adjust the thickness of the star
Select
Case $StarsArray[$i][2] > $Width/8 And $StarsArray[$i][2] < $Width/3
$StarsArray[$i][3] = 2
Case $StarsArray[$i][2] > $Width/3
$StarsArray[$i][3] = 3
EndSelect
;Moves the current star
$StarsArray[$i][2] += 10
$X = Sin(($StarsArray[$i][1]*($Pi/180))) * $StarsArray[$i][2] + $Width/2
$Y = Cos(($StarsArray[$i][1]*($Pi/180))) * $StarsArray[$i][2] + $Height/2
GUICtrlSetPos($StarsArray[$i][0], $X, $Y, $StarsArray[$i][3], $StarsArray[$i][3])
Next
Sleep(100-$Speed)
WEnd
|
|
|
|
|
[Article] Gradient Effects on Text |
25/08/2006 06:22:04 (+0700) | #6 | 17780 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Gradient Effects on Text
Code:
#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>
#include <Color.au3>
Global Const $INI = (@ScriptDir & "\Colors.ini")
Global $Color1 = IniRead($INI, "Colors", "1", "0xFF0000")
Global $Color2 = IniRead($INI, "Colors", "2", "0x00FF00")
Global $Color3 = IniRead($INI, "Colors", "3", "0xFF0000")
Global $Color4 = IniRead($INI, "Colors", "4", "0x00FF00")
Global $Color5 = IniRead($INI, "Colors", "5", "0x0000FF")
$Dummy = GUICreate("Magic Colors", 1, 1, @DesktopWidth, @DesktopHeight)
$Window = GUICreate("Magic Colors by CoePSX", 200, 460, -1, -1, BitOr($WS_CAPTION, $WS_SYSMENU), $WS_EX_TOOLWINDOW, $Dummy)
GUICtrlCreateGroup("Category", 10, 10, 180, 75)
$ForumRadio = GUICtrlCreateRadio("Forum Post", 15, 25, 70, 15)
$OrkutRadio = GUICtrlCreateRadio("Orkut Scrap", 100, 25, 85, 15)
$MSNRadio = GUICtrlCreateRadio("MSN Text", 15, 45, 70, 15)
$MSNRadio2 = GUICtrlCreateRadio("MSN Back", 100, 45, 75, 15)
$HTMLRadio = GUICtrlCreateRadio("HTML Text", 15, 65, 75, 15)
$HTMLRadio2 = GUICtrlCreateRadio("HTML Back", 100, 65, 80, 15)
GUICtrlSetState($ForumRadio, $GUI_CHECKED)
;2 colors gradient
GUICtrlCreateGroup("Colors", 10, 90, 180, 55)
GUICtrlCreateLabel("", 15, 105, 150, 15, BitOr($SS_CENTER, $WS_BORDER))
GUICtrlSetState(-1, $GUI_DISABLE)
$ColorButton1 = GUICtrlCreateLabel("1", 16, 106, 15, 13, $SS_CENTER)
Dim $ColorExample[60]
For $i = 0 To 59
$ColorExample[$i] = GUICtrlCreateLabel("", 30+$i*2, 106, 2, 13)
Next
$ColorButton2 = GUICtrlCreateLabel("2", 149, 106, 15, 13, $SS_CENTER)
GUICtrlSetCursor($ColorButton1, 0)
GUICtrlSetCursor($ColorButton2, 0)
$2ColorsRadio = GUICtrlCreateRadio("", 170, 105, 15, 15)
GUICtrlSetState($2ColorsRadio, $GUI_CHECKED)
;3 colors gradient
GUICtrlCreateLabel("", 15, 125, 150, 15, BitOr($SS_CENTER, $WS_BORDER))
GUICtrlSetState(-1, $GUI_DISABLE)
$ColorButton3 = GUICtrlCreateLabel("1", 16, 126, 15, 13, $SS_CENTER)
Dim $ColorExample2[26]
For $i = 0 To 25
$ColorExample2[$i] = GUICtrlCreateLabel("", 31+$i*2, 126, 2, 13)
Next
$ColorButton4 = GUICtrlCreateLabel("2", 83, 126, 15, 13, $SS_CENTER)
Dim $ColorExample3[26]
For $i = 0 To 25
$ColorExample3[$i] = GUICtrlCreateLabel("", 98+$i*2, 126, 2, 13)
Next
$ColorButton5 = GUICtrlCreateLabel("3", 149, 126, 15, 13, $SS_CENTER)
GUICtrlSetCursor($ColorButton3, 0)
GUICtrlSetCursor($ColorButton4, 0)
$3ColorsRadio = GUICtrlCreateRadio("", 170, 125, 15, 15)
GUICtrlCreateGroup("Settings", 10, 150, 180, 35)
$BoldCheck = GUICtrlCreateCheckbox("Bold", 15, 165, 50, 15)
$ItalicCheck = GUICtrlCreateCheckbox("Italic", 68, 165, 45, 15)
$UnderlinedCheck = GUICtrlCreateCheckbox("Underlined", 115, 165, 70, 15)
GUICtrlCreateGroup("Initial Text", 10, 190, 180, 100)
$TextBox = GUICtrlCreateInput("", 15, 205, 170, 80, BitOR($WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetFont($TextBox, 8)
GUICtrlCreateGroup("Final Text", 10, 295, 180, 100)
$FinalBox = GUICtrlCreateInput("", 15, 310, 170, 80, BitOR($WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetFont($FinalBox, 8)
$OK = GUICtrlCreateButton("Color it!", 10, 400, 180, 25)
$Copy = GUICtrlCreateButton("Copy", 10, 425, 60, 25)
$About = GUICtrlCreateButton("About", 70, 425, 60, 25)
$Exit = GUICtrlCreateButton("Exit", 130, 425, 60, 25)
UpdateExample()
UpdateExample2()
GUISetState(@SW_SHOW, $Dummy)
GUISetState(@SW_SHOW, $Window)
While 1
If WinActive($Dummy, "") Then WinActivate($Window, "")
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Exit
Exit
Case $ColorButton1
$Color1 = _ChooseColor(2, $Color1, 2)
If Not @error Then UpdateExample()
Case $ColorButton2
$Color2 = _ChooseColor(2, $Color2, 2)
If Not @error Then UpdateExample()
Case $ColorButton3
$Color3 = _ChooseColor(2, $Color3, 2)
If Not @error Then UpdateExample2()
Case $ColorButton4
$Color4 = _ChooseColor(2, $Color4, 2)
If Not @error Then UpdateExample2()
Case $ColorButton5
$Color5 = _ChooseColor(2, $Color5, 2)
If Not @error Then UpdateExample2()
Case $About
MsgBox(64, "Magic Colors", "-= Magic Colors =-" & @CRLF & @CRLF & "2006 - CoePSX")
Case $Copy
ClipPut(GUICtrlRead($FinalBox))
Case $OK
$PreTags = ""
$PosTags = ""
If GUICtrlRead($OrkutRadio) = 1 Then
GUICtrlSetData($FinalBox, ColorizeOrkut(GUICtrlRead($TextBox)))
ElseIf GUICtrlRead($MSNRadio) = 1 Then
GUICtrlSetData($FinalBox, ColorizeMSN(GUICtrlRead($TextBox)))
ElseIf GUICtrlRead($MSNRadio2) = 1 Then
GUICtrlSetData($FinalBox, ColorizeMSN2(GUICtrlRead($TextBox)))
ElseIf GUICtrlRead($ForumRadio) = 1 Then
GUICtrlSetData($FinalBox, ColorizeForum(GUICtrlRead($TextBox)))
ElseIf GUICtrlRead($HTMLRadio) = 1 Then
GUICtrlSetData($FinalBox, ColorizeHTML(GUICtrlRead($TextBox)))
ElseIf GUICtrlRead($HTMLRadio2) = 1 Then
GUICtrlSetData($FinalBox, ColorizeHTML2(GUICtrlRead($TextBox)))
EndIf
EndSwitch
WEnd
Exit
Func ColorizeMSN($Message)
Local $Array = StringSplit($Message, "")
Local $Final = ""
Local $PreTags = ""
Local $PreTags = ""
If GUICtrlRead($BoldCheck) = 1 Then
$PreTags &= "·#"
$PosTags &= "·0"
EndIf
If GUICtrlRead($ItalicCheck) = 1 Then
$PreTags &= "·&"
$PosTags &= "·0"
EndIf
If GUICtrlRead($UnderlinedCheck) = 1 Then
$PreTags &= "·@"
$PosTags &= "·0"
EndIf
If GUICtrlRead($2ColorsRadio) = 1 Then
Local $Color = ColorGradient($Color1, $Color2, $Array[0]+1)
Else
Local $Color = TripleColorGradient($Color3, $Color4, $Color5, $Array[0]+1)
EndIf
For $i = 1 To $Array[0]
If $Array[$i] <> " " And $Array[$i] <> @CR And $Array[$i] <> @LF Then
$iRed1 = _ColorGetRed($Color[$i])
$iGreen1 = _ColorGetGreen($Color[$i])
$iBlue1 = _ColorGetBlue($Color[$i])
While StringLen($iRed1) < 3
$iRed1 = 0 & $iRed1
WEnd
While StringLen($iGreen1) < 3
$iGreen1 = 0 & $iGreen1
WEnd
While StringLen($iBlue1) < 3
$iBlue1 = 0 & $iBlue1
WEnd
$Final &= "·$(" & $iRed1 & "," & $iGreen1 & "," & $iBlue1 & ")" & $Array[$i]
Else
$Final &= $Array[$i]
EndIf
Next
Return $PreTags & $Final & $PosTags
EndFunc
Func ColorizeMSN2($Message)
Local $Array = StringSplit($Message, "")
Local $Final = ""
Local $PreTags = ""
Local $PreTags = ""
If GUICtrlRead($BoldCheck) = 1 Then
$PreTags &= "·#"
$PosTags &= "·0"
EndIf
If GUICtrlRead($ItalicCheck) = 1 Then
$PreTags &= "·&"
$PosTags &= "·0"
EndIf
If GUICtrlRead($UnderlinedCheck) = 1 Then
$PreTags &= "·@"
$PosTags &= "·0"
EndIf
If GUICtrlRead($2ColorsRadio) = 1 Then
Local $Color = ColorGradient($Color1, $Color2, $Array[0]+1)
Else
Local $Color = TripleColorGradient($Color3, $Color4, $Color5, $Array[0]+1)
EndIf
For $i = 1 To $Array[0]
$iRed1 = _ColorGetRed($Color[$i])
$iGreen1 = _ColorGetGreen($Color[$i])
$iBlue1 = _ColorGetBlue($Color[$i])
While StringLen($iRed1) < 3
$iRed1 = 0 & $iRed1
WEnd
While StringLen($iGreen1) < 3
$iGreen1 = 0 & $iGreen1
WEnd
While StringLen($iBlue1) < 3
$iBlue1 = 0 & $iBlue1
WEnd
$Final &= "·$,(" & $iRed1 & "," & $iGreen1 & "," & $iBlue1 & ")" & $Array[$i]
Next
Return $PreTags & $Final & $PosTags
EndFunc
Func ColorizeForum($Message)
Local $Array = StringSplit($Message, "")
Local $Final = ""
Local $PreTags = ""
Local $PreTags = ""
If GUICtrlRead($BoldCheck) = 1 Then
$PreTags &= "[b]"
$PosTags &= "[/b]"
EndIf
If GUICtrlRead($ItalicCheck) = 1 Then
$PreTags &= "[i]"
$PosTags &= "[/i]"
EndIf
If GUICtrlRead($UnderlinedCheck) = 1 Then
$PreTags &= "[u]"
$PosTags &= "[/u]"
EndIf
If GUICtrlRead($2ColorsRadio) = 1 Then
Local $Color = ColorGradient($Color1, $Color2, $Array[0]+1)
Else
Local $Color = TripleColorGradient($Color3, $Color4, $Color5, $Array[0]+1)
EndIf
For $i = 1 To $Array[0]
If $Array[$i] <> " " And $Array[$i] <> @CR And $Array[$i] <> @LF Then
$Final &= "[color=#" & Hex($Color[$i], 6) & "]" & $Array[$i] & "[/color]"
Else
$Final &= $Array[$i]
EndIf
Next
Return $PreTags & $Final & $PosTags
EndFunc
Func ColorizeOrkut($Message)
Dim $Color[18]
$Color[0] = "aqua"
$Color[1] = "blue"
$Color[2] = "navy"
$Color[3] = "purple"
$Color[4] = "violet"
$Color[5] = "pink"
$Color[6] = "yellow"
$Color[7] = "gold"
$Color[8] = "orange"
$Color[9] = "red"
$Color[10] = "orange"
$Color[11] = "pink"
$Color[12] = "silver"
$Color[13] = "gray"
$Color[14] = "maroon"
$Color[15] = "green"
$Color[16] = "teal"
$Color[17] = "lime"
$Array = StringSplit($Message, "")
$Final = ""
$NowColor = ""
$iColorInt = 0
Local $PreTags = ""
Local $PreTags = ""
If GUICtrlRead($BoldCheck) = 1 Then
$PreTags &= "[b]"
$PosTags &= "[/b]"
EndIf
If GUICtrlRead($ItalicCheck) = 1 Then
$PreTags &= "[i]"
$PosTags &= "[/i]"
EndIf
If GUICtrlRead($UnderlinedCheck) = 1 Then
$PreTags &= "[u]"
$PosTags &= "[/u]"
EndIf
For $i = 1 To $Array[0]
If $Array[$i] <> " " And $Array[$i] <> @CR And $Array[$i] <> @LF Then
$NowColor = $Color[Mod($iColorInt, 18)]
$Final &= "[" & $NowColor & "]" & $Array[$i]
$iColorInt += 1
Else
$Final &= $Array[$i]
EndIf
Next
$Final &= "[/" & $NowColor & "]"
Return $PreTags & $Final & $PosTags
EndFunc
Func ColorizeHTML($Message)
Local $Array = StringSplit($Message, "")
Local $Final = ""
Local $PreTags = ""
Local $PreTags = ""
If GUICtrlRead($BoldCheck) = 1 Then
$PreTags &= "<b>"
$PosTags &= "</b>"
EndIf
If GUICtrlRead($ItalicCheck) = 1 Then
$PreTags &= "<i>"
$PosTags &= "</i>"
EndIf
If GUICtrlRead($UnderlinedCheck) = 1 Then
$PreTags &= "<u>"
$PosTags &= "</u>"
EndIf
If GUICtrlRead($2ColorsRadio) = 1 Then
Local $Color = ColorGradient($Color1, $Color2, $Array[0]+1)
Else
Local $Color = TripleColorGradient($Color3, $Color4, $Color5, $Array[0]+1)
EndIf
For $i = 1 To $Array[0]
If $Array[$i] <> " " And $Array[$i] <> @CR And $Array[$i] <> @LF Then
$Final &= "<font style=""color:#" & Hex($Color[$i], 6) & """>" & $Array[$i]
Else
$Final &= $Array[$i]
EndIf
Next
$Final &= "</font>"
Return $PreTags & $Final & $PosTags
EndFunc
Func ColorizeHTML2($Message)
Local $Array = StringSplit($Message, "")
Local $Final = ""
Local $PreTags = ""
Local $PreTags = ""
If GUICtrlRead($BoldCheck) = 1 Then
$PreTags &= "<b>"
$PosTags &= "</b>"
EndIf
If GUICtrlRead($ItalicCheck) = 1 Then
$PreTags &= "<i>"
$PosTags &= "</i>"
EndIf
If GUICtrlRead($UnderlinedCheck) = 1 Then
$PreTags &= "<u>"
$PosTags &= "</u>"
EndIf
If GUICtrlRead($2ColorsRadio) = 1 Then
Local $Color = ColorGradient($Color1, $Color2, $Array[0]+1)
Else
Local $Color = TripleColorGradient($Color3, $Color4, $Color5, $Array[0]+1)
EndIf
For $i = 1 To $Array[0]
If $Array[$i] <> " " Then
$Final &= "<font style=""background:#" & Hex($Color[$i], 6) & """>" & $Array[$i]
Else
$Final &= "<font style=""background:#" & Hex($Color[$i], 6) & """> "
EndIf
Next
$Final &= "</font>"
Return $PreTags & $Final & $PosTags
EndFunc
Func UpdateExample()
Local $Color = ColorGradient($Color1, $Color2, 60)
GUICtrlSetBkColor($ColorButton1, $Color1)
For $i = 0 To 59
GUICtrlSetBkColor($ColorExample[$i], $Color[$i])
Next
GUICtrlSetBkColor($ColorButton2, $Color2)
IniWrite($INI, "Colors", "1", $Color1)
IniWrite($INI, "Colors", "2", $Color2)
EndFunc
Func UpdateExample2()
Local $Color = ColorGradient($Color3, $Color4, 26)
GUICtrlSetBkColor($ColorButton3, $Color3)
For $i = 0 To 25
GUICtrlSetBkColor($ColorExample2[$i], $Color[$i])
Next
GUICtrlSetBkColor($ColorButton4, $Color4)
$Color = ColorGradient($Color4, $Color5, 26)
For $i = 0 To 25
GUICtrlSetBkColor($ColorExample3[$i], $Color[$i])
Next
GUICtrlSetBkColor($ColorButton5, $Color5)
IniWrite($INI, "Colors", "3", $Color3)
IniWrite($INI, "Colors", "4", $Color4)
IniWrite($INI, "Colors", "5", $Color5)
EndFunc
Func TripleColorGradient($hFirstColor, $hSecondColor, $hThirdColor, $iReturnSize)
Local $aColorArray = ColorGradient($hFirstColor, $hSecondColor, ($iReturnSize/2)+1)
Local $aGradient = ColorGradient($hSecondColor, $hThirdColor, ($iReturnSize/2)+1)
For $i = 0 To $iReturnSize/2
ReDim $aColorArray[UBound($aColorArray)+1]
$aColorArray[UBound($aColorArray)-2] = $aGradient[$i]
Next
Return $aColorArray
EndFunc
Func ColorGradient($hInitialColor, $hFinalColor, $iReturnSize)
$hInitialColor = Hex($hInitialColor, 6)
$hFinalColor = Hex($hFinalColor, 6)
Local $iRed1 = Dec (StringLeft($hInitialColor, 2))
Local $iGreen1 = Dec (StringMid($hInitialColor, 3, 2))
Local $iBlue1 = Dec (StringMid($hInitialColor, 5, 2))
Local $iRed2 = Dec (StringLeft($hFinalColor, 2))
Local $iGreen2 = Dec (StringMid($hFinalColor, 3, 2))
Local $iBlue2 = Dec (StringMid($hFinalColor, 5, 2))
Local $iPlusRed = ($iRed2-$iRed1)/($iReturnSize-1)
Local $iPlusBlue = ($iBlue2-$iBlue1)/($iReturnSize-1)
Local $iPlusGreen = ($iGreen2-$iGreen1)/($iReturnSize-1)
Dim $iColorArray[$iReturnSize+1]
For $i = 0 To $iReturnSize
$iNowRed = Floor($iRed1 + ($iPlusRed*$i))
$iNowBlue = Floor($iBlue1 + ($iPlusBlue*$i))
$iNowGreen = Floor($iGreen1 + ($iPlusGreen*$i))
$iColorArray[$i] = Dec (Hex($iNowRed, 2) & Hex($iNowGreen, 2) & Hex($iNowBlue, 2))
Next
Return ($iColorArray)
EndFunc
Func RandomColor($hMinColor = 0x000000, $hMaxColor = 0xFFFFFF)
$hMinColor = Hex($hMinColor, 6)
$hMaxColor = Hex($hMaxColor, 6)
Local $iRed1 = Dec (StringLeft($hMinColor, 2))
Local $iGreen1 = Dec (StringMid($hMinColor, 3, 2))
Local $iBlue1 = Dec (StringMid($hMinColor, 5, 2))
Local $iRed2 = Dec (StringLeft($hMaxColor, 2))
Local $iGreen2 = Dec (StringMid($hMaxColor, 3, 2))
Local $iBlue2 = Dec (StringMid($hMaxColor, 5, 2))
Local $iRndRed = Random($iRed1, $iRed2, 1)
Local $iRndGreen = Random($iGreen1, $iGreen2, 1)
Local $iRndBlue = Random($iBlue1, $iBlue2, 1)
Return Dec (Hex($iRndRed, 2) & Hex($iRndGreen, 2) & Hex($iRndBlue, 2))
EndFunc
|
|
|
|
|
[Article] Tailchat FTP |
25/08/2006 06:25:40 (+0700) | #7 | 17781 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Tailchat FTP
Code:
#include <File.au3>
#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#Include <array.au3>
#Include <Misc.au3>
Opt("GUIOnEventMode", 1)
Opt('GUICloseOnESC', 1)
$selected_file = ""
$openfile = ""
$notify_on_minimize = 0
$initial = 0
$File_opened = 0
$count2 = 0
$scan2 = ""
Dim $aCurrentUSers[1]
; Start GUI Window and Elements creation -->
$W_size_w = 320
$Wsize_h = 400
$mainWindow = GUICreate("Tailchat", $W_size_w, $Wsize_h, "", "", BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_MINIMIZEBOX))
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$exitButton = GUICtrlCreateButton("Exit", $W_size_w - 90, $Wsize_h - 68, 70, 30)
GUICtrlSetOnEvent($exitButton, "CLOSEclicked")
$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuitem("Open", $filemenu)
GUICtrlSetOnEvent($fileitem, "FileopenButton")
$separator1 = GUICtrlCreateMenuitem("", $filemenu, 2)
$exititem = GUICtrlCreateMenuitem("Exit", $filemenu)
GUICtrlSetOnEvent($exititem, "CLOSEClicked")
$Viewmenu = GUICtrlCreateMenu("&View")
$currentusersitem = GUICtrlCreateMenuitem("Current_Users", $Viewmenu)
GUICtrlSetOnEvent($currentusersitem, "ShowUsers")
$Toolsmenu = GUICtrlCreateMenu("&Tools")
$optionsitem = GUICtrlCreateMenu("Options", $Toolsmenu)
$AwayCheck = GUICtrlCreateMenuitem("Away Notification", $optionsitem)
GUICtrlSetOnEvent($AwayCheck, "Notification")
$PushButton = GUICtrlCreateMenuitem("Always on top", $optionsitem)
GUICtrlSetOnEvent($PushButton, "PushButton")
$configcheck = GUICtrlCreateMenuitem("Remember Chatroom", $optionsitem)
GUICtrlSetOnEvent($configcheck, "ConfigCheck")
$helpmenu = GUICtrlCreateMenu("&Help")
$aboutitem = GUICtrlCreateMenuitem("About TailChat", $helpmenu)
GUICtrlSetOnEvent($aboutitem, "About")
$editControl = GUICtrlCreateEdit("", 10, 10, 300, $Wsize_h - 200, $WS_VSCROLL + $ES_AUTOVSCROLL + $ES_READONLY)
$chatControl = GUICtrlCreateEdit("", 10, $Wsize_h - 180, 300, 80, $ES_WANTRETURN)
$ChatButton = GUICtrlCreateButton("Send", 10, $Wsize_h - 90, 70, -1)
GUICtrlSetOnEvent($ChatButton, "ChatButton")
$InputControl = GUICtrlCreateInput("", 0, 20, $W_size_w, 20, $ES_READONLY)
GUICtrlSetState(-1, $gui_hide)
If (WinActive("Tailchat") = 1) and (_IsPressed("0D")) Then
ChatButton()
EndIf
While 1
Tailit()
Sleep(50)
WEnd
Func Tailit()
$error = 0
$file = ControlGetText("Tailchat", "", $InputControl)
$count = _FileCountLines($file)
$scan = FileReadLine($file, $count)
$file_contents = ""
For $x = 1 To $count
$scan3 = FileReadLine($file, $x)
$display = _isSystemLine($file, $scan3, $x)
If $display = 1 Then
$file_contents &= $scan3 & @CRLF
ElseIf $display = 0 Then
EndIf
Next
if ($File_opened = 1) and ($initial = 0) Then
GUICtrlSetData($editControl, $file_contents)
_GUICtrlEditLineScroll($editControl, 0, $count)
$initial = 1
EndIf
If $File_opened = 1 Then
Select
Case $count2 <> $count
GUICtrlSetData($editControl, $file_contents)
If BitAND(WinGetState("Tailchat"), 16) Then
If $notify_on_minimize = 1 Then
TrayTip("TailChat", $scan, 5, 1)
EndIf
EndIf
_GUICtrlEditLineScroll($editControl, 0, $count)
Case $scan2 <> $scan
GUICtrlSetData($editControl, $file_contents)
_GUICtrlEditLineScroll($editControl, 0, $count)
EndSelect
EndIf
$count2 = $count
$scan2 = $scan
EndFunc ;==>Tailit
Func FileopenButton()
$nologin = 0
$old_file = ""
If $File_opened = 1 Then
$old_file = $selected_file
EndIf
Global $selected_file = FileOpenDialog("Open", @ScriptDir, "Text Files (*.*)")
If $selected_file = "" Then
$selected_file = $old_file
$nologin = 1
Else
_logout()
EndIf
GUICtrlSetData($InputControl, $selected_file)
Global $openfile = FileOpen($selected_file, 0)
$error = @error
$File_opened = 1
If $nologin <> 1 Then
_login()
EndIf
EndFunc ;==>FileopenButton
Func CLOSEClicked()
If @GUI_WinHandle == $mainWindow Then
_logout()
FileClose($openfile)
Exit
Else
GUIDelete(@GUI_WinHandle)
EndIf
EndFunc ;==>CLOSEClicked
Func ChatButton()
$inputtext = ControlGetText("", "", $chatControl)
If $File_opened = 1 Then
$inputtext = @HOUR & ":" & @MIN & " " & @UserName & ": " & $inputtext
$openfilewrite = FileOpen($selected_file, 1)
FileWriteLine($openfilewrite, $inputtext)
GUICtrlSetData($chatControl, "")
FileClose($openfilewrite)
Else
MsgBox(0, "No chat", "No chat has been logged into, nothing to send")
GUICtrlSetData($chatControl, "")
EndIf
EndFunc ;==>ChatButton
Func PushButton()
local $ischecked = _togglecheck($PushButton)
If $ischecked = 1 Then
WinSetOnTop("Tailchat", "", 1)
ElseIf $ischecked = 0 Then
WinSetOnTop("Tailchat", "", 0)
EndIf
EndFunc ;==>PushButton
Func _login()
$openfilewrite = FileOpen($selected_file, 1)
_FileWriteToLine($selected_file, 1, "##~~!!" & @UserName & "|" & @HOUR & @MIN & "|" & Random(1, 20, 1), 0)
FileWriteLine($openfilewrite, "--> " & @UserName & " has joined this chat at " & @HOUR & ":" & @MIN)
FileClose($openfilewrite)
EndFunc ;==>_login
Func _logout()
$openfilewrite = FileOpen($selected_file, 1)
_RemoveOnlineUser()
FileWriteLine($openfilewrite, "--> " & @UserName & " has left at " & @HOUR & ":" & @MIN)
FileClose($openfilewrite)
EndFunc ;==>_logout
Func Notification()
local $ischecked = _togglecheck($AwayCheck)
If $ischecked= 1 Then
$notify_on_minimize = 1
ElseIf $ischecked = 0 Then
$notify_on_minimize = 0
EndIf
EndFunc ;==>Notification
Func _isSystemLine($file, $scan3, $x)
If StringInStr($scan3, "##~~!!") <> 0 Then
Return 0
Else
Return 1
EndIf
EndFunc ;==>_isSystemLine
Func _RemoveOnlineUser()
Dim $atest, $aloc[1]
_FileReadToArray($selected_file, $atest)
For $x = 1 to (UBound($atest) - 1)
$isme = StringInStr($atest[$x], "##~~!!" & @UserName)
If $isme <> 0 Then
_ArrayAdd($aloc, $x)
EndIf
Next
For $y = (UBound($aloc) - 1) To 1 Step - 1
_FileWriteToLine($selected_file, $aloc[$y], "", 1)
Next
EndFunc ;==>_RemoveOnlineUser
Func ShowUsers()
If $File_opened = 1 Then
Dim $aEntFile, $afileusers[1]
_FileReadToArray($selected_file, $aEntFile)
For $x = 1 To UBound($aEntFile) - 1
If StringInStr($aEntFile[$x], "##~~!!") <> 0 Then
$sUser = StringTrimLeft($aEntFile[$x], 6)
$aSubUser = StringSplit($sUser, "|")
_ArrayAdd($afileusers, $aSubUser[1])
EndIf
Next
_ArrayDisplay($afileusers, "Array : aFileUsers ")
Else
MsgBox(0, "No Chat opened", "There are no users to display since you are not currently logged into a chat")
GUICtrlSetData($chatControl, "")
EndIf
EndFunc ;==>ShowUsers
Func About()
MsgBox(64, "About Tail Chat 2.2", "Tailchat was written in AutoIT V3.2" & @LF & @LF & "Written by : Blademonkey")
EndFunc ;==>About
Func _togglecheck($guihandle)
If GUICtrlRead($guihandle) = 68 Then
GUICtrlSetState($guihandle, $GUI_checked)
return 1
Else
GUICtrlSetState($guihandle, $GUI_unchecked)
return 0
EndIf
EndFunc ;==>_togglecheck
Func ConfigCheck()
local $ischecked = _togglecheck($configcheck)
If $ischecked= 1 Then
ConfigfileSet()
ElseIf $ischecked = 0 Then
;~ $notify_on_minimize = 0
EndIf
EndFunc
Func ConfigfileSet()
;~ if fileexists("c:\tailchat.ini")=0 Then
IniWrite("c:\tailchat.ini","chatrroms","chat1", $selected_file)
;~ EndIf
EndFunc
|
|
|
|
|
[Article] Virtual Desktops |
25/08/2006 06:31:55 (+0700) | #8 | 17783 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Virtual Desktops
Code:
#include <GUIConstants.au3>
#Include <Constants.au3>
#NoTrayIcon
Opt("TrayMenuMode",1)
FileDelete(@tempdir & "\pangaeadesktops.ini")
HotKeySet("#{ESC}","_panic")
HotKeySet("#{LEFT}","_prevdesk")
HotKeySet("#{RIGHT}","_nextdesk")
HotKeySet("^#{LEFT}","_movetoprev")
HotKeySet("^#{RIGHT}","_movetonext")
HotKeySet("#{DOWN}", "_QuickSelect")
Global $activedesk = 1,$winlist[500],$hwnd,$textwin,$texton = 0,$texttime,$desktopitem, $inaction = 0
_winget()
$desktopitem = TrayCreateItem("Desktop " & $activedesk)
TrayItemSetState(-1,$TRAY_DISABLE)
TrayCreateItem("")
$nextitem = TrayCreateItem("Next desktop win + right")
$previtem = TrayCreateItem("Prev desktop win + left")
TrayCreateItem("")
$tonextitem = TrayCreateItem("Move to next desktop ctrl + win + right")
$toprevitem = TrayCreateItem("Move to prev desktop ctrl + win + left")
TrayCreateItem("")
$displayall = TrayCreateItem("Quick Desktop Select win + down")
TrayCreateItem("")
$aboutitem = TrayCreateItem("About")
$exititem = TrayCreateItem("Exit win + esc")
TraySetState()
While 1
$msg = TrayGetMsg()
Select
Case $msg = $nextitem
_nextdesk()
Case $msg = $previtem
_prevdesk()
Case $msg = $tonextitem
_movetonext()
Case $msg = $toprevitem
_movetoprev()
Case $msg = $displayall
_QuickSelect()
Case $msg = $aboutitem
Msgbox(64,"About:","Pangaea Desktops" & @crlf & "by Rakudave, Pangaea WorX 2006" & @crlf & @crlf & "www.pangaeaworx.ch.vu")
Case $msg = $exititem
_panic()
EndSelect
If $texton = 1 then
If TimerDiff($texttime) > 2000 Then _text2()
Endif
WEnd
Func _showwins()
$var = IniReadSection(@tempdir & "\pangaeadesktops.ini", $activedesk)
If @error Then
return
Else
For $x = 1 To $var[0][0]
WinSetState($var[($var[0][0] +1) -$x][0],"",@SW_SHOW)
Next
EndIf
EndFunc ;==>_showwins
Func _hidewins()
$var = IniReadSection(@tempdir & "\pangaeadesktops.ini", $activedesk)
If @error Then
return
Else
For $x = 1 To $var[0][0]
WinSetState($var[($var[0][0] +1) -$x][0],"",@SW_HIDE)
Next
EndIf
EndFunc ;==>_hidewins
Func _QuickSelect()
If $inaction = 1 Then Return
$inaction = 1
For $i = 1 To 4
If $activedesk = $i Then
DllCall("captdll.dll", "int", "CaptureScreen", "str", @tempdir & "\pangaeaprtsc" & $i & ".jpg", "int", 85)
Else
_hidewins()
$olddesk = $activedesk
$activedesk = $i
_showwins()
DllCall("captdll.dll", "int", "CaptureScreen", "str", @tempdir & "\pangaeaprtsc" & $i & ".jpg", "int", 85)
_hidewins()
$activedesk = $olddesk
_showwins()
EndIf
Next
$hwnd = GUICreate("AnimatedWindow",@desktopwidth,@desktopheight,0,0,$WS_POPUP,$WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$one = GUICtrlCreatePic(@tempdir & "\pangaeaprtsc1.jpg",0,0,@DesktopWidth/2,@DesktopHeight/2)
$two = GUICtrlCreatePic(@tempdir & "\pangaeaprtsc2.jpg",@DesktopWidth/2,0,@DesktopWidth/2,@DesktopHeight/2)
$three = GUICtrlCreatePic(@tempdir & "\pangaeaprtsc3.jpg",0,@DesktopHeight/2,@DesktopWidth/2,@DesktopHeight/2)
$four = GUICtrlCreatePic(@tempdir & "\pangaeaprtsc4.jpg",@DesktopWidth/2,@DesktopHeight/2,@DesktopWidth/2,@DesktopHeight/2)
GUISetState()
While 1
Switch GUIGetMsg()
Case $one
GUIDelete()
_hidewins()
$activedesk = 1
_showwins()
ExitLoop
Case $two
GUIDelete()
_hidewins()
$activedesk = 2
_showwins()
ExitLoop
Case $three
GUIDelete()
_hidewins()
$activedesk = 3
_showwins()
ExitLoop
Case $four
GUIDelete()
_hidewins()
$activedesk = 4
_showwins()
ExitLoop
EndSwitch
WEnd
$inaction = 0
EndFunc ;==>QuickSelect
Func _nextdesk()
If $inaction = 1 then return
$inaction = 1
If $texton = 1 Then _text2()
_winget()
_animate1("r")
_hidewins()
$activedesk = $activedesk + 1
If $activedesk = 5 Then $activedesk = 1
_showwins()
_animate2()
$inaction = 0
_text1()
EndFunc ;==>_nextdesk
Func _prevdesk()
If $inaction = 1 then return
$inaction = 1
If $texton = 1 Then _text2()
_winget()
_animate1("l")
_hidewins()
$activedesk = $activedesk - 1
If $activedesk = 0 Then $activedesk = 4
_showwins()
_animate3()
$inaction = 0
_text1()
EndFunc ;==>_prevdesk
Func _movetonext()
If $inaction = 1 then return
$inaction = 1
_winget()
IniDelete (@tempdir & "\pangaeadesktops.ini",$activedesk,$winlist[1])
$activedesk = $activedesk + 1
If $activedesk = 5 Then $activedesk = 1
Iniwrite(@tempdir & "\pangaeadesktops.ini",$activedesk,$winlist[1],"moved")
$activedesk = $activedesk - 1
If $activedesk = 0 Then $activedesk = 4
WinSetState($winlist[1],"",@SW_HIDE)
$inaction = 0
_nextdesk()
EndFunc ;==>_movetonext
Func _movetoprev()
If $inaction = 1 then return
$inaction = 1
_winget()
IniDelete (@tempdir & "\pangaeadesktops.ini",$activedesk,$winlist[1])
$activedesk = $activedesk - 1
If $activedesk = 0 Then $activedesk = 4
Iniwrite(@tempdir & "\pangaeadesktops.ini",$activedesk,$winlist[1],"moved")
$activedesk = $activedesk + 1
If $activedesk = 5 Then $activedesk = 1
WinSetState($winlist[1],"",@SW_HIDE)
$inaction = 0
_prevdesk()
EndFunc ;==>_movetoprev
Func _winget()
$y = 0
$var = WinList()
IniDelete(@tempdir & "\pangaeadesktops.ini",$activedesk)
For $x = 1 to $var[0][0]
If $var[$x][0] <> "" AND IsVisible($var[$x][1]) AND $var[$x][0] <> "Program Manager" AND $var[$x][0] <> "Desktop 1" AND $var[$x][0] <> "Desktop 2" AND $var[$x][0] <> "Desktop 3" AND $var[$x][0] <> "Desktop 4" Then
Iniwrite(@tempdir & "\pangaeadesktops.ini",$activedesk,$var[$x][0],$var[$x][1])
$y = $y + 1
$winlist[$y] = $var[$x][0]
EndIf
Next
$winlist[0] = $y
EndFunc ;==>_winget
Func _panic()
for $y = 1 to 4
$var = IniReadSection(@tempdir & "\pangaeadesktops.ini", $y)
If @error = 0 then
For $x = 1 To $var[0][0]
WinSetState($var[($var[0][0] +1) -$x][0],"",@SW_SHOW)
Next
EndIf
next
FileDelete(@tempdir & "\pangaeadesktops.ini")
FileDelete(@tempdir & "\pangaeaprtsc.jpg")
FileDelete(@tempdir & "\pangaeaprtsc1.jpg")
FileDelete(@tempdir & "\pangaeaprtsc2.jpg")
FileDelete(@tempdir & "\pangaeaprtsc3.jpg")
FileDelete(@tempdir & "\pangaeaprtsc4.jpg")
exit
EndFunc ;==>_panic
Func _animate1($direction)
If $direction ="r" Then
$activedesktemp = $activedesk + 1
If $activedesktemp = 5 Then $activedesktemp = 1
ElseIf $direction = "l" Then
$activedesktemp = $activedesk - 1
If $activedesktemp = 0 Then $activedesktemp = 4
EndIf
DllCall("captdll.dll", "int", "CaptureScreen", "str", @tempdir & "\pangaeaprtsc.jpg", "int", 85)
DllCall("captdll.dll", "int", "CaptureScreen", "str", @tempdir & "\pangaeaprtsc" & $activedesktemp & ".jpg", "int", 85)
$hwnd = GUICreate("AnimatedWindow",@desktopwidth,@desktopheight,0,0,$WS_POPUP,$WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
GUICtrlCreatePic(@tempdir & "\pangaeaprtsc.jpg",0,0,@desktopwidth,@desktopheight)
GUISetState()
EndFunc ;==>_animate1
Func _animate2()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050002);slide out to left
GUIDelete($hwnd)
EndFunc ;==>_animate2
Func _animate3()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050001);slide out to right
GUIDelete($hwnd)
EndFunc ;==>_animate3
Func _text1()
$text = "Desktop " & $activedesk
TrayItemSetText($desktopitem,$text)
$textwin = TextWindow($text,600,40,"",-1,10,10,0xFF0000)
GUISetState()
$texton = 1
$texttime = TimerInit()
EndFunc ;==>_text1
Func _text2()
GUIDelete($textwin)
$texton = 0
EndFunc ;==>_text2
Func OnAutoItExit()
_panic()
EndFunc ;==>OnAutoItExit
Func IsVisible($handle)
If BitAnd(WinGetState($handle),2) Then
Return 1
Else
Return 0
EndIf
EndFunc ;==>IsVisible
Func TextWindow($zText,$width,$height,$font="Microsoft Sans Serif",$weight=1000,$x=-1,$y=-1,$color=-1)
Local Const $ANSI_CHARSET = 0
Local Const $OUT_CHARACTER_PRECIS = 2
Local Const $CLIP_DEFAULT_PRECIS = 0
Local Const $PROOF_QUALITY = 2
Local Const $FIXED_PITCH = 1
Local Const $RGN_XOR = 3
If $font = "" Then $font = "Microsoft Sans Serif"
If $weight = -1 Then $weight = 1000
Local $gui = GUICreate("Text Window",$width,$height,$x,$y,$WS_POPUP,$WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
If $color <> -1 Then GUISetBkColor($color)
Local $hDC= DLLCall("user32.dll","int","GetDC","hwnd",$gui)
Local $hMyFont = DLLCall("gdi32.dll","hwnd","CreateFont","int",$height, _
"int",0,"int",0,"int",0,"int",1000,"int",0, _
"int",0,"int",0,"int",$ANSI_CHARSET, _
"int",$OUT_CHARACTER_PRECIS,"int",$CLIP_DEFAULT_PRECIS, _
"int",$PROOF_QUALITY,"int",$FIXED_PITCH,"str",$font )
Local $hOldFont = DLLCall("gdi32.dll","hwnd","SelectObject","int",$hDC[0], _
"hwnd",$hMyFont[0])
DLLCall("gdi32.dll","int","BeginPath","int",$hDC[0])
DLLCall("gdi32.dll","int","TextOut","int",$hDC[0],"int",0,"int",0, _
"str",$zText,"int",StringLen($zText))
DLLCall("gdi32.dll","int","EndPath","int",$hDC[0])
Local $hRgn1 = DLLCall("gdi32.dll","hwnd","PathToRegion","int",$hDC[0])
Local $rc = DLLStructCreate("int;int;int;int")
DLLCall("gdi32.dll","int","GetRgnBox","hwnd",$hRgn1[0], _
"ptr",DllStructGetPtr($rc))
Local $hRgn2 = DLLCall("gdi32.dll","hwnd","CreateRectRgnIndirect", _
"ptr",DllStructGetPtr($rc))
DLLCall("gdi32.dll","int","CombineRgn","hwnd",$hRgn2[0],"hwnd",$hRgn2[0], _
"hwnd",$hRgn1[0],"int",$RGN_XOR)
DLLCall("gdi32.dll","int","DeleteObject","hwnd",$hRgn1[0])
DLLCall("user32.dll","int","ReleaseDC","hwnd",$gui,"int",$hDC[0])
DLLCall("user32.dll","int","SetWindowRgn","hwnd",$gui,"hwnd",$hRgn2[0],"int",1)
DLLCall("gdi32.dll","int","SelectObject","int",$hDC[0],"hwnd",$hOldFont[0])
Return $gui
EndFunc ;==>TextWindow
|
|
|
|
|
[Question] Viết ứng dụng đơn giản với AutoIt |
25/08/2006 21:26:33 (+0700) | #9 | 17937 |
|
eyesdog
Elite Member
|
0 |
|
|
Joined: 18/01/2002 06:54:01
Messages: 94
Offline
|
|
Dùng cái tool này là cách dễ nhất để viết các personal firewall bypass. |
|
|
|
|
[Question] Viết ứng dụng đơn giản với AutoIt |
06/09/2006 00:23:13 (+0700) | #10 | 20869 |
|
DaoDuyHieu
HVA Friend
|
Joined: 14/04/2004 00:32:37
Messages: 200
Location: MICROSOFT
Offline
|
|
Chào bồ ! Tớ cũng võ vẽ vọc AutoIT, có 2 vấn đề giúp đỡ :
1. Nếu 1 chương trình đang trong chế độ Inactive, có thể sendkey đến chương trình đó được kô, nếu được thì làm thế nào ?
2. Nếu chương trình đó không ẩn giao diện(đang chạy virtual desktop) có cách nào bắt khung hình lại được không ?
Thanks |
|
Great hopes make great men |
|
|
|
[Question] Viết ứng dụng đơn giản với AutoIt |
09/09/2006 21:25:39 (+0700) | #11 | 22030 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Tôi cũng chỉ mới mò mẫm qua cái Help thôi nên cũng chẳng rành rẽ gì mấy...
1. Bạn có thể Active cái cửa sổ rồi SendKey được mà... Tôi không biết ứng dụng bạn dùng là gì.
2. Câu hỏi này tôi không hiểu mấy... |
|
|
|
|
[Question] Viết ứng dụng đơn giản với AutoIt |
12/09/2006 04:26:28 (+0700) | #12 | 22613 |
|
DaoDuyHieu
HVA Friend
|
Joined: 14/04/2004 00:32:37
Messages: 200
Location: MICROSOFT
Offline
|
|
|
|
[Question] Viết ứng dụng đơn giản với AutoIt |
12/09/2006 09:15:02 (+0700) | #13 | 22668 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
AutoIt chỉ gửi được phím tới cửa sổ đang active thì phải... Các hàm hơi gói gọn và cũng không nhiều nên khả năng làm nhiều phần mềm hay cũng hơi khó... |
|
|
|
|
[Question] Viết ứng dụng đơn giản với AutoIt |
27/09/2006 01:53:30 (+0700) | #14 | 25988 |
|
Luke
Elite Member
|
0 |
|
|
Joined: 05/09/2002 13:21:20
Messages: 83
Offline
|
|
ControlSend() có thể gửi được đến tất cả các cửa sổ active or inactive, hidden or show.. |
|
|
|
|
[Article] Sodoku Game |
15/12/2006 02:51:50 (+0700) | #15 | 30517 |
nhutdm
Elite Member
|
0 |
|
|
Joined: 02/06/2003 12:40:50
Messages: 45
Offline
|
|
Sodoku Game
Code:
; created mostly by fisofo, with code scraps borrowed from all over ;)
; check "about" for credits.
#NoTrayIcon
#include <IE.au3>
#include <GuiConstants.au3>
Dim $aSudArray[9][9]
Dim $aOrigArray[9][9]
Dim $aEnumArray[10]
Dim $smallbuttons[9][9][9]
Dim $largebuttons[9][9]
Dim $IDtoPosition[1000][3]
Dim $Difficulty = 1
Dim $DifficultyText = "Easy"
Dim $Progress = 0
Dim $increment = 1
Dim $ProgressBar
Dim $HelperCheckbox
Dim $PossibilityArray[9][9][10]
Dim $SolutionsArray[81][3]
Dim $SolutionsCount = 0
Dim $isSolved = 0
_MainMenu()
;~ _StartSudoku() ; for testing
Func _MainMenu()
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 7)
GuiCreate("Sudoku-It!", 222, 403,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Progress = 0
$ButtonEasy = GuiCtrlCreateButton("Easy", 10, 40, 200, 50)
GUICtrlSetFont($ButtonEasy, 12, 700)
$ButtonMedium = GuiCtrlCreateButton("Medium", 10, 100, 200, 50)
GUICtrlSetFont($ButtonMedium, 12, 700)
$ButtonHard = GuiCtrlCreateButton("Hard", 10, 160, 200, 50)
GUICtrlSetFont($ButtonHard, 12, 700)
$ButtonInsane = GuiCtrlCreateButton("Insane", 10, 220, 200, 50)
GUICtrlSetFont($ButtonInsane, 12, 700)
$ButtonCustom = GuiCtrlCreateButton("Custom", 10, 280, 200, 50)
GUICtrlSetFont($ButtonCustom, 12, 700)
$ButtonAbout = GuiCtrlCreateButton("About", 60, 360, 100, 30)
$Label_GUI = GuiCtrlCreateLabel("Select Difficulty Level", 10, 10, 200, 20, $SS_CENTER)
GUICtrlSetFont($Label_GUI, 14, 700)
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
$ProgressBar = GuiCtrlCreateProgress(10, 340, 200, 10, $PBS_SMOOTH)
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $ButtonEasy
$Difficulty = 1
$DifficultyText = "Easy"
ExitLoop
Case $msg = $ButtonMedium
$Difficulty = 2
$DifficultyText = "Medium"
ExitLoop
Case $msg = $ButtonHard
$Difficulty = 3
$DifficultyText = "Hard"
ExitLoop
Case $msg = $ButtonInsane
$Difficulty = 4
$DifficultyText = "Insane"
ExitLoop
Case $msg = $ButtonCustom
$Difficulty = 1
$DifficultyText = "Custom!"
For $row = 0 to 8
For $col = 0 to 8
$aSudArray[$row][$col] = 0
$aOrigArray[$row][$col] = 0
Next
Next
GUIDelete()
_SudokuGUI()
Case $msg = $ButtonAbout
MsgBox(64, "About", "Mostly created by Fisofo..." & Chr(13) & Chr(13) & Chr(13) & _
"But Sudokudos! to:" & Chr(13) & Chr(13) & _
"nfwu for the Game GUI and" & Chr(13) & _
"PsaltyDS for the Progress bar" & Chr(13) & Chr(13) & _
"To the forum goers that" & Chr(13) & _
"put up with my questions ;)" & Chr(13) & Chr(13) & _
"And to my loverly wife," & Chr(13) & _
"who lets me stay up late coding!")
Case Else
;;;
EndSelect
WEnd
_SetProgColor()
GUICtrlSetState($ButtonEasy, $GUI_DISABLE)
_SetProgColor()
GUICtrlSetState($ButtonMedium, $GUI_DISABLE)
_SetProgColor()
GUICtrlSetState($ButtonHard, $GUI_DISABLE)
_SetProgColor()
GUICtrlSetState($ButtonInsane, $GUI_DISABLE)
_SetProgColor()
GUICtrlSetState($ButtonCustom, $GUI_DISABLE)
_SetProgColor()
GUICtrlSetState($ButtonAbout, $GUI_DISABLE)
_SetProgColor()
_StartSudoku()
EndFunc ;==>_MainMenu
Func _StartSudoku()
_SudokuGenerator()
GUIDelete()
_SudokuGUI()
EndFunc
Func _SudokuGUI() ; credit to nfwu for the math behind the GUI!
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
Dim $GUI = GUICreate("Sudoku-It! Game - " & $DifficultyText, 3 * 230 - 10, 3 * 230 + 50)
For $h = 0 To 8
For $i = 0 To 8
GUICtrlCreateGroup("", 5 + Mod($h, 3) * 230 + Mod($i, 3) * 70, _
0 + Int($h / 3) * 230 + Int($i / 3) * 70, 70, 75)
For $j = 0 To 8
$smallbuttons[$h][$i][$j] = _CreateSmallButton($h, $i, $j)
$IDtoPosition[$smallbuttons[$h][$i][$j]][0] = $h
$IDtoPosition[$smallbuttons[$h][$i][$j]][1] = $i
$IDtoPosition[$smallbuttons[$h][$i][$j]][2] = $j
GUICtrlSetState($smallbuttons[$h][$i][$j],$GUI_HIDE)
Next
Next
Next
For $h = 0 To 8
For $i = 0 To 8
$largebuttons[$h][$i] = _CreateLargeButton($h, $i, $j)
$IDtoPosition[$largebuttons[$h][$i]][0] = $h
$IDtoPosition[$largebuttons[$h][$i]][1] = $i
$IDtoPosition[$largebuttons[$h][$i]][2] = -1
GUICtrlSetState($largebuttons[$h][$i],$GUI_HIDE)
Next
Next
$Progress = 0
$ProgressBar = GuiCtrlCreateProgress(155, 3 * 230 - 10, 290, 50, $PBS_SMOOTH)
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 7)
$HelperCheckbox = GUICtrlCreateCheckbox("Helper Mode On/Off", 10, 3 * 230 - 10)
GUICtrlSetState($HelperCheckbox, $GUI_UNCHECKED)
$SolveButton = GUICtrlCreateButton("Solve", 10, 3 * 230 + 15)
$ResetButton = GUICtrlCreateButton("Reset", 50, 3 * 230 + 15)
$CheckButton = GUICtrlCreateButton("Check It!", 90, 3 * 230 + 15)
$SudokuLabel = GUICtrlCreateLabel("Sudoku-It!", 460, 3 * 230 - 10, 3 * 230, 50)
GUICtrlSetFont($SudokuLabel, 32, 700, 2)
_InitGUI()
_SudokuInitNormal()
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
GUIDelete()
_MainMenu()
Case $msg >= $smallbuttons[0][0][0] AND $msg <= $smallbuttons[8][8][8]
if GUICtrlRead($HelperCheckbox) = $GUI_CHECKED Then
_SudokuEliminator($msg)
Elseif GUICtrlRead($HelperCheckbox) = $GUI_UNCHECKED Then
_SudokuNormalMode("small", $msg)
EndIf
Case $msg >= $largebuttons[0][0] AND $msg <= $largebuttons[8][8]
GUICtrlSetData($msg, 0)
$row = _GridConvert($IDtoPosition[$msg][0], $IDtoPosition[$msg][1], "row")
$col = _GridConvert($IDtoPosition[$msg][0], $IDtoPosition[$msg][1], "col")
$aSudArray[$row][$col] = 0
if GUICtrlRead($HelperCheckbox) = $GUI_CHECKED Then
_SudokuEliminator(-1)
Elseif GUICtrlRead($HelperCheckbox) = $GUI_UNCHECKED Then
_SudokuNormalMode("big", $msg)
EndIf
Case $msg = $HelperCheckbox
if GUICtrlRead($HelperCheckbox) = $GUI_CHECKED Then
_SudokuEliminator(-1)
Elseif GUICtrlRead($HelperCheckbox) = $GUI_UNCHECKED Then
_SudokuInitNormal()
EndIf
Case $msg = $SolveButton
_SudokuSolver()
case $msg = $CheckButton
$isSolved = _SudokuEliminator(-1)
if $isSolved = 81 Then
MsgBox(0,"Congrats", "You're done!") ; obviously not done
Else
MsgBox(0,"Keep Going...","Have you tried the Solve Button?")
EndIf
Case $msg = $ResetButton
For $row = 0 to 8
for $col = 0 to 8
$h = _GridConvert($row, $col, "h")
$i = _GridConvert($row, $col, "i")
if $aSudArray[$row][$col] <> 0 Then
$aSudArray[$row][$col] = $aOrigArray[$row][$col]
EndIf
Next
Next
if GUICtrlRead($HelperCheckbox) = $GUI_CHECKED Then
_SudokuEliminator(-1)
Elseif GUICtrlRead($HelperCheckbox) = $GUI_UNCHECKED Then
_SudokuInitNormal()
EndIf
Case Else
;
EndSelect
WEnd
EndFunc ;==>_SudokuGUI
Func _SudokuInitNormal()
For $row = 0 to 8
for $col = 0 to 8
$h = _GridConvert($row, $col, "h")
$i = _GridConvert($row, $col, "i")
if $aSudArray[$row][$col]= 0 Then
GUICtrlSetState($largebuttons[$h][$i],$GUI_HIDE)
for $aCell = 0 to 8
GUICtrlSetState($smallbuttons[$h][$i][$aCell],$GUI_SHOW)
Next
Else
GUICtrlSetData($largebuttons[$h][$i], $aSudArray[$row][$col])
GUICtrlSetState($largebuttons[$h][$i],$GUI_SHOW)
for $aCell = 0 to 8
GUICtrlSetState($smallbuttons[$h][$i][$aCell],$GUI_HIDE)
Next
EndIf
Next
Next
EndFunc ;==>_SudokuInitNormal
Func _InitGUI()
For $row = 0 to 8
for $col = 0 to 8
$h = _GridConvert($row, $col, "h")
$i = _GridConvert($row, $col, "i")
GUICtrlSetState($largebuttons[$h][$i],$GUI_SHOW)
GUICtrlSetFont($largebuttons[$h][$i],14,1000)
if $aSudArray[$row][$col] <> 0 Then
GUICtrlSetState($largebuttons[$h][$i],$GUI_DISABLE)
EndIf
Next
Next
EndFunc ;==>_InitGUI
Func _SudokuGenerator()
$oIE = _IECreate("http://view.websudoku.com/?level=" & $Difficulty, 0, 0, 0) ; Disable for testing
;~ $oIE = _IEAttach("http://view.websudoku.com/?level=4", "URL") ; for testing, open in seperate browser before running script
_SetProgColor()
while 1
if _IEPropertyGet($oIE, "readystate") = 4 Then
ExitLoop
Else
_SetProgColor()
EndIf
WEnd
_SetProgColor()
$oSudForm = _IEFormGetObjByName($oIE, "board")
_SetProgColor()
$oSudInputs = _IEFormElementGetCollection($oSudForm)
_SetProgColor()
$row = 0
$col = 0
For $oSudInput in $oSudInputs
$aSudArray[$row][$col] = _IEFormElementGetValue($oSudInput)
$aOrigArray[$row][$col] = $aSudArray[$row][$col]
_SetProgColor()
If $row = 8 and $col = 8 Then
ExitLoop
EndIf
If $col = 8 Then
$col = 0
$row = $row + 1
Else
$col = $col + 1
EndIf
Next
while $Progress < 1000
_SetProgColor()
WEnd
_IEQuit($oIE) ; Disable for testing
EndFunc ;==>_SudokuGenerator
Func _SudokuNormalMode($button, $CID)
if $button = "small" Then
;----- small button clicked -----;
; set value in array to number from small box
$row = _GridConvert($IDtoPosition[$CID][0], $IDtoPosition[$CID][1], "row")
$col = _GridConvert($IDtoPosition[$CID][0], $IDtoPosition[$CID][1], "col")
$aSudArray[$row][$col] = GUICtrlRead($CID)
$h = _GridConvert($row, $col, "h")
$i = _GridConvert($row, $col, "i")
;hide small buttons in this cell
for $j = 0 to 8
GUICtrlSetState($smallbuttons[$h][$i][$j],$GUI_HIDE)
Next
;show big button in this cell
GUICtrlSetData($largebuttons[$h][$i], $aSudArray[$row][$col])
GUICtrlSetState($largebuttons[$h][$i],$GUI_SHOW)
Elseif $button = "big" Then
;----- big button clicked -----;
; value is already zero in button and array
$row = _GridConvert($IDtoPosition[$CID][0], $IDtoPosition[$CID][1], "row")
$col = _GridConvert($IDtoPosition[$CID][0], $IDtoPosition[$CID][1], "col")
$h = _GridConvert($row, $col, "h")
$i = _GridConvert($row, $col, "i")
;show small buttons in this cell
for $j = 0 to 8
GUICtrlSetState($smallbuttons[$h][$i][$j],$GUI_SHOW)
Next
; hide big button in this cell
GUICtrlSetState($largebuttons[$h][$i],$GUI_HIDE)
EndIf
EndFunc ;==>_SudokuNormalMode
Func _SudokuSolver()
; Methods
; 1. check for cells that have one possibility
; 2. check boxes/rows/cols for a cell that has a possibility no other cell has
; 3. Not implemented:Check for cells that depend on eachother to eliminate other possibilities?
GUICtrlSetState($HelperCheckbox, $GUI_CHECKED)
$count = 0
$DoneYet = _SudokuEliminator(-1)
while 1
_SudokuSolver1()
_SudokuSolver2()
$CantSolve = $DoneYet
$DoneYet = _SudokuEliminator(-1)
if $DoneYet = 81 Then
ExitLoop
ElseIf $count = 2 Then
ExitLoop
ElseIf $CantSolve = $DoneYet Then
$count = $count + 1
EndIf
WEnd
while $Progress <> 0
_SetProgColor()
WEnd
EndFunc ;==>_SudokuNormalMode
Func _SudokuSolver1()
_SudokuEliminator(-1)
; done checking board, all case 1 solutions are in $SolutionsArray
for $x = 0 to $SolutionsCount - 1
$aSudArray[$SolutionsArray[$x][0]][$SolutionsArray[$x][1]] = $SolutionsArray[$x][2]
Next
EndFunc ;==>_SudokuSolver1
Func _SudokuSolver2()
Dim $SolutionsArray2[81][3]
Dim $Case2Array[10][3]
$SolutionsCount = 0
For $row = 0 to 8
; Check Column
For $x = 0 to 9
$Case2Array[$x][2] = 0
Next
For $inCol = 0 to 8
For $aChoice = 1 to 9
_SetProgColor()
if $PossibilityArray[$row][$inCol][$aChoice] = 1 Then
$Case2Array[$aChoice][0] = $row
$Case2Array[$aChoice][1] = $inCol
$Case2Array[$aChoice][2] = $Case2Array[$aChoice][2] + 1
EndIf
Next
Next
; done checking Column, check for $aChoice's = 1
for $aChoice = 1 to 9
_SetProgColor()
if $Case2Array[$aChoice][2] = 1 Then
$SolutionsArray2[$SolutionsCount][0] = $Case2Array[$aChoice][0]
$SolutionsArray2[$SolutionsCount][1] = $Case2Array[$aChoice][1]
$SolutionsArray2[$SolutionsCount][2] = $aChoice
$SolutionsCount = $SolutionsCount + 1
EndIf
Next
Next
For $col = 0 to 8
; Check Row
For $x = 0 to 9
$Case2Array[$x][2] = 0
Next
For $inRow = 0 to 8
For $aChoice = 1 to 9
_SetProgColor()
if $PossibilityArray[$inRow][$col][$aChoice] = 1 Then
$Case2Array[$aChoice][0] = $inRow
$Case2Array[$aChoice][1] = $col
$Case2Array[$aChoice][2] = $Case2Array[$aChoice][2] + 1
EndIf
Next
Next
; done checking Row, check for $aChoice's = 1
for $aChoice = 1 to 9
_SetProgColor()
if $Case2Array[$aChoice][2] = 1 Then
$SolutionsArray2[$SolutionsCount][0] = $Case2Array[$aChoice][0]
$SolutionsArray2[$SolutionsCount][1] = $Case2Array[$aChoice][1]
$SolutionsArray2[$SolutionsCount][2] = $aChoice
$SolutionsCount = $SolutionsCount + 1
EndIf
Next
Next
; now check $PossibilityArray for each box to find case 2 solutions
For $row = 0 to 6 step 3
for $col = 0 to 6 step 3
For $x = 0 to 9
$Case2Array[$x][2] = 0
Next
$aStrCol = floor($col/3)*3
$aEndCol = floor($col/3)*3+2
$aStrRow = floor($row/3)*3
$aEndRow = floor($row/3)*3+2
for $inRow = $aStrRow to $aEndRow
for $inCol = $aStrCol to $aEndCol
for $aChoice = 1 to 9
_SetProgColor()
if $PossibilityArray[$inRow][$inCol][$aChoice] = 1 Then
$Case2Array[$aChoice][0] = $inRow
$Case2Array[$aChoice][1] = $inCol
$Case2Array[$aChoice][2] = $Case2Array[$aChoice][2] + 1
EndIf
Next
Next
Next
; done checking box, check for $aChoice's = 1
for $aChoice = 1 to 9
_SetProgColor()
if $Case2Array[$aChoice][2] = 1 Then
$SolutionsArray2[$SolutionsCount][0] = $Case2Array[$aChoice][0]
$SolutionsArray2[$SolutionsCount][1] = $Case2Array[$aChoice][1]
$SolutionsArray2[$SolutionsCount][2] = $aChoice
$SolutionsCount = $SolutionsCount + 1
EndIf
Next
Next
Next
for $x = 0 to $SolutionsCount - 1
$aSudArray[$SolutionsArray2[$x][0]][$SolutionsArray2[$x][1]] = $SolutionsArray2[$x][2]
Next
EndFunc ;==>_SudokuSolver2
Func _SudokuSolver3() ; doesn't quite work
Dim $Case3Array[10][6]
; now check $PossibilityArray for each box to find case 3 solutions
For $row = 0 to 6 step 3
for $col = 0 to 6 step 3
For $x = 0 to 9
$Case3Array[$x][2] = 0
$Case3Array[$x][5] = 0
Next
$aStrCol = floor($col/3)*3
$aEndCol = floor($col/3)*3+2
$aStrRow = floor($row/3)*3
$aEndRow = floor($row/3)*3+2
for $inRow = $aStrRow to $aEndRow
for $inCol = $aStrCol to $aEndCol
for $aChoice = 1 to 9
_SetProgColor()
If $Case3Array[$aChoice][5] > 1 Then
;skip
Elseif $PossibilityArray[$inRow][$inCol][$aChoice] = 1 Then
If $Case3Array[$aChoice][2] = 0 Then
$Case3Array[$aChoice][0] = $inRow
$Case3Array[$aChoice][1] = $inCol
$Case3Array[$aChoice][2] = $Case3Array[$aChoice][2] + 1
ElseIf $Case3Array[$aChoice][5] = 0 Then
$Case3Array[$aChoice][3] = $inRow
$Case3Array[$aChoice][4] = $inCol
$Case3Array[$aChoice][5] = $Case3Array[$aChoice][5] + 1
Else
$Case3Array[$aChoice][5] = $Case3Array[$aChoice][5] + 1
EndIf
EndIf
Next
Next
Next
; done checking box, check for $aChoice's = 1
for $aChoice = 1 to 9
_SetProgColor()
if $Case3Array[$aChoice][5] = 1 Then
if $Case3Array[$aChoice][0] = $Case3Array[$aChoice][3] Then
; we found 2 unique in box in a row, eliminate others in this row
For $inCol = 0 to 8
$inRow = $Case3Array[$aChoice][0]
if $inCol = $Case3Array[$aChoice][1] or $inCol = $Case3Array[$aChoice][4] Then
; do nothing
Else
$PossibilityArray[$inRow][$inCol][$aChoice] = 0
$h = _GridConvert($inRow, $inCol, "h")
$i = _GridConvert($inRow, $inCol, "i")
GUICtrlSetState($smallbuttons[$h][$i][$aChoice-1],$GUI_HIDE)
EndIf
Next
ElseIf $Case3Array[$aChoice][1] = $Case3Array[$aChoice][4] Then
; we found 2 unique in box in a col, eliminate others in this col
For $inRow = 0 to 8
$inCol = $Case3Array[$aChoice][1]
if $inRow = $Case3Array[$aChoice][0] or $inRow = $Case3Array[$aChoice][3] Then
; do nothing
Else
$PossibilityArray[$inRow][$inCol][$aChoice] = 0
$h = _GridConvert($inRow, $inCol, "h")
$i = _GridConvert($inRow, $inCol, "i")
GUICtrlSetState($smallbuttons[$h][$i][$aChoice-1],$GUI_HIDE)
EndIf
Next
EndIf
EndIf
Next
Next
Next
EndFunc ;==>_SudokuSolver3
Func _SudokuEliminator($CID)
Dim $SolutionsArray[81][3]
Dim $PossibilityArray[9][9][10]
$SolutionsCount = 0
$isSolved = 0
if $CID = -1 Then
;----- Eliminator/check all = will check entire board and reset as necessary
$StartCol = 0
$StartRow = 0
$EndCol = 8
$EndRow = 8
$HideNumber = 0 ;value to run main program checks on
Else
;----- Eliminator/small button clicked -----;
; set value in array to number from small box
$row = _GridConvert($IDtoPosition[$CID][0], $IDtoPosition[$CID][1], "row")
$col = _GridConvert($IDtoPosition[$CID][0], $IDtoPosition[$CID][1], "col")
$aSudArray[$row][$col] = GUICtrlRead($CID)
$HideNumber = $aSudArray[$row][$col]
$StartCol = $col
$StartRow = $row
$EndCol = $col
$EndRow = $row
EndIf
For $row = $StartRow to $EndRow
for $col = $StartCol to $EndCol
$h = _GridConvert($row, $col, "h")
$i = _GridConvert($row, $col, "i")
If $CID <> -1 Then ;----- Eliminator/sb clicked = hide the small buttons in this cell
for $j = 0 to 8
GUICtrlSetState($smallbuttons[$h][$i][$j],$GUI_HIDE)
Next
EndIf
; in normal mode, this "if" runs through any cell that does not have a big button
; in sb clicked mode, this "if" runs through just the cell that was clicked
if $aSudArray[$row][$col]= $HideNumber Then
If $CID = -1 Then ;----- Eliminator/check all = here, this cell is value 0, so hide the big button
GUICtrlSetState($largebuttons[$h][$i],$GUI_HIDE)
For $x = 0 to 9
$aEnumArray[$x] = True ;----- Eliminator/check all = initialize array of possible choices
Next
Else ;----- Eliminator/sb clicked = replace cell w/ big button of value = sb clicked
GUICtrlSetData($largebuttons[$h][$i], $HideNumber)
GUICtrlSetState($largebuttons[$h][$i],$GUI_SHOW)
EndIf
for $inCol = 0 to 8
_SetProgColor()
if $CID <> -1 Then ;----- Eliminator/sb clicked = hide the number clicked in this column
$h = _GridConvert($row, $inCol, "h")
$i = _GridConvert($row, $inCol, "i")
GUICtrlSetState($smallbuttons[$h][$i][$HideNumber-1],$GUI_HIDE)
ElseIf $aSudArray[$row][$inCol] <> 0 Then ;----- Eliminator/check all = check column cells that won't be possible to pick
$aEnumArray[$aSudArray[$row][$inCol]] = False
$PossibilityArray[$row][$inCol][$aSudArray[$row][$inCol]] = 0
EndIf
Next
for $inRow = 0 to 8
_SetProgColor()
if $CID <> -1 Then ;----- Eliminator/sb clicked = hide the number clicked in this row
$h = _GridConvert($inRow, $col, "h")
$i = _GridConvert($inRow, $col, "i")
GUICtrlSetState($smallbuttons[$h][$i][$HideNumber-1],$GUI_HIDE)
ElseIf $aSudArray[$inRow][$col] <> 0 Then ;----- Eliminator/check all = check row cells that won't be possible to pick
$aEnumArray[$aSudArray[$inRow][$col]] = False
$PossibilityArray[$inRow][$col][$aSudArray[$inRow][$col]] = 0
EndIf
Next
; define where the box starts/ends for row/col
$aStrCol = floor($col/3)*3
$aEndCol = floor($col/3)*3+2
$aStrRow = floor($row/3)*3
$aEndRow = floor($row/3)*3+2
for $inRow = $aStrRow to $aEndRow
for $inCol = $aStrCol to $aEndCol
_SetProgColor()
if $CID <> -1 Then ;----- Eliminator/sb clicked = hide the number clicked in this box
$h = _GridConvert($inRow, $inCol, "h")
$i = _GridConvert($inRow, $inCol, "i")
GUICtrlSetState($smallbuttons[$h][$i][$HideNumber-1],$GUI_HIDE)
ElseIf $aSudArray[$inRow][$inCol] <> 0 Then ;----- Eliminator/check all = check the current box for cells that can't be picked
$aEnumArray[$aSudArray[$inRow][$inCol]] = False
$PossibilityArray[$inRow][$inCol][$aSudArray[$inRow][$inCol]] = 0
EndIf
Next
Next
if $CID = -1 Then
$count = 0
for $aCell = 1 to 9
_SetProgColor()
if $aEnumArray[$aCell] = True Then ;----- Eliminator/ check all = show/hide sb's for every cell in sudoku
GUICtrlSetState($smallbuttons[$h][$i][$aCell-1],$GUI_SHOW)
; for first case solution:
$count = $count + 1
$SolutionsArray[$SolutionsCount][0] = $row
$SolutionsArray[$SolutionsCount][1] = $col
$SolutionsArray[$SolutionsCount][2] = $aCell
; for second case solution:
$PossibilityArray[$row][$col][$aCell] = 1
Else
GUICtrlSetState($smallbuttons[$h][$i][$aCell-1],$GUI_HIDE)
$PossibilityArray[$row][$col][$aCell] = 0
EndIf
Next
if $count = 1 Then ; we found a cell that only has only one possibility!
$SolutionsCount = $SolutionsCount + 1
Else
$SolutionsArray[$SolutionsCount][2] = -1
EndIf
EndIf
Else
; only get here in Eliminator/check all = set data and show large buttons for every cell that has been clicked.
; also hide all small buttons for these same cells so that there's no overlap.
$isSolved = $isSolved + 1
GUICtrlSetData($largebuttons[$h][$i], $aSudArray[$row][$col])
GUICtrlSetState($largebuttons[$h][$i],$GUI_SHOW)
For $aCell = 1 to 9
GUICtrlSetState($smallbuttons[$h][$i][$aCell-1],$GUI_HIDE)
$PossibilityArray[$row][$col][$aCell] = 0
Next
EndIf
Next
Next
while $Progress <> 0
_SetProgColor()
WEnd
Return $isSolved
EndFunc ;==>_SudokuEliminator
Func _SetProgColor() ; credit to PsaltyDS!
if $Progress = 1000 Then
$increment = -1
elseif $Progress = 0 Then
$increment = +1
EndIf
$Progress = $Progress + $increment
If $Progress < 0 Then $Progress = 0
If $Progress > 1000 Then $Progress = 1000
GUICtrlSetData($ProgressBar, Int($Progress / 10))
$Redness = Int(255 - ($Progress / 1000 * 512))
If $Redness < 0 Then $Redness = 0
$Greeness = Int(($Progress / 1000 * 512) - 257)
If $Greeness < 0 Then $Greeness = 0
$Blueness = Int(255 - ($Redness + $Greeness))
$ProgColor = ($Redness * 256 * 256) + ($Greeness * 256) + $Blueness
GUICtrlSetColor($ProgressBar, $ProgColor)
EndFunc ;==>_SetProgColor
Func _GridConvert($x, $y, $var) ;$x = $row = $h, $y = $col = $i
If $var = "row" or $var = "h" Then
Return floor($x / 3)*3 + floor($y / 3)
ElseIf $var = "col" or $var = "i" Then
Return ($x - floor($x/3)*3) * 3 + $y - floor($y/3)*3
EndIf
EndFunc ;==>_GridConvert
Func _CreateSmallButton($h, $i, $j)
Return GUICtrlCreateButton($j + 1, 10 + Mod($h, 3) * 230 + Mod($i, 3) * 70 + Mod($j, 3) * 20, _
10 + Int($h / 3) * 230 + Int($i / 3) * 70 + Int($j / 3) * 20, 20, 20)
EndFunc ;==>_CreateSmallButton
Func _CreateLargeButton($h, $i, $j)
Return GUICtrlCreateButton($j + 1, 10 + Mod($h, 3) * 230 + Mod($i, 3) * 70, _
10 + Int($h / 3) * 230 + Int($i / 3) * 70, 60, 60)
EndFunc ;==>_CreateLargeButton
|
|
|
|
|
|
|
|
Users currently in here |
1 Anonymous
|
|
Powered by JForum - Extended by HVAOnline
hvaonline.net | hvaforum.net | hvazone.net | hvanews.net | vnhacker.org
1999 - 2013 ©
v2012|0504|218|
|
|