Jump to content

Recommended Posts

  • 2 weeks later...
  • 3 months later...
Posted

What if you have a rather large compiled exe? it looks like you would be dealing with AutoIt Exe*N threads. What if you were to modify N_GetBinaryModule so that it detects the script resource and omits it?

What is what? What is what.

  • 2 months later...
  • 1 year later...
Posted

This is great! I love it!

I hope that I'm not asking a newb question ... is there a way to exit a thread?

For instance:

1st thread: I start a thread with a GUI. Then I spawn a 2nd thread from here ...

2nd thread: This thread has a TCPRecv in a loop which is always listening to a networked device. The messages received from this device then go into a shared global queue. The GUI then updates itself based on the messages found in the queue.

3rd thread: Then I want to start a thread from the 2nd thread that will process the messages received from the network (shortens them and converts them from binary). I want to be able to exit that third thread. 

Or does it happen that way and I'm just looking at this all wrong?

The following code does not demonstrate my intentions. Just sharing it for completeness. (Also, it  doesn't actually implement a real queue data structure at the moment.)

#AutoIt3Wrapper_Version=B
#Autoit3Wrapper_Testing=y
#autoit3Wrapper_jump_to_first_error=y
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 4 -w 5 -w 6 -w 7 -d

#NoTrayIcon

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include "N.au3"

OnAutoItExitRegister(OnAutoItExit)

Global $queue = NGlobal()

NMain("Main")

Func Main()
    GUICreate("EISCP", 520, 350)

    Local Const $edit = GUICtrlCreateEdit('', 10, 10, 500, 330, $ES_AUTOVSCROLL + $WS_VSCROLL)

    GUISetState(@SW_SHOWNORMAL)

    NRun("Recv")

    Do
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch

        GUICtrlSetData($edit, $queue.Command, 1)

        Sleep(100)
    Until False
EndFunc

Func Recv()
    TCPStartup()

    Local Const $sIPAddress = "192.168.0.209"

    Local Const $iPort = 60128

    Local Const $ConnectedSocket = TCPConnect($sIPAddress, $iPort)

    Local $command

    Do
        $command = TCPRecv($ConnectedSocket, 2048)

        If $command Then
            $queue.Command = ExtractCommand($command)
        EndIf

        Sleep(50)
    Until False
EndFunc

Func ExtractCommand($command)
    $command = BinaryMid($command, 5) ; lop off "ISCP"

    $command = BinaryMid($command, 15)

    $command = BinaryMid($command, 1, BinaryLen($command) - 3)

    Return String(BinaryToString($command))
EndFunc

Func OnAutoItExit()
    TCPShutdown()
EndFunc

 

  • Moderators
Posted

https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread

TerminateThread, but I read somewhere that GetCurrentThreadId from Kernel32 dll was deprecated, so I can't see "TerminateThread" from the processthreadsapi api being to safe tbh.

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.

  • 3 months later...
Posted

Hello,

I have a problem with this UDF. I putted the N.au3 file in UDF folder, and dlls in system 32 and sysWow64, and in UDF folder as well but i still get:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Cyberpunkt\Desktop\Tomek\autoit\N-0.2a\test_1.au3" /UserParams    
+>13:26:57 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000415  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0415)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Cyberpunkt\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Cyberpunkt\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.16.1)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\Cyberpunkt\Desktop\Tomek\autoit\N-0.2a\test_1.au3
+>13:26:57 AU3Check ended.rc:0
>Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Cyberpunkt\Desktop\Tomek\autoit\N-0.2a\test_1.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
!>13:26:58 AutoIt3.exe ended.rc:-1073741819
+>13:26:58 AutoIt3Wrapper Finished.
>Exit code: 3221225477    Time: 1.967

I'm trying to run the test files from author.

I suppose that, i'm doing some stupid, mistake. Can you help me?

 

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
  • Recently Browsing   0 members

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