Help with a script to listen to a port

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kidbit
Posts: 168
Joined: 02 Oct 2013, 16:05

Re: Help with a script to listen to a port

29 Oct 2013, 10:34

it shows "108"
question := (2b) || !(2b) © Shakespeare.
just me
Posts: 9763
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Help with a script to listen to a port

29 Oct 2013, 10:47

Try this:

Code: Select all

   Recv:
   ...
   ...
   Received := ""
   Received := StrGet(&Buffer, RecvLen, "CP0")
   If (StrLen(Received) < Result) { 
      Received := ""
      Loop, %RecvLen%
         Received .= FormatIntHex(NumGet(Buffer, A_Index - 1, "UChar"), "Char")
   }

Code: Select all

FormatIntHex(Int, Typ := "Auto") {
   ; Returns the hexadecimal string represention of the passed integer value.
   ; Int - Integer value in the range of -9223372036854775808 to 9223372036854775807
   ; Typ - Type to determine the size of the returned hex string.
   ;       You may pass one of the keys in the 'Types' object. If the parameter is omitted or 'Auto'
   ;       is passed explicitely, the size will be determined as 'Int64', 'Int', 'Short', or 'Char'
   ;       according to the value of 'Int'.
   Static Types := {Int64: 16, Int: 8, Color: 6, Short: 4, Char: 2, Ptr: (A_PtrSize = 8 ? 16 : 8)}
   If Int Is Not Integer
      Return ""
   If (Typ = "Auto")
      If (Int <= 127) && (Int >= -128)
         Len := 2
      Else If (Int <= 32767) && (Int >= -32768)
         Len := 4
      Else If (Int <= 2147483647) && (Int >= -2147483648)
         Len := 8
      Else
         Len := 16
   Else If Typ Is Integer
      Len := Typ
   Else If !(Len := Types[Typ])
      Return ""
   VarSetCapacity(Hex, 17 << !!A_IsUnicode, 0)
   If (DllCall("Shlwapi.dll\wnsprintf", "Str", Hex, "Int", 17, "Str", "%016I64X", "UInt64", Int, "Int") = 16)
      Return SubStr(Hex, StrLen(Hex) - Len + 1)
   Return ""
}
Edit: Missing ) in If (StrLen(Received) < Result) {
kidbit
Posts: 168
Joined: 02 Oct 2013, 16:05

Re: Help with a script to listen to a port

29 Oct 2013, 11:19

yay, that works, thanks a lot just me, you are so cool!

Oh, god, I can configure packets differently, so that I could bind each of them to a specific command, that's mega-awesome!
question := (2b) || !(2b) © Shakespeare.
just me
Posts: 9763
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Help with a script to listen to a port

29 Oct 2013, 11:31

You're welcome! ;)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 144 guests