Closed skygate2012 closed 9 months ago
@thqby Thank you so much for the fix. :) Can you also have a look at Socket.ahk? It appears to have a similar problem when receiving text, though I'm not 100% sure yet if it's server-side issue.
Socket messages have no boundaries, and when you receive a message, there may be a part of it that arrives later.
Perhaps add the option to define boundaries like \r\n?
Use RecvLine
to receive the message
https://www.autohotkey.com/boards/viewtopic.php?p=503678#p503678 This is the jsonrpc implementation
Each message is formatted like Content-Length: 9\r\n{"key":1}
.
Thanks. :)
@thqby Hi again, I just noticed regarding child_process.ahk, it's not wrapping text randomly now but sometimes it cuts off one or two characters in the beginning.
what?
After some further testing, it seems whenever the 0
character is present it will sometimes be dropped. It probably has something to do with relying on truthy/falsy for getting stdout?
Try this:
#Requires AutoHotkey v2.0
#SingleInstance Force
Loop {
Proc := child_process("adb shell ls /sdcard/test", , true)
Proc.Call()
Result := Proc.GetLastStdout()
Tooltip Result
}
If there is a file with a name like 0001000
under /sdcard/test
, the zero will be randomly missing either from the beginning or the end, but the 1 always stays.
I don't have adb, so use cmd.exe /c dir /b
, but can't reproduce it.
Yes this one only happens in adb as well. There might be others sharing the same problem but I haven't found it yet. I can confirm though that adb is working properly if I use ComObject("WScript.Shell")
.
I thought that would fix it, but it did not. Then I found there is another check relying on a falsy condition:
else if !line
break
Changing this to also check for blank string finally solved it.
This is strange because I was unable to reproduce it with other command line outputs, only that of adb, and it seems to occur randomly. For example, when I call
ls
for a folder throughadb shell
, the directory names are wrapped to the next line randomly.The results below are all produced with the same code above: 1.
2.
3.