johnwayne Posted December 10, 2019 Posted December 10, 2019 attempting to create a simple webcam enable/disable system. on my phone a simple ftp app with 2 files: camera_on.txt and camera_off.txt , both files are blank. dynamic IP is tied to a domain, ftp port forwarding through the firewall. local pc (always on) with webcam attached and ftp server running. ftp up the camera_on.txt file, and a folder watching program fires off cameraON.au3 . afterwards ftp up the camera_off.txt file, and the folder watching program fires off cameraOFF.au3 . cameraON.au3 is SUPPOSED to: prevent multiple script instance launches (the folder watcher often duplicates), open the webcam software (which always opens in the same screen position), click the motion detection button, delete the camera_disengaged.txt file (if exists) from the ftp folder, delete the camera_on.txt file from the ftp folder, create a camera_is_armed.txt file in the ftp folder. then the cameraOFF.au3 is SUPPOSED to: prevent multiple script instance launches, kill the webcam task, delete the camera_is_armed.txt file from the ftp folder, delete the camera_off.txt file from the ftp folder, create a camera_disengaged.txt file in the ftp folder. deletion and creation of files in the ftp folder creates the situation that viewing the ftp folder from the phone app shows what the current status of the camera is - inferred by the remaining visible filename. It mostly works, but problem currently is: frequently the camera_off.txt file is not deleted as expected, amongst other random intermittent partial failures. here is the code for the 2 script files: cameraON.au3 #include <AutoItConstants.au3> #include <Misc.au3> #include <File.au3> ;#include <MsgBoxConstants.au3> If _Singleton("camera-ON", 1) = 0 Then Exit EndIf onny1() Func onny1() ; Run Run("C:\Program Files (x86)\Logitech\LWS\Webcam Software\MotionDetection.exe") ; Wait for 10 seconds. Sleep(10000) ; click at the x, y position of 0, 500. MouseClick($MOUSE_CLICK_PRIMARY, 522, 640, 1) Sleep(500) FileDelete("c:\camswitch\camera_disengaged.txt") Sleep(500) $File="c:\camswitch\camera_is_armed.txt" _FileCreate ( $File ) Sleep(500) EndFunc onny2() Func onny2() FileDelete("c:\camswitch\camera_on.txt") Sleep(500) EndFunc cameraOFF.au3 #include <AutoItConstants.au3> #include <Misc.au3> #include <File.au3> ;#include <MsgBoxConstants.au3> If _Singleton("camera-OFF", 1) = 0 Then Exit EndIf offy1() Func offy1() ; Run Run('taskkill /F /IM "MotionDetection.exe"') Sleep(500) FileDelete("c:\camswitch\camera_is_armed.txt") Sleep(500) $File="c:\camswitch\camera_disengaged.txt" _FileCreate ( $File ) Sleep(500) FileDelete("c:\camswitch\camera_off.txt") Sleep(1000) EndFunc at a glance the code seems inefficient and clunky, and I agree, it has gone through many iterations, and "progressed" into this poor syntax in an effort to reduce the failure rate of the scripts performing all their tasks. When written efficiently - the fail rate of file deletions, creations and such was much higher. Additionally the use of fileMove to rename files failed frequently. The machine in question is Windows 10 Pro 64-bit, Athlon II x4 645, 8gb ram, ssd. I am relatively new to AutoIT, and am in need of some direction. thanks in advance. The folderwatching software also watches the webcam's record folder and fires off an email when a new recording is created, but that has nothing to do with the scripts. in the script, the prevention of multiple instances is just that, prevention. no warnings or click-to-continues, etc.
Moderators JLogan3o13 Posted December 11, 2019 Moderators Posted December 11, 2019 (edited) Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team Edited December 11, 2019 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
johnwayne Posted December 11, 2019 Author Posted December 11, 2019 @JLogan3o13 thank you for the move.
johnwayne Posted December 11, 2019 Author Posted December 11, 2019 @JLogan3o13 can you remove this topic of mine? turns out that the ftp app i was using on the phone was what was messing with autoit and with the folderwatching software. changed the phone ftp app and now all works great. a free app had me searching for help where it wasnt actually needed. thanks in advance. fwiw, dont use the app FTP RUSH.
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