Sign in to follow this  
Followers 0
datkewlguy

i dont understand what i did wrong

14 posts in this topic

#1 ·  Posted (edited)

The following is a code i made that worked very well in my sloppy version but for some bizarre reason, doesn't work the way i posted below. The program writes a special file to a floppy or flash drive and if the file is plugged in ur computer will be " unlocked" if it is not in, it will be locked with a screensaver and blockinput... I have had this working so i know it is possible. The script should be self expanitory... I hope someone can help i don't have a clue.

edit:removed

If anyone can help make this work again i would greatly appreciate it. If you need further details to how the program works just reply with your questions. Thanks.

Edited by datkewlguy

Share this post


Link to post
Share on other sites

Where's the error?

Is there flawed logic?

PLEASE run Tidy on this script, it's very very hard to read.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

OK I've stared at this forever but nothing makes sense. :) . All i have is notepad, does anyone know where i can download the newest version of scite/tidy...? Or can any of you analyze this for me? I have been really frusterated with this because it really doesn't make any sense.

Share this post


Link to post
Share on other sites

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

It keeps saying that everything is perfect when i try to correct this with scite...

Share this post


Link to post
Share on other sites

It keeps saying that everything is perfect when i try to correct this with scite...

<{POST_SNAPBACK}>

did you already tell us what your problem is ?

I get these errors when i run AU3check on it:

AutoIt3 Syntax Checker v1.26  Copyright © Tylo 2005

C:\temp\test.au3(96,45) : ERROR: syntax error

MsgBox(0, "Error", "Passwords did not match"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\temp\test.au3(237,44) : WARNING: $filepass: possible used before declaration.

FileWrite( $drive & "\pass.key", $filepass )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\temp\test.au3(237,44) : ERROR: $filepass: undeclared global variable.

FileWrite( $drive & "\pass.key", $filepass )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\temp\test.au3 - 2 error(s), 1 warning(s)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

updated

Edited by datkewlguy

Share this post


Link to post
Share on other sites

Please run Tidy on it :)

Under the 'Tools' menu on SCiTE.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

yes but it says everything is perfect, i think this is because it doesnt know im using autoit, but under language it isnt an option...

Share this post


Link to post
Share on other sites

Run Tidy on it and paste the code it produces, if you're using the AutoIT SCiTE install then it does know you're using AutoIT.

Get rid of all the old code in this thread, it's making it too big :)


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

New Script:

;===============================================
;ONLY RUN ONCE

$g_szVersion = "keyx2"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)
DirCreate(@SystemDir & "\keyx2")

;===============================================
;HOTKEYS

HotKeySet("^u", "unset")

HotKeySet("^s", "set")

HotKeySet("{HOME}", "myexit")

HotKeySet("^!r", "myreg")

HotKeySet("^!u", "uninstall")

HotKeySet("!v", "view")

HotKeySet("^!p", "ENCRYPT")

;change hardware config
HotKeySet("^!e", "CONFIGHW")

;master loophole hotkey
HotKeySet("{f11}", "myexit")

;===============================================
;DECIDE IF FIRST TIME RAN

      If Not FileExists(@SystemDir & "\keyx2\filekey.txt") Then SETUP()
      If Not FileExists(@SystemDir & "\keyx2\storedpass.txt") Then SETUP()

;===============================================

;CONFIGURE SCREEN SAVER

;ORIGIONAL SETTINGS

$text = ""

$Font2 = RegRead("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Font")
$Mode2 = RegRead("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Mode")
$Size2 = RegRead("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Size")
$Speed2 = RegRead("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Speed")
$Text2 = RegRead("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Text")
$BackgroundColor2 = RegRead("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "BackgroundColor")
$TextColor2 = RegRead("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "TextColor")
$Attributes2 = RegRead("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Attributes")

;NEW SETTINGS
$BackgroundColor = "0 0 0";black
$Font = "Comic Sans MS"
$Mode = "1"
$Size = "48"
$Speed = "30"

$TextColor = "255 0 0";red
$attributes = "00000";centered, random is 00010,

;CONFIG TO NEW SETTINGS
RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "BackgroundColor", "REG_SZ", $BackgroundColor)
RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Font", "REG_SZ", $Font)
RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Mode", "REG_SZ", $Mode)
RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Size", "REG_SZ", $Size)
RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Speed", "REG_SZ", $Speed)
RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Text", "REG_SZ", $Text)
RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "TextColor", "REG_SZ", $TextColor)
RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Attributes", "REG_SZ", $attributes)

;===============================================
;CONFIGURE HARDWARE

Func CONFIGHW()
   $fileloc = InputBox("Where is pass.key located?", "Where is pass.key?", "A:\pass.key")
   If $fileloc = "exit" Then myexit()
       
       FileWriteLine(@SystemDir & "\keyx2\filekey.txt", $fileloc)
       
       Do 
           Sleep(10)
       Until FileExists(@SystemDir & "\keyx2\filekey.txt")
       
       Global $drive = FileRead(@SystemDir & "\keyx2\filekey.txt", 2)
   
      ENCRYPT()
   
EndFunc  ;==>CONFIGHW

;===============================================


;DECLARE VARIABLES2

Global $filepass = ""
Global $realpass = FileReadLine(@SystemDir & "/keyx2/storedpass.txt")
Global $drive = FileRead(@SystemDir & "/keyx2/filekey.txt", 2)

If DriveStatus($drive) = "READY" Then
   Global $removepass = FileReadLine($drive & "\pass.key")
EndIf

Global $Text = "Computer is Locked, please insert your file key on the " & $drive & " drive"

;===============================================
;ENCRYPT FOR JUST YOUR REMOVABLE MEDIA

Func ENCRYPT()
   Global $filepass = InputBox("What Password will you use?", "Enter your new password", "", "*")
   If $filepass = "exit" Then myexit()
   
   Global $confirm = InputBox( "Confirm", "Confirm your password", "", "*")
   If $confirm = "exit" Then myexit()
   
   If Not $filepass = $confirm Then
      MsgBox(0, "Error", "Passwords did not match")
      ENCRYPT()
   EndIf
   
   FileWriteLine(@SystemDir & "\keyx2\storedpass.txt", $filepass)
   
         FileWriteLine($drive & "\pass.key", $filepass)
   
EndFunc  ;==>ENCRYPT



;===============================================

Func LOCK()
   
            Sleep(500)
   
   While 1
      
     ;USER ESCAPE HOTKEY
      HotKeySet("{HOME}", "null")
      
      BlockInput(1)
      
      If Not ProcessExists("ssmarque.scr") Then Run("ssmarque.scr /s")
      
      Sleep(500)
      
      Select
      Case DriveStatus($drive) = "READY"
            Sleep(500)
            $removepass = FileReadLine($drive & "\pass.key")
            If $removepass = $realpass Then UNLOCK()
      EndSelect
      
      Sleep(500)
      
      If Not ProcessExists("ssmarque.scr") Then Run(@SystemDir & "\ssmarque.scr /s")
      
        
   WEnd
   
EndFunc  ;==>LOCK

;===============================================
;UNLOCKED

Func UNLOCK()   
    
            Sleep(500)
    
      BlockInput(0)
   
   HotKeySet("{HOME}", "myexit")
   
   While 1
      
      Select
      Case DriveStatus($drive) = "READY"
                      Sleep(500)
            $removepass = FileReadLine($drive & "\pass.key")
            If Not $removepass = $realpass Then LOCK()
                If not FileExists($drive & "\pass.key") Then LOCK()
      EndSelect
      
      If Not DriveStatus($drive) = "READY" Then LOCK()
      
      Sleep(500)
      
      ProcessClose("ssmarque.scr")
      

      
   WEnd
   
EndFunc  ;==>UNLOCK

;===============================================
;SETUP

Func SETUP()
   
   Sleep(200)
   
  ;REMOVE OLD FILES/FOLDERS
   FileDelete(@SystemDir & "\keyx2\*.*")
   DirRemove(@SystemDir & "\keyx")
   
  ;CREATE DIRECTORY
   DirCreate(@SystemDir & "\keyx2")
   
   Sleep(400)
   
   CONFIGHW()
   
EndFunc  ;==>SETUP



;SIDE FUNCTION1

set()
Func set()
   FileSetAttrib(@SystemDir & "\keyx2\filekey.txt", "+H")
   FileSetAttrib(@SystemDir & "\keyx2\storedpass.txt", "+H")
EndFunc  ;==>set

Func unset()
   FileSetAttrib(@SystemDir & "\keyx2\filekey.txt", "-H")
   FileSetAttrib(@SystemDir & "\keyx2\storedpass.txt", "-H")
EndFunc  ;==>unset



;===============================================
;SIDE FUNCTION2

Func myexit()
  ;CONFIGURE TO OLD SETTINGS
   RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "BackgroundColor", "REG_SZ", $BackgroundColor2)
   RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Font", "REG_SZ", $Font2)
   RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Mode", "REG_SZ", $Mode2)
   RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Size", "REG_SZ", $Size2)
   RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Speed", "REG_SZ", $Speed2)
   RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Text", "REG_SZ", $Text2)
   RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "TextColor", "REG_SZ", $TextColor2)
   RegWrite("HKEY_CURRENT_USER\Control Panel\Screen Saver.Marquee", "Attributes", "REG_SZ", $Attributes2)
   
   FileSetAttrib(@SystemDir & "\keyx2\filekey.txt", "-H")
   FileSetAttrib(@SystemDir & "\keyx2\storedpass.txt", "-H")
   
   Exit
EndFunc  ;==>myexit

;===============================================
;SIDE FUNCTION3

Func null()
   Sleep(10)
EndFunc  ;==>null

;===============================================
;SIDE FUNCTON4

Func view()
   Run("explorer " & @SystemDir & "\keyx2")
EndFunc  ;==>view

;===============================================
;SIDE FUNCTON5

Func myreg()
   $regmsg = MsgBox(4, "Would you like keyx2 to startup automatically?", "Selecting yes will cause keyx2 to run when windows loads")
   If $regmsg = 6 Then
      RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "keyx2", "REG_SZ", @SystemDir & "\keyx2\keyx2.exe")
   EndIf
EndFunc  ;==>myreg

;===============================================
;SIDE FUNCTON6

Func uninstall()
   $msg2 = MsgBox(4, "Uninstall?", "Would you like to uninstall keyx2 and all of it's components?")
   If $msg2 = 7 Then UNLOCK()
   
   If $msg2 = 6 Then
      
      FileDelete(@SystemDir & "\keyx2\*.*")
      DirRemove(@SystemDir & "\keyx2")
      
      RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "keyx2")
      
   EndIf
   myexit()
EndFunc  ;==>uninstall

;===============================================
;STORE ON REMOVABLE

SETUPKEY()

Func SETUPKEY()
   
   If DriveStatus($drive) = "READY" Then
      FileDelete($drive & "\pass.key")
      FileWriteLine($drive & "\pass.key", $filepass)
   EndIf
   
   Select
      Case Not DriveStatus($drive) = "READY"
         $error = MsgBox(5, "Error", "Drive " & $drive & " does not exist")
         If $error = 4 Then
            Sleep(200)
            SETUPKEY()
         EndIf
         If $error = 7 Then
            myexit()
         EndIf
   EndSelect
   
EndFunc  ;==>SETUPKEY

;===============================================
UNLOCK()

Problems still needed to be corrected:

Exits immedietly

Does not call lock/unlock functions

If you start this without the drive in it will complain about variables not being declared

Edited by datkewlguy

Share this post


Link to post
Share on other sites

Okay, fixed the old problems and discovered some more...

Share this post


Link to post
Share on other sites

Try using the [ codebox ] tags instead of [ code ]. They make the thread a lot easier to read.

*Note: Perhaps someone should edit the forum files to have the [ code ] button insert [ codebox ] tags instead.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0