Things annoying me:
- Fade in is slow on my PC, but I heard from other people it's not on theirs.
- Timer so you have to hold it right for a few seconds still doesn't work.
Things I want to do:
- Password usage (HALF DONE see Edit 15-02-2011)
- Let the window always stay on top (DONE)
If you know how to fix it or you have any suggestions, please let me know!!
Together we can make it way better
If you don't understand something of the code, let me know and I'll explain.
EDIT: News: I'm gonna rewrite the whole code. So any help will be appreciated!
Code and Images:
PS2U.zip 134.46KB
633 downloadsEDIT:
Made the slider bar a bit smaller for lazy guys.
End animations same as the start animations
Please use the updated code below this instead of the one in the attachment or you won't have the edited parts.
EDIT 14-02-2011:
-The Bars are a bit transparent;
-The program don't use screenshots anymore: The bars are a window with transparency of 250, the 'overlay' so you can't touch the windows behind has a transparency of 1
-Deleted some comments
EDIT/UPDATE 15-02-2011:
-Added Password protection (still hard coded in script, so it's easy to hack so far
-Window always stays on top
I think I'm gonna focus on the clarity of the code, because in my opinion the code is not so clear
The most updated code: (not included in the .zip, just too lazy for that)
#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GUIEdit.au3> #include <StaticConstants.au3> #include <String.au3> #include <WinAPI.au3> #include <Timers.au3> Global $SW = @DesktopWidth, $SH = @DesktopHeight, $PwdOpen = 0, $Password = "1234" $MGUI = GUICreate("WindowSlideToUnlock", $SW, $SH, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor(0x000000, $MGUI) $TOPBACK = GUICtrlCreatePic("Data\s2u-b-b.bmp", 0, 0, $SW, 50) $BOTTOMBACK = GUICtrlCreatePic("Data\s2u-u-b.bmp", 0, $SH - 250, $SW, 250) $BARLEFT = GUICtrlCreatePic("Data\s2u-b-l.bmp", 197.5, $SH - 151, 21, 52) $BARMIDDLE = GUICtrlCreatePic("Data\s2u-b-m.bmp", 218.5, $SH - 151, $SW - 437, 52) $BARRIGHT = GUICtrlCreatePic("Data\s2u-b-r.bmp", $SW - 223.5, $SH - 151, 21, 52) $BARLABEL = GUICtrlCreateLabel("Fill in Password", 200, $SH - 151, $SW - 400, 52, $SS_NOTIFY & $SS_CENTER) $TIME = GUICtrlCreateLabel("", ($SW - 100) /2, 2, 100, 45, $SS_NOTIFY & $SS_CENTER) $ARROW = GUICtrlCreatePic("Data\s2u-b-sign.bmp", ($SW - 35) /2,$SH -250,35,35) _SETSTATEANDFONT() _SETTHETIME() WinSetTrans($MGUI, "", 0) ;---Create overlay window so you can't touch the window behind $OVERLAY = GUICreate("Overlay",$SW,$SH - 300,0, 50, $WS_POPUP, $WS_EX_TOPMOST, $MGUI) WinSetTrans($OVERLAY, "",1) GUISetState(@SW_SHOW, $OVERLAY) $TOPRGN = _WinAPI_CreateRectRgn(0,0,$SW,50) $BOTTOMRGN = _WinAPI_CreateRectRgn(0,$SH - 250,$SW, $SH) _WinAPI_CombineRgn($TOPRGN, $TOPRGN, $BOTTOMRGN,$RGN_OR) _WinAPI_SetWindowRgn($MGUI,$TOPRGN) GUISetState(@SW_SHOW, $MGUI) $PwdGui = GUICreate("Password input",250,100,-1,$SH - 348, $WS_POPUP, $WS_EX_TOPMOST, $MGUI) GUISetBkColor(0x000000,$PwdGui) $PwdBack = GUICtrlCreatePic("Data\s2u-p-b.bmp",0,0,250,100, $GUI_DISABLE) $PwdInput = GUICtrlCreateInput("", 25,10,200,60, BitOR ($ES_PASSWORD,$SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetLimit (-1,4) GUICtrlSetBkColor (-1,0xFFFFFF) GUICtrlSetFont (-1, 35-1,"","Lucida Sans") GUICtrlSetColor (-1, 0x000000) WinSetTrans("Password input","",250) GUISetState(@SW_HIDE, $PwdGui) $wSlide = GUICreate("HH", 60, 45, 200, $SH - 147.5, $WS_POPUP, $WS_EX_TOPMOST, $MGUI) $slider = GUICtrlCreatePic("Data\s2u-b-u.bmp", 0, 0, 60, 45) WinSetTrans($wSlide,"",0) GUISetState(@SW_HIDE, $wSlide) For $TRANS = 0 To 250 Step 15 WinSetTrans($wSlide, "", $TRANS) WinSetTrans($MGUI, "", $TRANS) If $TRANS >= 250 Then ExitLoop EndIf Next WinSetTrans($MGUI, "", 250) While 1 If $PwdOpen = 0 Then If Not WinActive ($MGUI,"") Then WinActivate ($MGUI,"") Else If Not WinActive ($PwdGui,"") Then WinActivate ($PwdGui,"") EndIf If StringLen(GUICtrlRead($PwdInput)) = 4 Then If GUICtrlRead($BARLABEL) <> "Slide To Unlock" Then GUICtrlSetData($BARLABEL,"Slide To Unlock") GUISetState(@SW_SHOW, $wSlide) EndIf Else If GUICtrlRead($BARLABEL) <> "Fill in Password" Then GUICtrlSetData($BARLABEL,"Fill in Password") GUISetState(@SW_HIDE, $wSlide) EndIf EndIf _SETTHETIME() $MINFO = GUIGetCursorInfo($wSlide) $hMsg = GUIGetMsg() If $hMsg = $ARROW Then _ShowPassWord() ElseIf $hMsg = $GUI_EVENT_CLOSE Then Exit EndIf If $MINFO[4] = $slider Then $POS = 1 $MINFO = GUIGetCursorInfo($wSlide) While $MINFO[4] = $slider $MINFO = GUIGetCursorInfo($wSlide) If $MINFO[2] = 1 Then $MINFO = GUIGetCursorInfo($wSlide) $MPOS = MouseGetPos() ConsoleWrite($MPOS[0] & @CRLF) $CONTROLPOS = $MPOS[0] - 200 While $MINFO[2] = 1 $MINFO = GUIGetCursorInfo($wSlide) $POS = MouseGetPos() $POS = $POS[0] - $CONTROLPOS If $POS <= 200 Then WinMove("HH", "", 200, $SH - 147.5) ElseIf $POS >= $SW - 265 Then WinMove($wSlide, "", $SW - 265, $SH - 147.5) _Timer_SetTimer($MGUI,1000, _SLIDEFULL(),-1) Else WinMove("HH", "", $POS, $SH - 147.5) EndIf Sleep(5) WEnd Do WinMove("HH", "", $POS, $SH - 147.5) $POS = $POS - 40 Sleep(5) Until $POS <= 200 WinMove("HH", "", 200, $SH - 147.5) EndIf Sleep(10) WEnd EndIf Sleep(1) WEnd Func _ShowPassWord() ConsoleWrite("_ShowPassWord() function called"&@CR) If $PwdOpen = 0 Then GUICtrlSetImage($ARROW,"Data\s2u-b-sign-inverse.bmp") GUISetState(@SW_SHOW, $PwdGui) $PwdOpen = 1 ElseIf $PwdOpen = 1 Then GUICtrlSetImage($ARROW,"Data\s2u-b-sign.bmp") GUISetState(@SW_HIDE, $PwdGui) $PwdOpen = 0 EndIf EndFunc Func _SETSTATEANDFONT() GUICtrlSetColor($BARLABEL, 0x373737) GUICtrlSetBkColor($BARLABEL, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont($BARLABEL, 21, 400, "", "Lucida Sans") GUICtrlSetBkColor($TIME, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont($TIME, 20, 400, "", "Lucida Sans") GUICtrlSetColor($TIME, 0xFFFFFF) For $X = $TOPBACK To $BARRIGHT GUICtrlSetState($X, $GUI_DISABLE) Next EndFunc ;==>_SETSTATEANDFONT Func _SETTHETIME() $MIN = @MIN $HOUR = @HOUR $T = GUICtrlRead($TIME) If $T <> $HOUR &":"& $MIN Then GUICtrlSetData($TIME, $HOUR&":"&$MIN) EndIf EndFunc ;==>_SETTHETIME Func _SLIDEFULL() If GUICtrlRead($PwdInput) = $Password Then GUISetState(@SW_HIDE, $PwdGui) $TRANS = 250 For $TRANS = 250 To 0 Step -25 WinSetTrans($wSlide, "", $TRANS) WinSetTrans($MGUI, "", $TRANS) ConsoleWrite($TRANS&@CR) If $TRANS <= 0 Then ExitLoop EndIf Next Exit Else $PwdOpen = 0 _ShowPassWord() GUICtrlSetBkColor($PwdInput,0xbb0000) EndIf EndFunc ;==>_SLIDEFULL
For the 2nd time: Suggestions are welcome!!
All the files are in the Attachments
Edited by AppTux, 25 March 2011 - 12:46 PM.





