Jump to content

pyrofool

Members
  • Posts

    4
  • Joined

  • Last visited

pyrofool's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I modified trues version a bit to add the ability to change font/background color and also added some emoticons. ;~ This is the client. ;~ version 1.5 ;~ by true ;~ based on : New & Improved TCP Chat by John2010zz (http://www.autoitscript.com/forum/index.php?showtopic=112507) ;~ and Advanced Encryption Standard (AES/Rijndael) UDF by Ward (http://www.autoitscript.com/forum/index.php?showtopic=78745&hl=aesau3&st=0) ;~ heavily modified by true for Silikon Junkeez (http://sj.hopto.org) ;~ many thanks to both of them ;~ i also used _ArrayAdd2 function by vampirevn01 (http://www.autoitscript.com/forum/index.php?showtopic=72040) #Include <ButtonConstants.Au3> #Include <EditConstants.Au3> #Include <GUIConstantsEx.Au3> #Include <StaticConstants.Au3> #Include <WindowsConstants.Au3> #Include <GUIEdit.Au3> #Include <Misc.Au3> #Include <AES.Au3> #include <iNet.au3> #NoTrayIcon Opt ('GUIOnEventMode', 1) TcpStartUp () ; ######################## some vars Global $Server = -1, $Logs, $version = "1.5", $serveradress , $FontColor , $BgColor $Key = Binary(IniRead ('Settings.ini','Settings','Key','0x00000000000000000000000000000000')) $red = "0xFF0019" $black = "0x000000" $blue = "0x0000FF" $yellow = "0xFFF70F" $green = "0x27C400" $white = "0xFFFFFF" $custom = "" ;######################### end vars ;######################### some GUI ;this is the settings window $FontColor = IniRead ('Settings.ini','Settings','FontColor','black') $BgColor = IniRead ('Settings.ini','Settings','BgColor','white') $Settings = GUICreate ('Settings', 180, 180, -1, -1, -1) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit') GUICtrlCreateGroup ('', 5, 0, 170, 95) GUICtrlCreateGroup ('', 5, 95, 170, 62) GUICtrlCreateLabel("Background",12,110,60,20) GUICtrlCreateLabel("Font",120,110,30,20) $IP = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','IP', '172.0.0'), 12, 13, 100, 21, 1) $Port = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','Port', 5555), 117, 13, 50, 21, 1) $User = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','User','User'), 12, 39, 156, 21, 1) $bgcolordrop = GUICtrlCreateCombo($BgColor,12,130,70,10) GUICtrlSetData($bgcolordrop,"red|black|yellow|green|blue|white") $fontcolordrop = GUICtrlCreateCombo($FontColor,100,130,70,10) GUICtrlSetData($fontcolordrop,"red|black|yellow|green|blue|white") $Pass = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','Pass','Password'), 12, 66, 156, 21, BitOR(1, $ES_PASSWORD)) $Connect = GUICtrlCreateButton ('Connect', 45, 158, 100, 20, $WS_GROUP) GUICtrlSetOnEvent ($Connect, '_Start') ;~ $Exit = GUICtrlCreateButton ('Exit', 117,145, 50, 20, $WS_GROUP) ;~ GUICtrlSetOnEvent ($Exit, '_Exit') GUISetState (@SW_SHOW) WinSetOnTop ($Settings, '', 1) ;this is the main GUI $GUI = GUICreate ('Chat Client' & " version " & $version, 375, 345, -1, -1, -1) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Toggle') $History = GUICtrlCreateEdit ('', 0, 1, 375, 243, 2103360 + $ES_MULTILINE) GUICtrlSetFont ($History, 10, -1, -1, 'Lucida Sans Unicode') $Send = GUICtrlCreateEdit ('', 0, 275, 375, 70, 2101248) GUICtrlSetFont ($Send, 10, -1, -1, 'Lucida Sans Unicode') $smiley = GUICtrlCreateButton(":-)",2,245,20,25) $smiley1 = GUICtrlCreateButton(";-)",23,245,20,25) $smiley2 = GUICtrlCreateButton(":-0",43,245,20,25) $smiley3 = GUICtrlCreateButton("8-)",63,245,20,25) GUICtrlSetOnEvent($smiley,'_smiley') GUICtrlSetOnEvent($smiley1,'_smiley1') GUICtrlSetOnEvent($smiley2,'_smiley2') GUICtrlSetOnEvent($smiley3,'_smiley3') GUISetState (@SW_HIDE) ;######################### end GUI ;######################### some Main While 1 Sleep (15) If $Server <> -1 Then $Recv2 = TcpRecv ($Server, 1000000, 1) If @Error Then GUISetState (@SW_HIDE, $GUI) Sleep (100) MsgBox (48, 'Server Notice','You have been disconnected from the server.') _Disconnect () EndIf $Decrypted = _AesDecrypt($Key, $Recv2) $Recv = BinaryToString($Decrypted) If $Recv = 'Error:Username.Exists;' Then GUISetState (@SW_HIDE, $GUI) Sleep (100) MsgBox (48, 'Server Notice','Your username is already in use, please change it and try again.') _Disconnect () ElseIf $Recv = 'Error:Max.Connections;' Then GUISetState (@SW_HIDE, $GUI) Sleep (100) MsgBox (48, 'Server Notice','Max amount of connections reached, try again later.') _Disconnect () ElseIf $Recv = 'Error:Wrong.Username.Or.Password;' Then GUISetState (@SW_HIDE, $GUI) Sleep (100) MsgBox (48, 'Server Notice','Wrong username or password.') _Disconnect () ElseIf $Recv = 'Error:IP.Banned;' Then GUISetState (@SW_HIDE, $GUI) Sleep (100) MsgBox (48, 'Server Notice','Your IP address has been banned.') _Disconnect () ElseIf StringLeft ($Recv, 4) = '.log' Then FileWriteLine ('Logged.txt', StringTrimLeft ($Recv, 5)) ElseIf $Recv <> '' Then _Log (StringReplace ($Recv, '%Time', @HOUR & ':' & @MIN)) EndIf If _IsPressed ('0D') And GUICtrlRead ($Send) <> '' And ControlGetFocus ($GUI) = 'Edit2' Then $Read = StringReplace (GUICtrlRead ($Send), @CRLF, '') $Read = StringReplace ($Read, @CR, '') $Read = StringReplace ($Read, @LF, '') If $Read = '.clear' Then GUICtrlSetData ($History, '') ElseIf $Read = '.logs' Then _Logs () ElseIf $Read = '.save' Then FileWrite (@MDAY & '-' & @MON & '-' & @YEAR & '_' & @HOUR & '-' & @MIN & '-' & @SEC & '_Logs.txt', GUICtrlRead ($History)) ElseIf $Read = '.disconnect' Or $Read = '.exit' Then _Disconnect () Else If $Read <> "" Then $Encrypted = _AesEncrypt($Key, $Read) TcpSend ($Server, $Encrypted) EndIf EndIf GUICtrlSetData ($Send, '') EndIf EndIf WEnd ;######################### end Main ;######################### some Functions Func _Logs () $Logs = GUICreate ('Admin Logs', 375, 203, -1, -1, -1, 128) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Delete') $Edit = GUICtrlCreateEdit ('', 0, 1, 375, 203, 2103360 + $ES_MULTILINE) GUICtrlSetFont ($Edit, 10, -1, -1, 'Lucida Sans Unicode') GUICtrlSetBkColor ($Edit, 0x83B4FC) GUICtrlSetColor ($Edit, 0xFFFFFF) GUISetState (@SW_SHOW) GUICtrlSetData ($Edit, FileRead ('Logged.txt')) WinSetOnTop ($Logs, '', 1) EndFunc Func _Delete () GUIDelete ($Logs) EndFunc Func _Disconnect () GUICtrlSetData ($History, '') TcpCloseSocket ($Server) $Server = -1 GUISetState (@SW_HIDE, $GUI) GUISetState (@SW_SHOW, $Settings) WinSetOnTop ($Settings, '', 1) EndFunc Func _Toggle () GUICtrlSetData ($History, '') TcpCloseSocket ($Server) $Server = -1 GUISetState (@SW_HIDE, $GUI) GUISetState (@SW_SHOW, $Settings) WinSetOnTop ($Settings, '', 1) EndFunc Func _Log ($Data) GUICtrlSetData ($History, GUICtrlRead ($History) & $Data & @CRLF) _GUICtrlEdit_LineScroll ($History, 0, _GUICtrlEdit_GetLineCount ($History) - 1) EndFunc Func _Start () If GUICtrlRead ($User) == '' Or GUICtrlRead ($IP) == '' Or GUICtrlRead ($Port) == '' Then Return @Error If StringIsDigit(StringLeft ((GUICtrlRead ($IP)), 1 )) Then $serveradress = (GUICtrlRead ($IP)) Else $serveradress = _TCPIpToName (GUICtrlRead ($IP)) EndIf $Server = TcpConnect ($serveradress, GUICtrlRead ($Port)) If $Server = -1 Or @Error Then WinSetOnTop ($Settings, '', 0) Sleep (100) MsgBox (16, 'Fatal Error','Unable to connect to the server, change your settings and try again.') WinSetOnTop ($Settings, '', 1) Return @Error EndIf Sleep (150) $Encrypted = _AesEncrypt($Key, GUICtrlRead ($User) & "|" & GUICtrlRead ($Pass)) TcpSend ($Server, $Encrypted) GUISetState (@SW_HIDE, $Settings) WinSetOnTop ($Settings, '', 0) getcolors () GUISetState (@SW_SHOW, $GUI) EndFunc Func _Exit () IniWrite ('Settings.ini','Settings','IP', GUICtrlRead ($IP)) IniWrite ('Settings.ini','Settings','Port', GUICtrlRead ($Port)) IniWrite ('Settings.ini','Settings','User', GUICtrlRead ($User)) IniWrite ('Settings.ini','Settings','Pass', GUICtrlRead ($Pass)) IniWrite ('Settings.ini','Settings','Key', $Key) IniWrite ('Settings.ini','Settings','FontColor', GUICtrlRead($fontcolordrop)) IniWrite ('Settings.ini','Settings','BgColor',GUICtrlRead($bgcolordrop)) Exit EndFunc Func getcolors () $FontColor = GUICtrlRead($fontcolordrop) If $FontColor = "red" Then $FontColor = $red ElseIf $FontColor = "blue" Then $FontColor = $blue ElseIf $FontColor = "yellow" Then $FontColor = $yellow ElseIf $FontColor = "green" Then $FontColor = $green ElseIf $FontColor = "white" Then $FontColor = $white else $FontColor = $black EndIf $BgColor = GUICtrlRead($bgcolordrop) If $BgColor = "red" Then $BgColor = $red ElseIf $BgColor = "blue" Then $BgColor = $blue ElseIf $BgColor = "yellow" Then $BgColor = $yellow ElseIf $BgColor = "green" Then $BgColor = $green ElseIf $BgColor = "black" Then $BgColor = $black else $BgColor = $white EndIf GUICtrlSetBkColor ($History, $BgColor) ;recieve baground color GUICtrlSetColor ($History, $FontColor) ;recieve font color GUICtrlSetColor ($Send, $FontColor) ;send font color GUICtrlSetBkColor ($Send, $BgColor) ;send background color EndFunc Func _smiley () GUICtrlSetState($Send,$GUI_FOCUS) Send(":-)") EndFunc Func _smiley1 () GUICtrlSetState($Send,$GUI_FOCUS) Send(";-)") EndFunc Func _smiley2 () GUICtrlSetState($Send,$GUI_FOCUS) Send(":-0") EndFunc Func _smiley3 () GUICtrlSetState($Send,$GUI_FOCUS) Send("8-)") EndFunc ;######################### end Functions Probably not the cleanest way to add those features but it works
  2. Thanks for the response, while your code does work it was not quite what I was thinking. I liked the toggle minimize part but I need to add a Guisetstate(@SW_restore) after the guisetstate(@SW_show). now when i want the gui to appear it maximizes to the tray then it restores itself to the screen. This was the problem the whole time.
  3. The GUI minimizes properly but if I try to show the GUI right after I click one of the tray menus, the gui only maximizes to the tray and does not show fully. This does not happen if I click one of the tray menus and click on the screen before I try to maximize, so I have no idea why it won't fully show up. I know the code is a bit messy but this is my first real application with autoit. Any help would be appreciated, I have been beating my head against the wall for days . CODE#include <GuiConstantsEx.au3> #include <WMMedia.au3> #include <Constants.au3> Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) Global $is_minimized = 0 ;Tray $TrayMenu_Play = TrayCreateItem("Play") $TrayMenu_Stop = TrayCreateItem("Stop") $TrayMenu_Mute = TrayCreateItem("Mute") TrayCreateItem("") $TrayMenu_Exit = TrayCreateItem("Exit") TrayItemSetOnEvent($TrayMenu_Exit, "Tray_Exit") TrayItemSetOnEvent($TrayMenu_Stop, "Tray_Stop") TraySetClick(8) TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Toggle") TraySetToolTip ("Radio Streamer") ;GUI $Radio_Client = GUICreate('Radio Streamer', 200, 200) GuiSetState() GUICtrlCreateLabel('volume:', 10, 90, 50, 20) $checkCN = GUICtrlCreateCheckbox("Mute", 110, 100, 90, 20) $Play_Button = GUICtrlCreateButton("Play", 30, 40, 60, 25) $Stop_Button = GUICtrlCreateButton("Stop", 95, 40, 60, 25) ;$Pause_Button = GUICtrlCreateButton("PAuse", 125, 40, 60, 25) $Label = GUICtrlCreateLabel('4', 50, 90, 50, 20) ;Slider $Slider = GUICtrlCreateSlider(5, 125, 190, 40) GUICtrlSetLimit(-1, 100, 4) GUICtrlSetData(100,1) $Prev = GUICtrlRead($Slider) ;Menu $menu=GuiCtrlCreateMenu("Menu") $about_menu=GUICtrlCreateMenuItem("About", $menu) $stations_menu=GUICtrlCreateMenu("Stations", $menu, 1) $techno=GUICtrlCreateMenu("Techno", $stations_menu, 1) $Happy_Hardcore=GUICtrlCreateMenuItem("Happy Hardcore", $techno) $alt_rock=GUICtrlCreateMenu("Alt Rock", $stations_menu, 1) $WGRD=GUICtrlCreateMenuItem("WGRD", $alt_rock) $top_40=GUICtrlCreateMenu("Top 40", $stations_menu, 1) $hotfm=GUICtrlCreateMenuItem("Hot FM", $top_40) $Jackson=GUICtrlCreateMenuItem("Michael Jackson", $stations_menu, 1) while 1 ;Volume Control $Data = GUICtrlRead($Slider) if $Data <> $Prev then GUICtrlSetData($Label, $Data) $Prev = $Data WmSetVolume($Data) GUICtrlSetState ($checkCN, $GUI_UNCHECKED) endif ;Menu Items $Msg = GUIGetMsg() If $msg = $about_menu Then MsgBox(0, "Info","WGRD Radio 1.0"& @LF & "Created by Christopher Roelofs") endif If $msg = $Happy_Hardcore Then WMStop() $sFilename = ("http://www.di.fm/wma/hardcore.asx ") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $WGRD Then WMStop() $sFilename = ("http://media.streamads.com/clientdata/regent/asx/WGRD.asx") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $hotfm Then WMStop() $sFilename = ("mms://citadelcc-whts-fm.wm.llnwd.net/citadelcc_whts_fm") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $Jackson Then WMStop() $sFilename = ("http://www.mjtunes.com/mjtunesradio-7.asx") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf ;PLay,Pause,Stop,Mute Select Case $msg = $Play_Button $pObj.controls.play() Case $msg = $Stop_Button $pObj.controls.Stop() Case $msg = $checkCN And BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) = $GUI_CHECKED $pObj.settings.volume = (0) GUISetState() Case $msg = $checkCN And BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) <> $GUI_CHECKED WmSetVolume($Data) GUISetState() EndSelect switch $Msg case $GUI_EVENT_CLOSE WMStop() exit Case $GUI_EVENT_MINIMIZE GuiSetState(@SW_HIDE) $is_minimized = 1 endswitch wend ;Minimize Func Toggle() If $is_minimized = 1 Then GuiSetState(@SW_SHOW) $is_minimized = 0 Else GuiSetState(@SW_HIDE) $is_minimized = 1 EndIf EndFunc ;Exit Func Tray_Exit() WMStop() Exit EndFunc Func Tray_Stop() WMStop() EndFunc P.S the script use WMMedia.au3 which I have attached WMMedia.au3
  4. looks great, fantastic job!
×
×
  • Create New...