In this article I want to tell you about the experiment that I set for myself.
I have been working remotely (outsourcing) for a long time and as a result I have to provide a monthly report on the work done, in the form of a table with the name of the tasks, time spent and other information. Even with a huge availability of ticket systems, use them daily to record the work done - hard labor. In a company where I work there are no strict requirements for logging or other daily reports, which probably makes my problem of lack of daily data a single, or at least not so popular (or not, maybe I am not the only such outsourcer?). The month flies by unnoticed and with full immersion in work, instead of immersion in bureaucracy, since everything is built on trust. And until recently, I coped with the task of compiling monthly reports, because almost every day I at least greeted my skype colleagues, chatted about this, including workflow, updated tickets, received letters. But here's the trouble, the preserved data is not always available on the right day, in which at least kill yourself you can not remember what you did. And at one such moment, while compiling such a report, it suddenly struck me, as I, a programmer, can solve this problem for myself from now on.
Programmers, because they, like any other specialists, have a knowledge base in their field and should use it not only for work. Like for example, doctors have a whole bunch of pills, syringes and other devices at home. The mechanic is always a whole bunch of parts and tools, unscrew, nail, drill ... But I apparently fell under the classic phrase "shoemaker without shoes." My PC is assembled on a table in pieces of boards and wires, the operating system has not been swapped for a million years, but oh well. I may be a shoemaker without boots, but the problem still needs to be solved, and I decided to patch up my boots.
Having formed an idea to solve a problem in my head, I first decided to discuss it with friends what they think about it. As it turned out, I even threw a couple of links to ready-made solutions. At first I was upset that my idea had already been implemented, on the other hand I did not even try to try the solutions offered to me, because I was convinced of the ease of implementation and security of my own decision. Actually, what is the idea itself?
')
My solution to the problem of logging was to write a spyware program that would do all this work for me and hang constantly in the system tray. For a couple of minutes I came up with several functions for such a program. Here are some of the features invented:
- Screenshot
- Shooting short video clips screen
- Clipboard saving
- Start spying on a schedule (only during customized hours and only on weekdays)
This is a periodicity with a frequency of N seconds / minutes / hours (configurable in the program), i.e. with N equal to 1 minute, we get 8 * 60 = 480 images for an eight-hour working day. One shot takes ~ 700 KB, rounded up to a megabyte, so 480 megabytes of images will accumulate in one working day. For a month it will be 14 gigabytes. I agree, the figure is scary. But I personally still have a place, and there is no need to save for more than a month, plus or minus. As an option, you can use clouds with unlimited space (there seems to be such, not?), I personally do not use such services, I do not know. But theoretically and in a vacuum, it is possible to accumulate data on work for arbitrarily months / years, while having access to your own data from everywhere. Another optimization option is to reduce the image size before saving or lengthen the period N.
So this is the minimum set of espionage tasks that came to my mind. If you wrap everything up in a beautiful interface, then perhaps the process of reading logs will become even enjoyable. I had C # on hand, in which I did some small task at work not so long ago. Accordingly, the choice fell on C #.
Using the free time in the evening, I began to implement the first function, since it is the easiest, and frankly, the only potentially useful in my task. If someone else has not fully understood the essence, then here it is: from the screenshots you can understand what you did during the day. Shooting a video is most likely a rudimentary idea, and will be deleted, because it does not carry much benefit. But with the clipboard while I think. At the moment, the function is not implemented, but it is intended to regularly save the clipboard (text) to the database on the hard disk. This is nothing but a record of the form.
id | datetime | buffer
Actually, the shorter the N frequency, the more data the spy will collect. From the contents of the clipboard, you can understand that you programmed and copied at a specific date and time.
Of course, I decided to make the first implementation as simple and fast as possible. So that the title of the program was not
Form1, I introduced the first thing that
Work Spy had to mind, and so my brainchild was called. By the way, its original appearance, containing only one box with rich text (RichTextBox), which in turn was nothing but a simple window of the log where, when and what it saved:

Writing took about 10 minutes. A couple of requests to google and now we’ve already got some examples of the code for “how to take a screenshot of c #”. My spy creates a folder, calling it today's date, and accordingly during the work of the program, using the
Timer class, puts pictures of my two monitors inside (image size 3840x1080), whose name also consists of the date and time (I decided that I would use such template
12_03_2012__12_30_36.gif ). Image format - gif, in order to save space. Despite the graininess of the image, everything is clearly visible on it.
The first version is written, makes a minimum of gestures, all the settings so far are sewn into the code, instead of convenient elements on the form for setting up the program. Test debugging is over, it's time to try running the program offline, rather than pressing F5. With the first launch, I was congratulated by avast !, “drawing” attention to my program. Congratulations from the antivirus looked like this:

It remains a mystery to me, as he identified the potential harm in these ~ 100 lines of code, but on the other hand, it is nice that even the simplest samopisny spy was able to suspect that something was wrong. Not finding sufficient evidence of harm, avast! apologized

I politely asked the respected avast! open my program as usual, and not in the sandbox, because I trust it 100%.
At the moment everything is still in manual test mode. Daily start / close and view saved snapshots. The program has worked so far for a week. The result is already impressive. If I open pictures from the launch day, I clearly see my browser, a text editor, in which I see tabs and the code of the project I'm working on. Sometimes there are funny pictures where I watch a movie (probably a break, ayay ay, during the working day), or write a message on a social network. It is the self-writing of the program that removes any excitement and fear for what is captured on the screen, but the most unexpected and unpredictable :) joke can be captured.
Perhaps all that I wanted to tell. The experiment continues, and I am sure that I will be satisfied by the end of the month. It remains to agree with the willpower and finish the handles and legs to the body so that everything works as comfortable as possible. The moral of the story is that 10 minutes and knowledge can solve big problems.
In order to endow the article with benefits, I will leave links to the solutions that I have been advised to solve problems like mine. I do not answer for the adequacy of the programs, because I did not even download them to watch.
www.debugmode.com/winktaskwarrior.org/projects/show/taskwarrior