Bru Posted August 3, 2008 Posted August 3, 2008 Well, i am trying to make a pc lock, nothing special, just something as it's my first day back with au3. Say i want to lock my pc, this adds to startup. Then everytime you get this asking for a password. I have two problems, one. expandcollapse popup#include <GUIConstants.au3> Global $pass = IniRead(@DesktopDir & "\pass.ini", "Password", "pass", "") $Form1 = GUICreate("PC-Lock", 292, 209, 521, 216, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) GUISetIcon("D:\Programming\02.07.08 CODING\thermidaicon.ico") $Label1 = GUICtrlCreateLabel("Please enter the correrct password before entering the PC", 8, 8, 277, 17) $Label2 = GUICtrlCreateLabel("Password: ", 8, 48, 56, 17) $Input1 = GUICtrlCreateInput("", 64, 48, 217, 21) $Button1 = GUICtrlCreateButton("Run", 200, 72, 73, 25, 0) $Button3 = GUICtrlCreateButton("OK", 200, 176, 73, 25, 0) $Label3 = GUICtrlCreateLabel("Original: ", 8, 120, 45, 17) $Label4 = GUICtrlCreateLabel("New: ", 8, 152, 32, 17) $Input2 = GUICtrlCreateInput("", 64, 120, 217, 21) $Input3 = GUICtrlCreateInput("", 64, 152, 217, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $entered = GUICtrlRead($Input1) If $pass == $entered Then MsgBox(0, "Correct", "Correct") Else MsgBox(0, "Fail", "Fail") EndIf Case $Button3 $old = GUICtrlRead($Input2) $new = GUICtrlRead($Input3) If $old == $pass Then IniWrite(@DesktopDir & "\pass.ini", "Password", "pass", $new) MsgBox(0, "Done!", "Now please re-open PC-Lock") Exit Else Msgbox(0, "Fail", "The original password does not match.") EndIf EndSwitch WEnd I get an error, The error is. >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Programming\PCLock\main.au3" D:\Programming\PCLock\main.au3 (5) : ==> Variable used without being declared.: $Form1 = GUICreate("PC-Lock", 292, 209, 521, 216, BitAND($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) $Form1 = GUICreate("PC-Lock", 292, 209, 521, 216, BitAND(^ ERROR Now for that, i am trying to get rid of the minimize button. Now my other problem is, when this opens on startup, people could just ignore it! So... How would i set focus on this? So it CANNOT be ignored or got around unless you enter the password! Thank you for your time and help! Bru [right][/right]
Szhlopp Posted August 3, 2008 Posted August 3, 2008 Use an _ infront of the BitOr. It continues the line... BitOr _ (#######) As far as keeping focus on the window, you could do something like this in your while loop: While 1 If WinActive("My Window") <> 1 then WinActivate("My Window") WinFlash ("My Window", "" , 3 ) Endif Wend Thankfully, AutoIt will never be a completely secure "anti-use of computer" program. Anybody can still use Alt-F4 or use the process browser to kill the app. I hope that helps you, Szhlopp RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+'
martin Posted August 3, 2008 Posted August 3, 2008 Well, i am trying to make a pc lock, nothing special, just something as it's my first day back with au3. This will be a bit harder to get round. expandcollapse popup#include <GUIConstants.au3> #include <windowsconstants.au3> #include <editconstants.au3> Global $pass = IniRead(@DesktopDir & "\pass.ini", "Password", "pass", "autoit") ConsoleWrite($pass & @CRLF) Global $restore = False, $passed = False $Form1 = GUICreate("PC-Lock", 292, 209, 521, 216, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS)) GUISetIcon("D:\Programming\02.07.08 CODING\thermidaicon.ico") $Label1 = GUICtrlCreateLabel("Please enter the correct password before entering the PC", 8, 8, 277, 17) $Label2 = GUICtrlCreateLabel("Password: ", 8, 48, 56, 17) $Input1 = GUICtrlCreateInput("", 64, 48, 217, 21) $Button1 = GUICtrlCreateButton("Run", 200, 72, 73, 25, 0) $Button3 = GUICtrlCreateButton("OK", 200, 176, 73, 25, 0) $Label3 = GUICtrlCreateLabel("Original: ", 8, 120, 45, 17) $Label4 = GUICtrlCreateLabel("New: ", 8, 152, 32, 17) $Input2 = GUICtrlCreateInput("", 64, 120, 217, 21) $Input3 = GUICtrlCreateInput("", 64, 152, 217, 21) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE If $passed Then Exit Case $Button1 $entered = GUICtrlRead($Input1) If $pass == $entered Then MsgBox(0, "Correct", "Correct") $passed = True Else MsgBox(0, "Fail", "Fail") EndIf Case $Button3 If $passed Then $old = GUICtrlRead($Input2) $new = GUICtrlRead($Input3) If $old == $pass Then IniWrite(@DesktopDir & "\pass.ini", "Password", "pass", $new) MsgBox(0, "Done!", "Now please re-open PC-Lock") Exit Else MsgBox(0, "Fail", "The original password does not match.") EndIf EndIf EndSwitch If $restore Then $restore = False WinActivate($Form1) WinSetOnTop($Form1, "", 1) EndIf If WinExists("Windows Task Manager") Then WinClose("Windows Task Manager") WEnd Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iCode = BitShift($wParam, 16) Switch $lParam Case GUICtrlGetHandle($Input1) Switch $iCode Case $EN_KILLFOCUS Local $attempt = GUICtrlRead($Input1) If Not $passed And $attempt <> $pass Then $restore = True GUICtrlSetState($Input1, $GUI_FOCUS) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Bru Posted August 3, 2008 Author Posted August 3, 2008 I have successfully done the focus part, But i still get that error, Maybe i am doing it incorrectly, may you write that line of code out again for me to see? Thank you! Bru [right][/right]
martin Posted August 4, 2008 Posted August 4, 2008 I have successfully done the focus part,But i still get that error, Maybe i am doing it incorrectly, may you write that line of code out again for me to see?Thank you!BruNot sure which bit of code you mean. Can you show your latest code? Was the modified version of your code that I posted of any help? It runs without errors for me. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Bru Posted August 4, 2008 Author Posted August 4, 2008 (edited) Infact i don't know what yours does, but here is my latest code. expandcollapse popup#include <GUIConstants.au3> Global $pass = IniRead("C:\WINDOWS\Temp" & "\pass.ini", "Password", "pass", "") $Form1 = GUICreate("PC-Lock", 292, 209, 521, 216, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) GUISetIcon("D:\Programming\02.07.08 CODING\thermidaicon.ico") $Label1 = GUICtrlCreateLabel("Please enter the correrct password before entering the PC", 8, 8, 277, 17) $Label2 = GUICtrlCreateLabel("Password: ", 8, 48, 56, 17) $Input1 = GUICtrlCreateInput("", 64, 48, 217, 21) $Button1 = GUICtrlCreateButton("Run", 200, 72, 73, 25, 0) $Button3 = GUICtrlCreateButton("OK", 200, 176, 73, 25, 0) $Label3 = GUICtrlCreateLabel("Original: ", 8, 120, 45, 17) $Label4 = GUICtrlCreateLabel("New: ", 8, 152, 32, 17) $Input2 = GUICtrlCreateInput("", 64, 120, 217, 21) $Input3 = GUICtrlCreateInput("", 64, 152, 217, 21) GUISetState(@SW_SHOW) While 1 If WinActive("PC-Lock") <> 1 Then WinActivate("PC-Lock") Endif $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Case $Button1 $entered = GUICtrlRead($Input1) If $pass == $entered Then Exit Else MsgBox(0, "Fail", "Fail") EndIf Case $Button3 $old = GUICtrlRead($Input2) $new = GUICtrlRead($Input3) If $old == $pass Then IniWrite("C:\WINDOWS\Temp" & "\pass.ini", "Password", "pass", $new) ShellExecute(@ScriptFullPath) Exit Else Msgbox(0, "Fail", "The original password does not match.") EndIf EndSwitch WEnd ; I still get the same error as before. Thank you, Bru Edited August 4, 2008 by Bru [right][/right]
martin Posted August 4, 2008 Posted August 4, 2008 Infact i don't know what yours does, but here is my latest code.I still get the same error as before.Thank you,BruCould you perhaps try my script? It's a modification of your original post to achieve what I thought you wanted. It includes the addition of an include file which was missing in your script and caused your error, and it stops anyone using the PC until the password has been entered. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
nitekram Posted August 4, 2008 Posted August 4, 2008 Could you perhaps try my script? It's a modification of your original post to achieve what I thought you wanted. It includes the addition of an include file which was missing in your script and caused your error, and it stops anyone using the PC until the password has been entered.what does $EN_KILLFOCUS do or should it equal? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
davecollinsnz Posted August 4, 2008 Posted August 4, 2008 (edited) A while back I made a script that did the same (a security program for me at network parties) but I found that autoit couldn't handle more than 64 hotkeysets in a script. So I made serveral scripts (that were all started by the main script) each with a different set of 64 hotkeysets to capture. I made it so the window was on top and if the focus wasn't its self, it moved the focus to it. I had made the window screen size and disabled taskmanger and the mouse. I also encrypted the password with the same password and then it decrypts the password with the password entered and sees if the two match. After three wrong passwords, the computer blocks all input for 60 seconds, then unlocks. One last security feature which I never got around to coding was that if the program was somehow disabled, another program would start it up again. Edited August 4, 2008 by TheDarkEngineer Trust me to make SkyNet with AutoIt...
TerarinKerowyn Posted August 4, 2008 Posted August 4, 2008 Using WM_KILLFOCUS will alert you of when the users clicks out of your controls domain those the check on that then checking the password if it isn't correct the automatic return back to your application Hence the GUICtrlSetState($Input1, $GUI_FOCUS) Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah
nitekram Posted August 4, 2008 Posted August 4, 2008 Using WM_KILLFOCUS will alert you of when the users clicks out of your controls domain those the check on that then checking the password if it isn't correct the automatic return back to your applicationHence the GUICtrlSetState($Input1, $GUI_FOCUS)When I tried the script, I got an error and it said it was undefined, undeclared global variable. I am looking for where to find more information on it. So that the script would work. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
davecollinsnz Posted August 4, 2008 Posted August 4, 2008 @ nitekram I just ran the code that martin posted and I got no error from it. Are all the includes at the top of your .au3 complete? (ie. did you copy and paste correctly?) Trust me to make SkyNet with AutoIt...
martin Posted August 4, 2008 Posted August 4, 2008 what does $EN_KILLFOCUS do or should it equal?It's defined in editconstants.au3 which is included in the script I posted.It's a notification from the input that it has lost focus. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
nitekram Posted August 4, 2008 Posted August 4, 2008 It's defined in editconstants.au3 which is included in the script I posted. It's a notification from the input that it has lost focus.expandcollapse popupHere is mine - is yours different. Running:(3.2.0.1) #include-once ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.1.1 (beta) ; Language: English ; Description: Edit Constants. ; ; ------------------------------------------------------------------------------ ; Styles Global Const $ES_LEFT = 0 Global Const $ES_CENTER = 1 Global Const $ES_RIGHT = 2 Global Const $ES_MULTILINE = 4 Global Const $ES_UPPERCASE = 8 Global Const $ES_LOWERCASE = 16 Global Const $ES_PASSWORD = 32 Global Const $ES_AUTOVSCROLL = 64 Global Const $ES_AUTOHSCROLL = 128 Global Const $ES_NOHIDESEL = 256 Global Const $ES_OEMCONVERT = 1024 Global Const $ES_READONLY = 2048 Global Const $ES_WANTRETURN = 4096 Global Const $ES_NUMBER = 8192 ;Global Const $ES_DISABLENOSCROLL = 8192 ;Global Const $ES_SUNKEN = 16384 ;Global Const $ES_VERTICAL = 4194304 ;Global Const $ES_SELECTIONBAR = 16777216 ; Error checking Global Const $EC_ERR = -1 ; Messages to send to edit control Global Const $ECM_FIRST = 0X1500 Global Const $EM_CANUNDO = 0xC6 Global Const $EM_EMPTYUNDOBUFFER = 0xCD Global Const $EM_GETFIRSTVISIBLELINE = 0xCE Global Const $EM_GETLINECOUNT = 0xBA Global Const $EM_GETMODIFY = 0xB8 Global Const $EM_GETRECT = 0xB2 Global Const $EM_GETSEL = 0xB0 Global Const $EM_LINEFROMCHAR = 0xC9 Global Const $EM_LINEINDEX = 0xBB Global Const $EM_LINELENGTH = 0xC1 Global Const $EM_LINESCROLL = 0xB6 Global Const $EM_REPLACESEL = 0xC2 Global Const $EM_SCROLL = 0xB5 Global Const $EM_SCROLLCARET = 0x00B7 Global Const $EM_SETMODIFY = 0xB9 Global Const $EM_SETSEL = 0xB1 Global Const $EM_UNDO = 0xC7 Global Const $EM_SETREADONLY = 0x00CF Global Const $EM_SETTABSTOPS = 0x00CB 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
martin Posted August 4, 2008 Posted August 4, 2008 (edited) expandcollapse popupHere is mine - is yours different. Running:(3.2.0.1) #include-once ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.1.1 (beta) ; Language: English ; Description: Edit Constants. ; ; ------------------------------------------------------------------------------ ; Styles Global Const $ES_LEFT = 0 Global Const $ES_CENTER = 1 Global Const $ES_RIGHT = 2 Global Const $ES_MULTILINE = 4 Global Const $ES_UPPERCASE = 8 Global Const $ES_LOWERCASE = 16 Global Const $ES_PASSWORD = 32 Global Const $ES_AUTOVSCROLL = 64 Global Const $ES_AUTOHSCROLL = 128 Global Const $ES_NOHIDESEL = 256 Global Const $ES_OEMCONVERT = 1024 Global Const $ES_READONLY = 2048 Global Const $ES_WANTRETURN = 4096 Global Const $ES_NUMBER = 8192 ;Global Const $ES_DISABLENOSCROLL = 8192 ;Global Const $ES_SUNKEN = 16384 ;Global Const $ES_VERTICAL = 4194304 ;Global Const $ES_SELECTIONBAR = 16777216 ; Error checking Global Const $EC_ERR = -1 ; Messages to send to edit control Global Const $ECM_FIRST = 0X1500 Global Const $EM_CANUNDO = 0xC6 Global Const $EM_EMPTYUNDOBUFFER = 0xCD Global Const $EM_GETFIRSTVISIBLELINE = 0xCE Global Const $EM_GETLINECOUNT = 0xBA Global Const $EM_GETMODIFY = 0xB8 Global Const $EM_GETRECT = 0xB2 Global Const $EM_GETSEL = 0xB0 Global Const $EM_LINEFROMCHAR = 0xC9 Global Const $EM_LINEINDEX = 0xBB Global Const $EM_LINELENGTH = 0xC1 Global Const $EM_LINESCROLL = 0xB6 Global Const $EM_REPLACESEL = 0xC2 Global Const $EM_SCROLL = 0xB5 Global Const $EM_SCROLLCARET = 0x00B7 Global Const $EM_SETMODIFY = 0xB9 Global Const $EM_SETSEL = 0xB1 Global Const $EM_UNDO = 0xC7 Global Const $EM_SETREADONLY = 0x00CF Global Const $EM_SETTABSTOPS = 0x00CB Very different. Your version is very old and I am using the latest version, (or it was last week). You can simply add this though to get it working Global Const $EN_KILLFOCUS = 0x200 ;Global Const $EN_SETFOCUS = 0x100 Edited August 4, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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