Jump to content

LANCR


CodyBarrett
 Share

Recommended Posts

Ok here... i made a program that uses well its somewhat like LAN... it uses a file that (must hardcode it in) is on a shared network drive.... yeah i use it for school and it has NOTHING to do with TCP...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=\\Svrss1\RSUsers\barrettc\My Documents\Mail.ico
#AutoIt3Wrapper_outfile=J:\Transfer\oogabooga\LANCR.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=Used For Shared DRIVES And Also A Substitute For TCP
#AutoIt3Wrapper_Res_Description=LAN ChatRoom
#AutoIt3Wrapper_Res_Fileversion=0.2.3.71
#AutoIt3Wrapper_Res_LegalCopyright=Bob
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         Bob

 Script Function:
    ChatRoom For Shared Drives \ Substitute For TCP
    
#ce ----------------------------------------------------------------------------
#Include <GUIConstantsEx.Au3>
#Include <WindowsConstants.Au3>
#Include <EditConstants.Au3>
#Include <StaticConstants.Au3>
#Include <Misc.Au3> 
#Include <GUIEdit.Au3>
#Include <Date.Au3>
#Include <Array.au3>
#include <ScrollBarConstants.au3>
#include <ProgressConstants.au3>
#Include <String.au3>
#Include <Timers.au3>
#Include <File.au3>

Opt ('GUIOnEventMode',1)

If WinExists ('LANCR - [ LAN CHATROOM ]') Then Exit

Global $LANCR_Settings_Ini = @ScriptDir & '\LANCR - Settings.ini'
Global $File_Name = IniRead ($LANCR_Settings_Ini,'{-Global-}','File_Path','')

$GUI = GUICreate ('LANCR - [ LAN CHATROOM ]', 300, 320, -1, -1, 1, 138)
$Menu = GUICtrlCreateMenu ('[ - File - ]')
$Font_Menu = GUICtrlCreateMenuItem ('- Font -',$Menu)
$Bk_Color_Menu = GUICtrlCreateMenuItem ('- Bk Color -',$Menu)
$Exit_Menu = GUICtrlCreateMenuItem ('- Exit -',$Menu)
$Exit_Button = GUICtrlCreateButton (' X ',270,5,20,20)
$Minimize_Button = GUICtrlCreateButton (' _ ',250,5,20,20)
$Name_Input = GUICtrlCreateInput (IniRead ($LANCR_Settings_Ini, '{-Global-}','Client_Name',''),5,5,180,20,1)
$Connect_Button = GUICtrlCreateButton ('Connect',190,5,55,20)
$Main = GUICtrlCreateEdit ('',5,30,285,195,2103360)
$Send = GUICtrlCreateEdit ('',5,230,245,40,2101248)
$Send_Button = GUICtrlCreateButton ('Send',250,230,40,40)
$File_Read = FileRead ($File_Name)
$Ini_Font_Name = IniRead ($LANCR_Settings_Ini,'{-Global-}','Font_Name','')
$Ini_Font_Size = IniRead ($LANCR_Settings_Ini,'{-Global-}','Font_Size','')
$Ini_Font_Color = IniRead ($LANCR_Settings_Ini,'{-Global-}','Font_Color','')
$Ini_Bk_Color = IniRead ($LANCR_Settings_Ini,'{-Global-}','Bk_Color','')
        
GUICtrlSetFont ($Main,10,'','','Courier New')
GUICtrlSetColor ($Main,0xFFFFFF)
GUICtrlSetBkColor ($Main,0x000000)
GUICtrlSetFont ($Send,10,'','','Courier New')
GUICtrlSetColor ($Send,0xFFFFFF)
GUICtrlSetBkColor ($Send,0x000000)

GUICtrlSetOnEvent ($Font_Menu,'Font')
GUICtrlSetOnEvent ($Bk_Color_Menu,'Bk_Color')
GUICtrlSetOnEvent ($Exit_Menu,'_Exit')
GUICtrlSetOnEvent ($Connect_Button, 'Connect')
GUICtrlSetOnEvent ($Send_Button,'_Send')
GUICtrlSetOnEvent ($Minimize_Button, 'Minimize')
GUICtrlSetOnEvent ($Exit_Button, '_Exit')
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')

If FileExists ($LANCR_Settings_Ini) Then
    
    GUICtrlSetData ($Main, $File_Read)  
    GUICtrlSetBkColor ($Main,0X808080)
    GUICtrlSetBkColor ($Send,0X808080)
    GUICtrlSetColor ($Main,0X808080)
    GUICtrlSetColor ($Send,0X808080)
    GUICtrlSetState ($Main,@SW_DISABLE)
    GUICtrlSetState ($Send,@SW_DISABLE)
    GUICtrlSetState ($Send_Button,$GUI_DISABLE)
    GUICtrlSetState ($Send,$GUI_FOCUS)
    GUISetState (@SW_HIDE, $GUI)
    GUISetState (@SW_SHOW, $GUI)
    
Else

    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Client_Name',' ')
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Font_Name','Courier New')
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Font_Size','10')
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Font_Color','0xFFFFFF')
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Bk_Color','0x000000')
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','File_Path',@ScriptDir & '\LANCR-LOG.txt')
    Run ('notepad','',@SW_MAXIMIZE)
    WinWaitActive ('Untitled - Notepad')
    Send ('DO THESE STEPS EXACTLY!' & @CRLF & '1) Open LANCR - Settings.ini' & @CRLF & '2) Make This:'& @CRLF & 'File_Path=J:\Transfer\oogabooga\LANCR-LOG.txt' & @CRLF & '3)Run LANCR.exe Again')
    
    
EndIf
        


$Connection_Status = 0
$Admin_Status = 0

While 1 
    
    $i = 0
    $File_Read = FileRead ($File_Name)
            
    If GUICtrlRead ($Main) <> $File_Read Then
        
        GUICtrlSetData ($Main, $File_Read)
        
    EndIf
    
    If $Connection_Status = 1 Then
        
        If FileExists ($File_Name) Then 
            
            ;If StringInStr ($File_Read,'{Boot=(USERNAME ).}') Then StringReplace (StringReplace ($File_Read,'{Boot=(',''),')','')
            
            If StringInStr ($File_Read,'{Boot=(' & GUICtrlRead ($Name_Input) & ').}') Or StringInStr ($File_Read,'{Boot=(' & @UserName & ').}') Then _Exit ()
            
            FileSetAttrib ($File_Name,'+h')
        
        Else
        
            _Exit ()
        
        EndIf
    
    EndIf

    _GUICtrlEdit_Scroll ($Main,$SB_SCROLLCARET)
    Sleep (100)

WEnd

Func Bk_Color ()
    
    $i = _ChooseColor (2,0,2,$GUI)
    GUICtrlSetBkColor ($Main,$i)
    GUICtrlSetBkColor ($Send,$i)
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Bk_Color',$i)
    
EndFunc

Func Connect ()

    If StringInStr ( GUICtrlRead ($Name_Input), 'Admin') Then 
        
    Else
        
        If StringInStr ( GUICtrlRead ($Name_Input), 'Name') Or StringInStr ( GUICtrlRead ($Name_Input), ' ') Or StringInStr ( GUICtrlRead ($Name_Input), @CRLF ) Then
                    
        Else
        
            FileWrite ($File_Name, GUICtrlRead ($Name_Input) & ' Has Joined The Room!' & @CRLF & GUICtrlRead ($Name_Input) & ' = ' & @UserName & @CRLF)
            IniWrite ($LANCR_Settings_Ini, '{-Global-}','Client_Name',GUICtrlRead ($Name_Input) )
            $File_Read = FileRead ($File_Name)
            $Connection_Status = 1
            GUICtrlSetData ($Main, $File_Read)  
            GUICtrlSetState ($Send_Button,$GUI_ENABLE)
            GUICtrlSetFont ($Main,$Ini_Font_Size,'','',$Ini_Font_Name)
            GUICtrlSetFont ($Main,$Ini_Font_Size,'','',$Ini_Font_Name)
            GUICtrlSetColor ($Main,$Ini_Font_Color)
            GUICtrlSetColor ($Send,$Ini_Font_Color)
            GUICtrlSetBkColor ($Main,$Ini_Bk_Color)
            GUICtrlSetBkColor ($Send,$Ini_Bk_Color)
            GUICtrlSetState ($Connect_Button, $GUI_DISABLE)
            GUICtrlSetState ($Name_Input, $GUI_DISABLE)
            GUICtrlSetState ($Send,$GUI_FOCUS)
            
        EndIf

    EndIf

EndFunc

Func _FileDelete ()
    
    FileDelete ($File_Name)
    
EndFunc

Func Font ()
    
    $i = _ChooseFont ($Ini_Font_Name,$Ini_Font_Size,$Ini_Font_Color,'','','','',$GUI)
        
    GUICtrlSetFont ($Main,$i[3],'','',$i[2])
    GUICtrlSetColor ($Main,$i[7])
    GUICtrlSetFont ($Send,$i[3],'','',$i[2])
    GUICtrlSetColor ($Send,$i[7])
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Font_Name',$i[2])
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Font_Size',$i[3])
    IniWrite ($LANCR_Settings_Ini, '{-Global-}','Font_Color',$i[7])
    
EndFunc

Func Minimize ()
    
    GUISetState (@SW_MINIMIZE, $GUI)
    
EndFunc

Func _Send ()

    If GUICtrlRead ($Send) <> '' Then 
        
        If $Admin_Status = 1 Then

            If StringInStr ( GUICtrlRead ($Send),'{Boot=(') Or StringInStr ( GUICtrlRead ($Send),'{CurrentUserNames.}') Then
                
                If $Admin_Status >= 0 Then
            
                    FileWrite ($File_Name, GUICtrlRead ($Send) & @CRLF)
                        
                EndIf
                    
            Else
                    
            FileWrite ($File_Name, '[ - Admin - ] ' &  GUICtrlRead ($Name_Input) & ' ~ ' & GUICtrlRead ($Send) & @CRLF)
            
            If StringInStr ( GUICtrlRead ($Send),'{FileDelete.}') Then _FileDelete ()
            
            EndIf


        Else
            
            If StringInStr ( GUICtrlRead ($Send),'{APASS=(')  Then
            
                $Admin_Password = StringReplace ( StringReplace (GUICtrlRead ($Send),'{APASS=(',''),').}','')
            
                If $Admin_Password = 'tbhoeb' Then
                
                    FileWrite ($File_Name, GUICtrlRead ($Name_Input) & ' ~ Is Now An Administrator.' & @CRLF)
                    $Admin_Status = 1

                EndIf

            Else    

                If StringInStr ( GUICtrlRead ($Send),'{Boot=(') Then

                    GUICtrlSetData ($Send, '')
                    GUICtrlSetState ($Send,$GUI_FOCUS)

                EndIf
                
                FileWrite ($File_Name, GUICtrlRead ($Name_Input) & ' ~ ' & GUICtrlRead ($Send) & @CRLF)
                
            EndIf

        EndIf
        
        GUICtrlSetData ($Send, '')
        GUICtrlSetState ($Send,$GUI_FOCUS)
        
    EndIf
    
EndFunc

Func _Exit ()
    
    If $Connection_Status = 1 and FileExists ($File_Name) Then FileWrite ($File_Name, GUICtrlRead ($Name_Input) & ' Has Left The Room.' & @CRLF)
    Exit
    
EndFunc

WORKING ON....

*Client Disconnection - Stringinstr() manipulation (WONT TAKE LONG)

*Faster Updatinging of main Edit Control

*Non HARDCODED Path To File (INI.. easy)

Edited by CodyBarrett
Link to comment
Share on other sites

:unsure: hello again guys OK i made new version and Funtions include :

* Boots Clients on chosen name OR @USERNAME

*Client is Banned untill .txt is deleted

*IniFile has Path to ANYWHERE you want

*Font & Bkcolor is changeable

*Can only connect once (old version clients could spam)

*ADMINISTRATOR status is changed by typing {apass=(tbhoeb).}

*remotely delete file with {FileDelete.} ONLY If your ADMIN

*Booting {boot=(clientname).}

*can be specified HARDCODED the @USERNAME to NEVER be banned

well thats about it for this version :D what you guys think :P

EDIT

sorry forgot to add that NEW SCRIPT is in 1st post

Edited by CodyBarrett
Link to comment
Share on other sites

  • 2 weeks later...

It would be very useful to add a simple encyption as some other people in my class want to read the stuff that I'm writing to my friend.

Another point: If the teacher finds the chat-file on the server he/she won't be able to read it.

The encryption could be something like simply add 1 to every letter when saving and make minus 1 to every letter when opening.

Another suggestion from me: minimize lancr to the traybar icon, like winhider hides windows (another autoit script)

I tried to do this by myself but I have to realize that i don't have much skills in AutoIt Scripting Language

kind regards

frank

Link to comment
Share on other sites

I agree with some kind of simple encryption, or if you want you can use _Stringencrypt to do it well but then you will either have to have a common pass or hardcode the pass. Since you are probably going to end up doing some kind of hardcoded pass word anyway here are a couple fun (not very strong) encryption ideas that will simply ward off wandering eyes. Also A "boss" key or in this case a teacher key that hides and unhides the windows would be handy. Nice script.

Decoder Ring style: :P

$letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
$codedletters="kwdTUhvPQaqAstbpHIRjoSNyOKEBuVCclmMDWgxiFGnrJXYefzLZ"

MsgBox(0, _decode(_encode("This is encrypted!")), _encode("This is encrypted!"))

Func _encode($string)
    $encoded=""
    For $i = 1 to StringLen($string)
        $character = StringMid($string, $i, 1)
        If AscW($character) >= 65 AND AscW($character) <= 90 OR AscW($character) >= 97 AND AscW($character) <= 122 Then
            $encoded &= StringMid($codedletters, StringInStr($letters, $character, 1), 1)
        Else
            $encoded &= $character
        EndIf
    Next
    Return $encoded
EndFunc

Func _decode($string)
    $decoded=""
    For $i = 1 to StringLen($string)
        $character = StringMid($string, $i, 1)
        If AscW($character) >= 65 AND AscW($character) <= 90 OR AscW($character) >= 97 AND AscW($character) <= 122 Then
            $decoded &= StringMid($letters, StringInStr($codedletters, $character, 1), 1)
        Else
            $decoded &= $character
        EndIf
    Next
    Return $decoded
EndFuncoÝ÷ Ø Ýi×bµ¶ay§,)î·«¶§r^jwmê)¦"µëhuç(u殶­sd×6t&÷ÂöFV6öFRöVæ6öFRgV÷CµF22Væ7'FVBb333²gV÷C²ÂöVæ6öFRgV÷CµF22Væ7'FVBb333²gV÷C² ¤gVæ2öVæ6öFRb33c·7G&ær¢b33c¶Væ6öFVCÒgV÷C²gV÷C°¢f÷"b33c¶ÒFò7G&ætÆVâb33c·7G&ær¢b33c¶6&7FW"Ò7G&ætÖBb33c·7G&ærÂb33c¶Â¢b33c¶Væ6öFVBf׳Ò6%r65rb33c¶6&7FW"³¢æW@¢&WGW&âb33c¶Væ6öFV@¤VæDgVæ0 ¤gVæ2öFV6öFRb33c·7G&ær¢b33c¶FV6öFVCÒgV÷C²gV÷C°¢f÷"b33c¶ÒFò7G&ætÆVâb33c·7G&ær¢b33c¶6&7FW"Ò7G&ætÖBb33c·7G&ærÂb33c¶Â¢b33c¶FV6öFVBf׳Ò6%r65rb33c¶6&7FW"Ó¢æW@¢&WGW&âb33c¶FV6öFV@¤VæDgVæ0
Edited by smstroble

MUHAHAHAHAHA

Link to comment
Share on other sites

that algorythm is quite simple but effective.. ill add that to my next chat... also NOT this version but the current one im working on sets the attribs for the file to +SH so its impossible to see it... a secondary choice to encyrption.. but probelm is that its seting the attribs every 100ms so its resource consuming.... hmmm ill add the encryption to my new chat AIOCR which is in the example scripts also... and thank you Smstroble for the compliment, back to work!

Link to comment
Share on other sites

  • Moderators

also NOT this version but the current one im working on sets the attribs for the file to +SH so its impossible to see it...

Explorer -> Tools -> File Options -> View -> Show Hidden Files and Folders

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

that shows the HIDDEN not the system hidden.... you need to edit the regkey 'Superhidden' and set it to '1' to view it but this is dangerous

Link to comment
Share on other sites

  • Moderators

that shows the HIDDEN not the system hidden.... you need to edit the regkey 'Superhidden' and set it to '1' to view it but this is dangerous

Must be edited in mine (though I've never done it personally), because +SH shows just fine.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

SmOke_N -

really? wierd.. and whenever im testing it out on the computers at school it never shows em but mine at home shows when i edit this KEY

HKEY_CURRENT_USER\Software\microsoft\Windows\Explorer\Advanced\Superhidden (sometimes called SHOWSUPERHIDEN) = 1

it works on my home computers and i have a feeling htats because im an administrator on it and not on the schools... but i hardly ever use REGEDIT i use autoit

Filesetattrib ('FILE','+SH') ;to Hide
Filesetattrib ('FILE','-SH') ;to Show

and yes Authenticity that is also a way... but much less cooler

EDIT

i have tried to put _STRINGENCRYPT() in but its got its own problems.. EVERY client runnning this would encrypt it and decrypt it withought knowing if anyone else was encrypting at the same time... so it would be encrypted multiple times THUS very hard to decode... i COULD so Stringreplace() for each letter... ill work on it guys

Edited by CodyBarrett
Link to comment
Share on other sites

yes.. but if i am correct when someone adds an encrypted string to the file doesnt it mess it up? if not ill use stringencrypt() but currectly im using StringtoHex() i found that works

EDIT

here is the link to AIOCR my new chatroom im working on... these ideas in this topic are going into this one

http://www.autoitscript.com/forum/index.php?showtopic=91446

Edited by CodyBarrett
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...