amfony Posted November 19, 2009 Share Posted November 19, 2009 Hi All, I have made a simple application that will: screen scrape at every mouse click dump jpg to local folder on startup delete folders (of screen dumps) that are older then X Very simple. I want to 'service' this app so it can run in a lab with or without user logged on, load with the computer, and most importantly not fail. What ive done so far: created a service via the sc.exe command with the options of type = own and interact (with desktop) pointed it to the compiled script and ... error. The service is not responding to the control function. I attributed this to the app never ending as it will loop looking for mouseclick forever. I then created a service pointing to a launcher.exe that simply calls the screen scraper exe and that is my current work around. What this doesnt do though it make my 'service' durable. If the screen scrape app fails (which it does for some reason) it does not restart as it it not the 'serviced' the launcher.exe is. I think i have my thought process is wrong with writing a service in general, what a service executable should do (ie not loop) and how i can get the result i require. TIA for any tips and direction. expandcollapse popupAutoItSetOption("TrayIconHide", 1) AutoItSetOption("TrayIconDebug", 1) #Include <ScreenCapture.au3> #Include <Misc.au3> #Include <date.au3> #Include <File.au3> #Include <Array.au3> $today = @YEAR&"-"&@MON&"-"&@MDAY _ScreenCapture_SetJPGQuality(40) $dll = DllOpen("user32.dll") _FileListToArray("C:\captures") If Not @error= 4 Then $Folders_Array = _FileListToArray("C:\captures") ;_ArrayDisplay($Folders_Array) $i = 0 For $day in $Folders_Array ConsoleWrite(_DateDiff("D",$Folders_Array[$i],$today) & @CRLF) if _DateDiff("D",$Folders_Array[$i],$today) > 7 Then ConsoleWrite("deleting: "&"C:\CAPTURES\"&$day&@CRLF) DirRemove("C:\CAPTURES\"&$day,1) EndIf $i = $i + 1 Next EndIf While 1 Sleep ( 50 ) If _IsPressed("01", $dll) Then ScreenCap() ;exit WEnd DllClose($dll) ;================================================= Func ScreenCap() Local $hBmp $user = RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultUserName") if not FileExists("C:\captures\"&@YEAR&"-"&@MON&"-"&@MDAY&"\"&$user) Then DirCreate("C:\captures\"&@YEAR&"-"&@MON&"-"&@MDAY&"\"&$user) ; Capture full screen $hBmp = _ScreenCapture_Capture ("") ; Save bitmap to file _ScreenCapture_SaveImage ("C:\captures\"&@YEAR&"-"&@MON&"-"&@MDAY&"\"&$user&"\"&@HOUR&"-"&@MIN&"-"&@SEC&"-"&$user&".jpg", $hBmp) EndFunc ;==>_Main Link to comment Share on other sites More sharing options...
spudw2k Posted November 20, 2009 Share Posted November 20, 2009 (edited) Check out this thread for how to compile a proper service script: http://www.autoitscript.com/forum/index.php?showtopic=80201&view=&hl=&fromsearch=1 Also, you'll have to think about the services running user. I believe by default (SYSTEM) would not be able to capture screenshots of a logged in user if it is not Interactive. Edited November 20, 2009 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
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