AppTux Posted November 27, 2010 Share Posted November 27, 2010 (edited) I made a kind of 'slide to unlock' for Windows. It works, but one problem: not smooth. My code so far: $UL is the slide image. While 1 $hMSG = GUIGetCursorInfo($MGUI) If $hMSG[4] = $UL Then $pos = 1 $hMSG = GUIGetCursorInfo($MGUI) While $hMSG[4] = $UL $hMSG = GUIGetCursorInfo($MGUI) If $hMSG[2] = 1 Then $hMSG = GUIGetCursorInfo($MGUI) $p = MouseGetPos() $pc = $p[0] -22.5 While $hMSG[2] = 1 $hMSG = GUIGetCursorInfo($MGUI) $pos = MouseGetPos() $pos = $pos[0] - $pc GUICtrlSetPos($UL,$pos,$sh - 147.5) If $pos >= $sw - 82.5 Then GUICtrlSetPos($UL,$pos,$sh - 147.5) Exit ElseIf $pos <= 20 Then GUICtrlSetPos($UL,$pos,$sh-147.5) ExitLoop EndIf Sleep(5) WEnd Do GUICtrlSetPos($UL,$pos,$sh-147.5) $pos = $pos - 40 Sleep(5) Until $pos <= 22.5 GUICtrlSetPos($UL,22.5,$sh-147.5) EndIf Sleep(10) WEnd EndIf WEnd A lot of code, but it's needed to get the position on the control etc. Is it possible to make it nice smooth, and how to do? EDIT: Now I use ControlMove() instead of GUICtrlSetPos(). It works smooth. Edited November 27, 2010 by AppTux PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
Zedna Posted November 27, 2010 Share Posted November 27, 2010 Basic antiflicker method is to call functions which update/repaint controls only when needed in your case only when its position changes. So first compare previous control's position with the one you are about to use and call GUICtrlSetPos only if it's different. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
AppTux Posted November 27, 2010 Author Share Posted November 27, 2010 I'll try! PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
AppTux Posted November 27, 2010 Author Share Posted November 27, 2010 I don't know how to get the previous coords of the control in a while, any idea? Because in a while it's always resetting... PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
JoHanatCent Posted November 27, 2010 Share Posted November 27, 2010 Will you not get the same result like so? $MGUI = GUICreate("Test", 300, 300, -1, -1) $UL = GUICtrlCreateSlider(10, 10, 250, 50) GUICtrlSetLimit(-1, 200, 0) GUISetState() GUICtrlSetData($UL, 45) ; set cursor While "Silly" $Pos = GUICtrlRead($UL) Sleep(100) If $Pos >= 182.5 Then MsgBox(0, '', 'Cheers', 1) Exit ElseIf $Pos <= 20 Then ExitLoop EndIf WEnd MsgBox(0, '', 'I''m out of that silly loop', 5) Link to comment Share on other sites More sharing options...
AppTux Posted November 27, 2010 Author Share Posted November 27, 2010 @JoHanatCent Then it's not the same slide to unlock like the iPhone's; like this: That's how it's meaned @Zedna I tried it, but no effect. It's also blinking with the slide back if you haven't slided it to the end. Any other idea's? PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
AppTux Posted November 27, 2010 Author Share Posted November 27, 2010 Now I tried it with ControlMove() It works perfect!!! It perfectly smooth. PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now