Jump to content
Sign in to follow this  

[Solved] SendMsg() not showing to other users

Recommended Posts


Hi Experts,

I have this old script from my former colleague and when trying to modify it, it will no longer working. I was task to modify this code for the production to use it but can't figured it out why it was not sending the message after inputting my message in inputbox.

So far from my modification:

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstantS.au3>

Global $hGui, $hEdit, $hInp, $hBtn, $rsock, $ssock, $recv, $UserInput
Global $port = 1018
Global $Broadcast = @IPAddress1

;start main function
GUICtrlSetBkColor($hGui, $COLOR_RED)


Func _main()
    ;create gui
    $hGui = GUICreate("",300,239)
    GUISetOnEvent($GUI_EVENT_CLOSE, "hGuiClose")
    $hEdit = GUICtrlCreateEdit("Welcome, Visitors",0,0,316,220,BitOR($ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL,$ES_AUTOVSCROLL))
    $hInp = GUICtrlCreateInput("",0,219,250,20)
    $hBtn = GUICtrlCreateButton("Send",310,220,30,20,$BS_DEFPUSHBUTTON)

    ;display gui

    ;start winsock for udp
    ;bind a socket to the port for listening
    $rsock = UDPBind(@IpAddress1,$port)
    If @error <> 0 Then Exit
    ;send message informing of online status
    SendMsg("-"&@UserName&" is online.")
    ;start gui loop
        $recv = UDPRecv($rsock,1024)
        If $recv <> "" Then
            _WinAPI_FlashWindowEx($hGui, 2)
        $msg = GUIGetMsg()
        If $msg = $hBtn Then
            $buffer = GUICtrlRead($hInp)
            If $buffer <> "" Then
                SendMsg("<"&@UserName&">: "&$buffer & " (" & @HOUR & ":" & @MIN & ":" & @SEC & ")")
     Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==> _main

Func SendMsg($txtMsg)
        $ssock = UDPOpen($Broadcast,$port)
        If @error = 0 Then
EndFunc ;==> SendMsg

Func Print($txtMsg)
EndFunc ;==> Print

Func hGuiClose()
    ;send message informing of offline status
    SendMsg("-"&@UserName&" has gone offline.")
EndFunc ;==> OnAutoItExit

Can't locate the working code from our former colleague who resigned a while ago and I'm having hard time modifying it.


Need you help with this Experts, thanks in advance.




Edited by KickStarter15

Share this post

Link to post
Share on other sites


What's the issue? :)

Click here to see my signature:


I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post

Link to post
Share on other sites

Mabe because you use the wrong broadcast IP?

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post

Link to post
Share on other sites

@FrancescoDiMuro,:D I think the issue was when other user use this program, they can type-in their message but their message is not showing to another user that is also using the program.

When trying it in my own PC same thing as the other user could not see my message. I tried checking it and testing it but still could not locate the cause.


@funkey, I think broadcast IP is good and i think there's no problem with it. This program is already used in production and is working fine. But when I modified it with some thing to add like, change username to full name, get their ID, and other things (which is my task right now) and it's no longer working.:(


Here is the scenario with this issue: "The program was saved at the server where all users can call it and run it."

Now, I am the user1 with IP of 172.0.0... opening the program and at the same time other user which user2 was using it as well with IP 172.0.1.... then user2 type-in a message to that program and enter to send. But me as the user1 could not see his/her message. In return, he/she could not also see mine as well.

This program is like a chat group but localized usage only (which is for production use only).

Edited by KickStarter15

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.