Jump to content

Recommended Posts

Posted

hello all,

im making a tool bar app that sits at the top of the screen and you can send messages to a nother user. it sends the data via TCP fine but i cant get the reciver part to work with it.

here waht i got.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <ScreenCapture.au3>

TCPStartup()

;vars
Dim $Operating_System, $HOUR, $PM_AM, $Button2, $Input2, $Edit2


;opearting type
If @OSVersion = "WIN_7" Then
    $Operating_System = "Windows 7"
ElseIf @OSVersion = "WIN_VISTA" Then
    $Operating_System = "Windows Vista"
ElseIf @OSVersion = "WIN_XP" Then
    $Operating_System = "Windows XP"
EndIf


;GUI
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 894, 35, 38, 124)
$Label1 = GUICtrlCreateLabel("Computer Name:", 8, 8, 95, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Sans Serif")
$Label2 = GUICtrlCreateLabel(@ComputerName, 108, 8, 76, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Sans Serif")
$Label3 = GUICtrlCreateLabel("Operating System:", 184, 8, 100, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Sans Serif")
$Label4 = GUICtrlCreateLabel($Operating_System,  290, 8, 60, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Sans Serif")
$Label5 = GUICtrlCreateLabel("Time:", 368, 8, 30, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Sans Serif")
$Label6 = GUICtrlCreateLabel($HOUR&":"&@MIN&":"&@SEC&"-"&$PM_AM,  405, 8, 70, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Microsoft Sans Serif")
$Button1 = GUICtrlCreateButton("HELP", 490, 4, 75, 25)
$Button5 = GUICtrlCreateButton("MESSAGE", 576, 4, 75, 25)
$Button8 = GUICtrlCreateButton("", 660, 4, 30, 25,$BS_ICON) ;Recved messages button
GUICtrlSetImage(-1, "shell32.dll", -157)
GUICtrlSetState($Button8, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Clock()
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            HELP()
        Case $Button5
            CHAT()
        Case $button8
            MAIL()
    EndSwitch
WEnd

Func Snapshot()
    $path = (@TempDir&"\SCREEN_SHOT.jpg")
    $temp = _ScreenCapture_Capture($path)
    sleep(500)
    MsgBox(64,"Your Information Please", "Screen Shot Taken")
EndFunc

Func HELP()
    $Form2 = GUICreate("Whats The Problem ??", 228, 390, 192, 124,1,1)
    $Input1 = GUICtrlCreateInput("TOPIC", 8, 32, 121, 21, BitOR($ES_AUTOHSCROLL,$WS_BORDER))
    $Label7 = GUICtrlCreateLabel("Topic", 24, 8, 34, 19)
    GUICtrlSetFont(-1, 9, 400, 4, "Microsoft Sans Serif")
    $Label8 = GUICtrlCreateLabel("Message", 24, 64, 55, 19)
    GUICtrlSetFont(-1, 9, 400, 4, "Microsoft Sans Serif")
    $Edit1 = GUICtrlCreateEdit("", 8, 88, 201, 193, BitOR($ES_WANTRETURN,$WS_BORDER))
    GUICtrlSetData(-1, "TELL USE YOUR PROBLEM.")
    $Button2 = GUICtrlCreateButton("Take Screen Shot", 56, 296, 107, 25)
    $Button3 = GUICtrlCreateButton("Report", 136, 32, 75, 25)
    $Button6 = GUICtrlCreateButton("Exit", 72, 335, 75, 25)
    GUISetState(@SW_SHOW)

        While 2
        $nMsg = GUIGetMsg()
        If $nMsg = $Button6 Then ExitLoop
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            case $Button2 ;Snapshot of screen
                Snapshot()
            Case $Button3 ;Report sends details to a SQL server.
        EndSwitch
    WEnd
    GUIDelete($Form2)

EndFunc

Func CHAT()
    $Form3 = GUICreate("Form3", 220, 359, 282, 159)
    $Input2 = GUICtrlCreateInput(@IPAddress1, 16, 32, 145, 21, BitOR($ES_AUTOHSCROLL,$WS_BORDER))
    $Label10 = GUICtrlCreateLabel("IP Address Or PC Name", 24, 8, 134, 19)
    GUICtrlSetFont(-1, 9, 400, 4, "Microsoft Sans Serif")
    $Label9 = GUICtrlCreateLabel("Message", 24, 64, 55, 19)
    GUICtrlSetFont(-1, 9, 400, 4, "Microsoft Sans Serif")
    $Edit2 = GUICtrlCreateEdit("", 16, 88, 185, 177, BitOR($ES_WANTRETURN,$WS_BORDER))
    GUICtrlSetData(-1, "Your Message Please.")
    $Button4 = GUICtrlCreateButton("Send", 64, 280, 75, 25)
    $Button7 = GUICtrlCreateButton("Exit", 64, 320, 75, 25)
    GUISetState(@SW_SHOW)

        While 3
        $nMsg = GUIGetMsg()
        If $nMsg = $Button7 Then ExitLoop
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button4
                TCPsender()
        EndSwitch
    WEnd
    GUIDelete($Form3)

EndFunc

Func TCPsender()
    $pc = GUICtrlRead($Input2); reads the ipaddress from func help
    $Message = GUICtrlRead($Edit2); reads the message from func help
    opt("TCPTimeout",100)
    ;TCPStartup() THIS IS ON LINE 8
    $connect = TCPConnect($pc, 4000); sends data on to port 4000
    TCPSend($connect, $Message)
    TCPCloseSocket($connect)
EndFunc

Func TCPRECVER()
    $TCPListen = TCPListen(@IPaddress1, 4000)
    Do
     $TCPAccept = TCPAccept($TCPListen)
    Until $TCPAccept <> -1
    Do
     $TCPRecive = TCPRecv($TCPAccept, 100000000)
    until $TCPRecive <> ""
    msgbox(0,0,$TCPRecive);<<<<<<<<<<<<<<<<<<<<< this will change latter to show that $Button8 thas mail (the disabled mail button for now)
EndFunc

func MAIL()
    $Form4 = GUICreate("Form4", 221, 360, 282, 159)
    $Input3 = GUICtrlCreateInput("????", 16, 32, 145, 21, BitOR($ES_AUTOHSCROLL,$WS_BORDER))
    $Label11 = GUICtrlCreateLabel("From Sender", 24, 8, 78, 19)
    GUICtrlSetFont(-1, 9, 400, 4, "Microsoft Sans Serif")
    $Label2 = GUICtrlCreateLabel("Your Message", 24, 64, 87, 19)
    GUICtrlSetFont(-1, 9, 400, 4, "Microsoft Sans Serif")
    $Edit3 = GUICtrlCreateEdit("", 16, 88, 185, 177, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER))
    GUICtrlSetData(-1, "Your Revived Messaged.")
    $Button9 = GUICtrlCreateButton("Replay", 64, 280, 75, 25)
    $Button10 = GUICtrlCreateButton("Exit", 64, 320, 75, 25)
    GUISetState(@SW_SHOW)

        While 4
                $nMsg = GUIGetMsg()
                If $nMsg = $Button10 Then ExitLoop
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        Exit
                    Case $Button9
                        CHAT()
                EndSwitch
            WEnd
            GUIDelete($Form4)
EndFunc

Func Clock()
    If @HOUR = 1 Then
        $HOUR = 1
    ElseIf @HOUR = 2 Then
        $HOUR = 2
    ElseIf @HOUR = 3 Then
        $HOUR = 3
    ElseIf @HOUR = 4 Then
        $HOUR = 4
    ElseIf @HOUR = 5 Then
        $HOUR = 5
    ElseIf @HOUR = 6 Then
        $HOUR = 6
    ElseIf @HOUR = 7 Then
        $HOUR = 7
    ElseIf @HOUR = 8 Then
        $HOUR = 8
    ElseIf @HOUR = 9 Then
        $HOUR = 9
    ElseIf @HOUR = 10 Then
        $HOUR = 10
    ElseIf @HOUR = 11 Then
        $HOUR = 11
    ElseIf @HOUR = 12 Then
        $HOUR = 12
    ElseIf @HOUR = 13 Then
        $HOUR = 1
    ElseIf @HOUR = 14 Then
        $HOUR = 2
    ElseIf @HOUR = 15 Then
        $HOUR = 3
    ElseIf @HOUR = 16 Then
        $HOUR = 4
    ElseIf @HOUR = 17 Then
        $HOUR = 5
    ElseIf @HOUR = 18 Then
        $HOUR = 6
    ElseIf @HOUR = 19 Then
        $HOUR = 7
    ElseIf @HOUR = 20 Then
        $HOUR = 8
    ElseIf @HOUR = 21 Then
        $HOUR = 9
    ElseIf @HOUR = 22 Then
        $HOUR = 10
    ElseIf @HOUR = 23 Then
        $HOUR = 11
    ElseIf @HOUR = 24 Then
        $HOUR = 12
    EndIf

    If @HOUR = 1 > 12 Then
        $PM_AM = "AM"
    ElseIf @HOUR = 13 < 25 Then
        $PM_AM = "PM"
    EndIf

    Global $sData = $HOUR&":"&@MIN&":"&@SEC&"-"&$PM_AM
    GuiCtrlSetData($Label6 ,$sData)
EndFunc
Posted

In your CHAT function there doesn't seem to have a TCPreceive in the while loop.

Also in the recieve function you have specified.. the TCP funcs aren't configured correctly. you only need to call TCPListen ONCE. - need some help with TCP? check out my TCP multiclient Example in my Sig.

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
×
×
  • Create New...