MrKris1224 Posted April 28, 2018 Posted April 28, 2018 (edited) Hi, i'm trying to make communication between script in autoit and php script. I tried communication via file but i think it's too slow. Now i trying to make it on TCP but something is wrong and scripts doesn't work. this is the code of scripts: #include <ScreenCapture.au3> TCPStartup() OnAutoItExitRegister("OnAutoItExit") Global $Client _ScreenCapture_SetJPGQuality(35) $Listen = TCPListen("127.0.0.1", 3030, 20) While 1 $Client = TCPAccept($Listen) If $Client <> -1 Then _ScreenCapture_Capture("D:/xampp/htdocs/desktop.jpg") TCPSend($Client, "1") EndIf Sleep(5) WEnd Func OnAutoItExit() TCPShutdown() EndFunc <?php $fp = fsockopen("127.0.0.1", 3030); while(fgets($fp, 2) != "1")) { usleep(5000); } ?> The PHP server is local. I trying to achieve if i execute php script that connecting to tcp autoit server and wait for response string "1" then just exit. Edited April 28, 2018 by MrKris1224
ripdad Posted April 29, 2018 Posted April 29, 2018 It might help to debug if error checking was in place... expandcollapse popup#include 'ScreenCapture.au3' ; Opt('MustDeclareVars', 1) ; TCPStartup() Opt('TCPTimeout', 10); <- needed for Autoit v3.3.10 to v3.3.15 OnAutoItExitRegister("OnAutoItExit") ; Local $Client, $Listen, $nError, $sFile = 'D:\xampp\htdocs\desktop.jpg' _ScreenCapture_SetJPGQuality(35) ; $Listen = TCPListen("127.0.0.1", 3030, 20) $nError = @error If $nError Then MsgBox(8208, 'Error', 'TCPListen: ' & $nError) Exit EndIf ; While 1 $Client = TCPAccept($Listen) If $Client > 0 Then If FileExists($sFile) Then FileDelete($sFile) EndIf ; _ScreenCapture_Capture($sFile) TCPSend($Client, "1") $nError = @error If $nError Then MsgBox(8208, 'Error', 'TCPSend: ' & $nError) EndIf ; Sleep(1000) TCPCloseSocket($Client) EndIf Sleep(10) WEnd ; Func OnAutoItExit() TCPShutdown() EndFunc "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
ripdad Posted April 30, 2018 Posted April 30, 2018 I don't know about php, so I have no way to test it from that side. The script I posted above does work with another AutoIt script that I used to test with. So, perhaps the issue is on the php side. (OT: I wonder what happened to the post number counts in the forum. I sure do miss them!) "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
bernd670 Posted May 5, 2018 Posted May 5, 2018 Hello, try to open a tcp socket in php. See <here> Example #2 greetingsbernd I hacked 127.0.0.1 ->
junkew Posted May 5, 2018 Posted May 5, 2018 First try AutoIt example both server-client in AutoIt https://www.autoitscript.com/autoit3/docs/functions/TCPAccept.htm Then start writing one of them in php FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now