Jump to content

maksecret

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by maksecret

  1. I am not facing any such problem.I think that you are not clearing the input field before entering new password. But I may be wrong, if so then try to output the values of password variables and see why the condition is not satisfied? I added one line to auto clear the input field so try this one: #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> #include <Crypt.au3> Global $SW = @DesktopWidth, $SH = @DesktopHeight, $PwdOpen = 0,$Password = IniRead("config.ini", "PS2U", "key", "UNSET") if $Password == "UNSET" Then $Password = InputBox("Set Password","Please type the new password.","","*M",250,130) if @Error = 1 Then Exit EndIf IniWrite("config.ini", "PS2U", "key", _Crypt_HashData($Password,$CALG_MD5)) EndIf $MGUI = GUICreate("WindowSlideToUnlock", $SW, $SH, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor(0x000000, $MGUI) $TOPBACK = GUICtrlCreatePic("images\s2u-b-b.bmp", 0, 0, $SW, 50) $BOTTOMBACK = GUICtrlCreatePic("images\s2u-u-b.bmp", 0, $SH - 250, $SW, 250) $BARLEFT = GUICtrlCreatePic("images\s2u-b-l.bmp", 197.5, $SH - 151, 21, 52) $BARMIDDLE = GUICtrlCreatePic("images\s2u-b-m.bmp", 218.5, $SH - 151, $SW - 437, 52) $BARRIGHT = GUICtrlCreatePic("images\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("images\s2u-b-sign.bmp", ($SW - 35) /2,$SH -250,35,35) $PwdInput = GUICtrlCreateInput("", ($SW - 200) /2,$SH -230,200,50, BitOR ($ES_PASSWORD,$SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetLimit (-1,4) GUICtrlSetBkColor (-1,0xFFFFFF) GUICtrlSetFont (-1, 35-1,"","Lucida Sans") GUICtrlSetColor (-1, 0x000000) _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("images\s2u-p-b.bmp",0,0,250,100, $GUI_DISABLE) $wSlide = GUICreate("HH", 60, 45, 200, $SH - 147.5, $WS_POPUP, $WS_EX_TOPMOST, $MGUI) $slider = GUICtrlCreatePic("images\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,"") 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,"images\s2u-b-sign-inverse.bmp") $PwdOpen = 1 ElseIf $PwdOpen = 1 Then GUICtrlSetImage($ARROW,"images\s2u-b-sign.bmp") $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() ;MsgBox(0, "Selected listbox entry", GUICtrlRead($PwdInput)) If _Crypt_HashData(GUICtrlRead($PwdInput),$CALG_MD5) == $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 GUICtrlSetData($PwdInput,"","") _ShowPassWord() GUICtrlSetBkColor($PwdInput,0xbb0000) EndIf EndFunc ;==>_SLIDEFULL
  2. Hey AppTux, instead of creating a new GUI for the password input field why didn't you add an input control to the main GUI? Adding a control instead of new GUI solves the flickering issues and will also look better. I modified it and also added encrypted password feature. Here is the code with the changes: #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> #include <Crypt.au3> Global $SW = @DesktopWidth, $SH = @DesktopHeight, $PwdOpen = 0,$Password = IniRead("config.ini", "PS2U", "key", "UNSET") if $Password == "UNSET" Then $Password = InputBox("Set Password","Please type the new password.","","*M",250,130) if @Error = 1 Then Exit EndIf IniWrite("config.ini", "PS2U", "key", _Crypt_HashData($Password,$CALG_MD5)) EndIf $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) $PwdInput = GUICtrlCreateInput("", ($SW - 200) /2,$SH -230,200,50, BitOR ($ES_PASSWORD,$SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetLimit (-1,4) GUICtrlSetBkColor (-1,0xFFFFFF) GUICtrlSetFont (-1, 35-1,"","Lucida Sans") GUICtrlSetColor (-1, 0x000000) _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) $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,"") 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") $PwdOpen = 1 ElseIf $PwdOpen = 1 Then GUICtrlSetImage($ARROW,"Data\s2u-b-sign.bmp") $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 _Crypt_HashData(GUICtrlRead($PwdInput),$CALG_MD5) == $Password Then $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 As you can see I haven't done much, just small changes but it does solve the flickering issue.
×
×
  • Create New...