Jump to content
Sign in to follow this  
JonBMN

Program runs fine before compile; does not work after

Recommended Posts

I have a script that runs perfectly before compiling. I need one file called TCP.au3 included in this compiled program, but it does not seem to let me use it once I've compiled my main script.

I've noticed some people have had problems, but not like mine.

My GUI runs fine, but the back-end is at a stand still and does not run (I'm thinking because it is not getting the information from TCP.au3 it needs), but I could be wrong. Any help would be greatly appreciated.

Edited by JonBMN

Share this post


Link to post
Share on other sites

JonBMN, you're stating you have a script that runs fine before compiling, but not after, and you would like some assistance. Yet, you do not provide us the script - so we have to guess at what you're doing and then troubleshoot why it is not working for you ;)

Please post your script, or a short reproducer of the problem; help us help you.

Share this post


Link to post
Share on other sites

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Green.ico
#AutoIt3Wrapper_Outfile=ArchServer.exe
#AutoIt3Wrapper_Res_Comment=
#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****



#include "TCP.au3"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <Array.au3>
#include <ButtonConstants.au3>

;AutoItSetOption("TCPTimeout", 100)

;ToolTip("SERVER: Creating server...",10,30)

$hServer = _TCP_Server_Create(21230); A server. Tadaa!


Local $compName = "", $strSplit, $DateTime, $User, $CarDatabase = "Database.txt"
Local $MaxCars = 1000, $CarData[$MaxCars][3], $NumCars = -1, $List1, $List2, $List3, $List4
Local $ButtonAZ, $ButtonZA, $GUIhandle, $hChild_1, $ButtonCloseChild, $msg, $ConnectList
Local $UsersConnected = 0, $ActiveConnections, $Button19, $Button91


HotKeySet("{Esc}", "Quit")
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
;MAIN LINE





ReadCars()
GUI()

_TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server.
_TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects.
_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Receive"); And this,... when we receive something from the client side


While 1
    $msg = GUIGetMsg(1)
        Switch $msg[1]
            Case $GUIhandle
                Switch $msg[0]
                  Case $GUI_EVENT_CLOSE
                      Quit()
                  Case $ButtonAZ
                      Sort("^ v", 0)
                  Case $ButtonZA
                      Sort("v ^", 0)
                  Case $Button19
                      Sort("^ v", 1)
                  Case $Button91
                      Sort("v ^", 1)
                EndSwitch
            Case $hChild_1
                 Switch $msg[0]
                     Case $GUI_EVENT_CLOSE
                          GUIDelete($hChild_1)
                 EndSwitch
         EndSwitch
WEnd

;END MAIN LINE

_TCP_Server_ClientList()


Func NewClient($hSocket, $iError); Yo, check this out! It's an $iError parameter! (In case you didn't noticed: It's in every function)
    $UsersConnected = $UsersConnected + 1
    _GUICtrlListBox_ReplaceString($ActiveConnections, 0, String($UsersConnected))
    If $UsersConnected > 1000 Then
        _TCP_Server_DisconnectClient($hSocket)
    EndIf
EndFunc

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
    $UsersConnected -= 1
    _GUICtrlListBox_ReplaceString($ActiveConnections, 0, String($UsersConnected))
EndFunc


Func Receive($hSocket, $sReceived, $iError)
    Local $LinesReceived[101]
    If $sReceived = " " Or $sReceived = "" Then
        Return
    EndIf
    ;ConsoleWrite($sReceived & @CRLF)
    $LinesReceived = StringSplit($sReceived, "|")
    For $Index = 1 to $LinesReceived[0]
        ParseLineData($LinesReceived[$Index])
    Next
EndFunc

Func ParseLineData($LineReceived)
    Local $Log = "", $FoundAt, $CheckIn, $LineSplit
    ConsoleWrite($LineReceived & @CRLF)
    MsgBox(0, "", $LineReceived & @CRLF)
    $LineSplit = StringSplit($LineReceived, ",")
    If $LineSplit[0] <> 4 Then
        _GUICtrlListBox_AddString($List4, "Received Incomplete Data String")
        return
    EndIf
    consoleWrite($LineSplit[0] & @CRLF)
    $DateTime = StringStripWS($LineSplit[1], 1)
    $User = StringStripWS($LineSplit[2], 1)
    $compName = StringStripWS($LineSplit[3], 1)
    $Data = StringStripWS($LineSplit[4], 1)
    $Data = StringStripWS($LineSplit[4], 2)
    $FoundAt = FindCar($compName)
    If $FoundAt = -1 Then
        _GUICtrlListBox_AddString($List4, "Found " & $compName & " not in the database. Adding Now.")
        $NumCars += 1
        $FoundAt = $NumCars
        $CarData[$NumCars][0] = $compName
        $CarData[$NumCars][1] = " "
        _GUICtrlListBox_ReplaceString($List2, $FoundAt, " " & $CarData[$NumCars][1])
        $CarData[$NumCars][2] = " "
        _GUICtrlListBox_ReplaceString($List3, $FoundAt, " " & $CarData[$NumCars][2])
        _GUICtrlListBox_ReplaceString($List1, $FoundAt, " " & $CarData[$FoundAt][0])
    EndIf
    $CarData[$FoundAt][1] = $DateTime
    _GUICtrlListBox_ReplaceString($List2, $FoundAt, " " & $CarData[$FoundAt][1])
    $strinstr = StringInStr($Data, "Heartbeat")
    If $strinstr > 0 Then
        $CheckIn = StringRight($Data, 2)
        $CarData[$FoundAt][2] = $CheckIn
        _GUICtrlListBox_ReplaceString($List3, $FoundAt, " " & $CarData[$FoundAt][2])
    EndIf
    $Log = FileOpen($compName & ".log", 1)
    FileWriteLine($Log, $LineReceived & @CRLF)
    ConsoleWrite($Data & @CRLF) ;;This is for testing purposes only;;
    ;sleep(500)
    FileClose($Log)
EndFunc

Func Quit()
    WriteCars()
    Exit
EndFunc

Func Sort($SortOrder, $SubItem)
    Local $Decending
    If $SortOrder = "^ v" Then
        $Decending = 0
    Else
        $Decending = 1
    EndIf
    _ArraySort($CarData, $Decending, 0, $NumCars, $Subitem)
    Repaint()
EndFunc

Func Repaint()
    For $Index = 0 To $NumCars Step 1
        _GUICtrlListBox_ReplaceString($List1, $Index, " " & $CarData[$Index][0])
        _GUICtrlListBox_ReplaceString($List2, $Index, " " & $CarData[$Index][1])
        _GUICtrlListBox_ReplaceString($List3, $Index, " " & $CarData[$Index][2])
    Next
EndFunc

Func WriteCars()
   Local $FileHandle, $Index
   $FileHandle = FileOpen($CarDatabase, 2)
   For $Index = 0 To $NumCars Step 1
      FileWriteLine($FileHandle, $CarData[$Index][0] & "," & $CarData[$Index][1] & "," & $CarData[$Index][2])
   Next
   FileClose($FileHandle)
EndFunc


Func ReadCars()
   Local $FileHandle, $Line, $LineStrip
   $FileHandle = FileOpen($CarDatabase, 0)
   While 1
      $Line = FileReadLine($FileHandle)
      If @error = -1 Then
         ExitLoop
      EndIf
   $NumCars += 1
   $LineStrip = StringSplit($Line, ",")
   $CarData[$NumCars][0] = $LineStrip[1]
   $CarData[$NumCars][1] = $LineStrip[2]
   $CarData[$NumCars][2] = $LineStrip[3]
   WEnd
   FileClose($FileHandle)
EndFunc

Func FindCar($LookFor)
   Local $Found = -1, $Index
   If $NumCars = -1 Then
      Return $Found
   EndIf
   For $Index = 0 To $NumCars Step 1
      If $LookFor = $CarData[$Index][0] Then
         $Found = $Index
         ExitLoop
      EndIf
   Next
   return $Found
EndFunc


Func GUI()
   Local $Index
   $GUIhandle = GUICreate("Archangel Log Collection", 1000, 750)
   GUICtrlCreateLabel("Sort Method:", 185, 13)
   GUICtrlCreateLabel("Sort Method:", 485, 13)
   $ButtonAZ = GUICtrlCreateButton("5", 250, 5, 30)
   GUICtrlSetFont($ButtonAZ, 10, 600, -1, "Webdings")
   $ButtonZA = GUICtrlCreateButton("6", 280, 5, 30)
   GUICtrlSetFont($ButtonZA, 10, 600, -1, "Webdings")
   $Button19 = GUICtrlCreateButton("5", 550, 5, 30)
   GUICtrlSetFont($Button19, 10, 600, -1, "Webdings")
   $Button91 = GUICtrlCreateButton("6", 580, 5, 30)
   GUICtrlSetFont($Button91, 10, 600, -1, "Webdings")
   GUICtrlCreateLabel("Computer Name", 60, 13)
   $List1 = GUICtrlCreateList("", 60, 35, 250, 650, BitOr($WS_BORDER, $WS_VSCROLL)) ;;$ES_READONLY incase you don't want to be able to select text
   GUICtrlCreateLabel("Date/Time", 360, 13)
   $List2 = GUICtrlCreateList("", 360, 35, 250, 650, BitOr($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
   GUICtrlCreateLabel("Speed Limit", 660, 13)
   $List3 = GUICtrlCreateList("", 660, 35, 250, 650, BitOr($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
   GUICtrlCreateLabel("Warning Window", 60, 680)
   $List4 = GUICtrlCreateList("", 60, 705, 850, 45, BitOr($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
   GUICtrlCreateLabel("Active Connections: ", 780, 680)
   $ActiveConnections = GUICtrlCreateList($UsersConnected, 880, 678, 30, 30)
   GUISetState(@SW_SHOW) ;shows the GUI window
   For $Index = 0 To $MaxCars Step 1
      _GUICtrlListBox_AddString($List1, " ")
      _GUICtrlListBox_AddString($List2, " ")
      _GUICtrlListBox_AddString($List3, " ")
   Next
   Repaint()
EndFunc

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
   Local $sData, $sFile, $cEdit_2
   #forceref $hWnd, $iMsg, $lParam
   $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
   $iCode = BitShift($wParam, 16) ; Hi Word
   Switch $iCode
     Case $LBN_DBLCLK
         Switch $iIDFrom
             Case $List1
                 $sData = GUICtrlRead($List1) ; Use the native function
                 $sData = StringStripWS($sData, 1) ;strips the space before the data
                 $sFile = FileRead($sData & ".log") ; Read the file
                 $hChild_1 = GUICreate($sData & " - Log", 500, 500, 600, 0, Default, Default, $GUIhandle)
                 $cEdit_2 = GUICtrlCreateEdit("", 10, 10, 480, 480, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
                 GUICtrlSetData($cEdit_2, $sFile)
                 GUISetState()
                 ControlSend($hChild_1, "", $cEdit_2, "^{HOME}") ; This unselects the text

         EndSwitch
EndSwitch
EndFunc

Edited by JonBMN

Share this post


Link to post
Share on other sites

Also to add, this works with a client that will not send unless the connection is active. The client is sending when I have the compiled server running I am just not getting a single message on my GUI. Any suggestions on why that is?

Share this post


Link to post
Share on other sites

I did a quick and dirty example and compiled it and ran it and it completely worked.

#include "TCP.au3"


HotKeySet("{Esc}", "Quit")
$hServer = _TCP_Server_Create(21230); A server. Tadaa!

_TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server.
_TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects.
_TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Receive"); And this,... when we receive something from the client side

While 1

WEnd



Func NewClient($hSocket, $iError); Yo, check this out! It's an $iError parameter! (In case you didn't noticed: It's in every function)
EndFunc   ;==>NewClient

Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P
EndFunc   ;==>Disconnect

Func Receive($hSocket, $sReceived, $iError)
    MsgBox(0, "", $sReceived)
EndFunc   ;==>Receive

Func Quit()
    Exit
EndFunc   ;==>Quit

What's different that it won't work in my script in my post above, but will work in this little example?

Share this post


Link to post
Share on other sites

So I got it to work, but the problem was with the Directives specified at the top.

#AutoIt3Wrapper_Run_Obfuscator=y

needed to be:

#AutoIt3Wrapper_Run_Obfuscator=n

Why is that so? Can anyone shed some light on this?

Share this post


Link to post
Share on other sites

What messages, if any, do you get when compiling the script? Does it mention the use of Call or Execute?

One other thing, you have these lines

WEnd

;END MAIN LINE

_TCP_Server_ClientList()

The last line won't get executed because it's after the While loop, and your script never leaves the While loop, so it never gets to that line.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

@BrewManNH I do not want it to execute. I just put it there so that I might use it later, but forgot to take it out after I was done.

the errors I get say that the _TCP_Send function from the TCP.au3::

-### StripOnly/StripFunc Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by this Function.

>### current Func: ___TCP_OnAccept

C:UsersJonBecherDesktopTCPServer100TCP.au3(139,1) Warning for line:Call($__TCP_SOCKETS[0][6], 0, $iError)

Share this post


Link to post
Share on other sites

There you go, it told you why it won't run, and you ignored it.

There are ways to prevent this from causing problems when using /striponly. If you add this line #Obfuscator_Ignore_Funcs= at the top of the TCP.au3 file, and add in the names of the functions that get stripped out because of the Call statement, you can avoid this and still use the /striponly part of obfuscator.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

@BrewManNH I do not want it to execute. I just put it there so that I might use it later, but forgot to take it out after I was done.

the errors I get say that the _TCP_Send function from the TCP.au3::

-### StripOnly/StripFunc Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by this Function.

>### current Func: ___TCP_OnAccept

C:UsersJonBecherDesktopTCPServer100TCP.au3(139,1) Warning for line:Call($__TCP_SOCKETS[0][6], 0, $iError)

So you seriously thought you could ignore these and expect your script to run ...huh ?

Share this post


Link to post
Share on other sites

It's running without that so yes I did.

PS: if you can't respond courteously then don't respond at all. Basic rules you learn in 1st grade. Do you want me to come into your topic and make you feel stupid when the question has already been answered? No I didn't think so, also we already had this whole discussion on an old topic how you don't need to be rude especially when your not even answering a question.

Edited by JonBMN

Share this post


Link to post
Share on other sites

It's running without that so yes I did.

PS: if you can't respond courteously then don't respond at all. Basic rules you learn in 1st grade. Do you want me to come into your topic and make you feel stupid when the question has already been answered? No I didn't think so, also we already had this whole discussion on an old topic how you don't need to be rude especially when your not even answering a question.

Think we went down this road before if my memory serves me right, but won't drag it too long this time.

I have learned never to ignore statements that explicitly tell you that your script will be crippled.

That is all I am contributing here today and wish you success ignoring warnings I have programmed in Obfuscator, but please do not moan about it when it doesn't work, since you are informed about it. ;)

Jos

Edited by Jos

Share this post


Link to post
Share on other sites

If we went down this road again, then why did you do it again? I literally do not understand why you think it is okay to make a rude statement when the question has already been answered. Not once did I moan and groan about how it didn't work. I didn't understand it and therefore I asked a question about it. I don't understand how you think everyone is suppose to be a god when it comes to autoIT and know exactly how to read and fix errors that come up.

That's why these forums are here, TO ASK QUESTIONS ABOUT THINGS YOU DO NOT UNDERSTAND. Not get criticized when your just looking for an answer to a question (that you have done a ton of work on might I add). I thought I did good debugging in which I found what was not letting me run it and then asked how to fix it, then got the push in the right direction and went to work. I don't understand how you think you are justified to come into someones post when what you said has already been stated by someone else, and then bash them for making a little mistake that they are in the process of trying to fix.

You say you don't want this to drag on, but yet you still make YET ANOTHER rude comment, "wish you success ignoring warnings". Seriously what is your problem? Do you wish to just piss everyone away from autoIT or what? Have some respect just like you'd want.

Share this post


Link to post
Share on other sites

If I've ever seen a 12 year its you. Saying whatever instead of explaining yourself to me without making a condescending statement like an adult is utterly childish. Don't respond to topics that don't need your help, especially if your just going to be an asshole and make yourself look like you have god complex if I've ever seen one.

Share this post


Link to post
Share on other sites

Funny to see you doing the exact same thing as the other thread and you think I have a problem?

This thread has run it's course.

*Click*

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Similar Content

    • By tarretarretarre
      Autoit-Socket-IO
      Introduction
      Autoit-Socket-IO is a event driven TCP/IP wrapper heavily inspired from Socket.IO with focus on user friendliness and long term sustainability.
      I created this UDF because I was fascinated how Socket.IO made a such scary task "reliable and secure networking" so simple for the developer. So this was my main motivation.
      I constantly want to make this UDF faster and better, so if you have any suggestions. Do not hesitate to make requests!
      Features
      Flexiable and easy to understand API Above avarage documentation "Fully featured" examples Security in form of data encryption and middleware-support Limitations
      Speed. Because I want this UDF to be as flexible and simple as possible. Sometimes speed is sacrificed, but that does not mean i don't try to . It is not possible to emit objects mainly because autoit does not support serialization. Only 1D-arrays can be emitted (2D arrays will probably never be supported) Success story
      Since December 2017-now I have used version 1.5.0 in an production environment for 40+ clients with great success, the only downtime is planned windows updates and power outages.
      Getting started
      Download the script from AutoIt or pull it from the official github repo git@github.com:tarreislam/Autoit-Socket-IO.git and checkout the tag 2.0.0 The documentation is located at Docs\index.html Take a look in the examples/ folder Changelog
      Version 2.0.0 (This update break scripts. Please consult the upgrade.md for guidance)
      All global internal variables has been renamed. Added a bunch of new API methods: _Io_RegisterMiddleware, _Io_whoAmI, _Io_IsClient, _Io_IsServer, _Io_getAllByProperty and _Io_getFirstByProperty and some more. Read more about these in the documentation. _Io_socketGetProperty now has a setter method called _Io_socketSetProperty which can be used to set custom properties. _Io_socketGetProperty now has a third parameter "default" which is used when a property is not found Removed _Io_setEventPostScript and _Io_setEventPretScript in favor of _Io_RegisterMiddleware Improved documentation (It still needs some love though) Improved the verbosity of _Io_DevDebug  
      Newest version (2019-09-29!)
      Autoit-Socket-IO-2.0.0.zip
      Older versions (Not supported anymore)
      Autoit-Socket-IO-1.0.0.zip Autoit-Socket-IO-1.1.0.zip Autoit-Socket-IO-1.3.0.zip Autoit-Socket-IO-1.4.0.zip Autoit-Socket-IO-1.5.0.zip
    • By AoRaToS
      I started working on this program in the summer of 2008 then I stopped cause I faced some problems I couldn't overcome back then. Now that I've practiced more and have become a better scripter/programmer I'm releasing the program to the public to get some opinions. I know it's not a new concept but it's the first program I started besides some small stuff I did just for practice! I won't post the source code yet because it's still under construction, although I'm sure I've posted early stages of the code with bugs in the past in some topic...
      What I wanted was a simple, small, serverless program that would work without installation cause I wanted it for where I work, so I ended up with this!
      I have attached some images of various versions, also visit the forum thread.
      The package includes s!mpL3 LAN Messenger and the full change log.
      Current version 2.9.9.1! [04/07/2019]
      Check the Change Log below!
       
       
      http://www.autoitscript.com/forum/index.php?showtopic=88782
       
       
       
      Read the license before using this software.
       
    • By SgtHugoStiglitz
      HI people,
                        I got a questions, I maintain code in autoIT and every time I compile a new version or modification, Scite generate 2 folders. One folder is finish by released and the other is tentative. I try to make some google search, but never find answer would satisfied myself. The dev who was maintain it before were using AutoIt3Wrapper_GUI, and I don't know if it's related. I look both folder, but they seem pretty identical, but I would like to know what it's the difference between those to folder. Anyone have a clue?
    • By Rhidlor
      I don't have any experience compiling AutoIt scripts or know of any best practices regarding said scripts so I was wondering, what are some of the options for passing data to complied scripts? Here's an example of what I mean by "option": Writing data to a text file, then running a script which reads the data from that text file.
      Thanks!
      I apologize if this topic is a little lackluster
    • By Skeletor
      Hey All,
      Yes, this is an odd request. 
      But is there a way to bulk up the size of the compiled program? 
      I know many want to reduce it's size, but I want to increase it.
      What methods do you suggest?
×
×
  • Create New...