📜 ⬆️ ⬇️

Programming for non-programmers by April 1

There comes one of the funniest folk holidays - April Fool's Day, or more politically correct - April Fool's Day. Accordingly, the urgent question arises - how to play a trick on colleagues at work without making additional enemies for yourself.

You can, of course, use the classic jokes like:
• ask the test subject how the word “DUNY” is decoded; offer your own version of "We Do Not Have Fools"; and wait for the puzzled "And I?";
• stuff the test villus into the photosensor mouse or simply stick it with tape (in the sense of the sensor) ...

But you can apply more high-tech and sophisticated methods of "demolishing the roof" with the help of joke programs.
')
In principle, on the Internet you can find and download a bunch of such applications. But the launch of such programs is a very dubious and dangerous occupation.

The best option is to write such a program yourself. How to do it quickly, having absolutely no programming skills, you will learn in this article.

1. Download and install the necessary software. For example, from the official site: www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe

2. Additionally, you can download the Russian book guide: autoit-script.ru/autoit_rv_ua/files/Other/AutoIt_v3_Kratkoe_Rukovodstvo.pdf
And install Russian Help (help): u.to/KfkBAQ (for more information, on autoit-script.ru/index.php?topic=10070.0 )

3. Go to the installation folder. By default, C: \ Program Files \ AutoIt3 \ SciTE. Next, run the editor SciTE.exe.

At this preparatory part is over - you can start to "programming".

It has been noticed that many office workers (especially, "people") play in the workplace in the simplest computer games, a classic example of which is Solitaire. Here we will experiment on it. By the way, instead of "Klondike" you can use almost any other program - it is enough to replace the title "Klondike" (the name of the window in the upper left corner with the corresponding application name).

So, launching the editor SciTE.exe, we get a window like this:

image

Let us think: what is the simplest, innocuous and unpleasant thing you can tune the player? Well, of course, close the window "kerchief." By the way, the corresponding operator (translated into English and a bit abbreviated) literally looks like this: WinClose (“Solitaire”):

image

Those. if we run the program compiled on the basis of this line of code on the user's computer, the window (Win) with a kerchief (“Solitaire”) will close (Close).

However, a purely organizational problem appears here ... It is unlikely that a player during the game will allow to run some kind of suspicious program on his computer. In addition, the joke will lose the factors of surprise and anonymity.

Therefore, it would be logical to entrust the task of tracking player actions to the program itself.
To do this, add to it a simple WinWaitActive operator (“Solitaire”), which in Russian means: Wait for the Activation of the “Solitaire” Window.

image

Please note that the new line of code is in the first place, which is quite logical.

Now again we will deal with purely technical details (which are obvious to the programmer, and for a simple user - a dark forest). First, the received program (hereinafter, we will call it the more correct term “script”) must be saved, and secondly - compiled, i.e. get an executable file based on the code (with the extension "exe", "executable").

1. File -> Save As ... -> CloseSol
2. Tools -> Compile -> Compile Script

As a result (if you did not manage to make mistakes in two lines of code) in the source folder (by default, C: \ Program Files \ AutoIt3 \ SciTE) should appear our source code CloseSol.au3 and executable file - CloseSol.exe.

It only remains to run this script (CloseSol.exe) on the subject's computer (for example, from a flash drive) and wait for its reaction.

However, our script, although quite workable, is still very far from perfect.

First, it is "disposable." Those. The effect of the joke will be very short. In order for the script to work until the subject loses consciousness, we simply loop it (script) to endless execution with “operator brackets”: Do and Until 0 = 1, which means Do it Until 0 becomes equal to 1.

image

Secondly, instantly closing the window is too simple a procedure to annoy the player. Therefore, let's make the script wait a few seconds until the player plays: Sleep (30000) - Sleep 30,000 milliseconds (30 seconds).

image

Well and, thirdly, our script in the process of execution will loom in the form of a tray icon than it quickly finds itself. Therefore, we hide it with the Opt command ("TrayIconHide", 1):

image

That's all. It remains to recompile the script and, in the morning of April 1, run it on the experimental computer (s). Everything else is a matter of technique. You can, for example, remove what is happening on the camcorder and put it on the Internet. And you can just invite your friends - see the reaction of the player ...

Well and, of course, you should know how to stop this disgrace at any moment - all you need to do is to go to the “Processes” of the “Task Manager” (called by pressing the Ctrl Alt Del keys) and, having found the corresponding process (CloseSol.exe), (right-click and select "Close process").

By the way, if you call the script with some clever name, for example, service, then even an experienced sysadmin will get tired of looking for the source of the problem. If the program is added to the autorun, it will almost turn out to be a virus - but this is for a particularly p (p) single-handed pranksters.

But seriously, with the help of AutoIt you can easily automate many routine operations, which you used to take a long time to complete. Moreover, all the necessary software you have already installed, and numerous tips and examples can be found in the appropriate forums. But this is not funny.

Source: https://habr.com/ru/post/254609/


All Articles