issue150:tutoriel1
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue150:tutoriel1 [2019/10/31 08:26] – auntiee | issue150:tutoriel1 [2019/10/31 17:41] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Welcome back! In this issue, we continue our automation journey. If you have just joined us, we are automating things in Ubuntu. Last time, I asked you to save your file as test.txt. Did you manage to do it? If not, have a look at what I did. | + | **Welcome back! In this issue, we continue our automation journey. If you have just joined us, we are automating things in Ubuntu. Last time, I asked you to save your file as test.txt. Did you manage to do it? If not, have a look at what I did.** |
- | Code: | + | Ravi de vous revoir ! Dans ce numéro, nous continuons notre voyage dans l' |
+ | |||
+ | **Code: | ||
#! /bin/ bash | #! /bin/ bash | ||
Ligne 17: | Ligne 19: | ||
• A text editor. | • A text editor. | ||
• xdotool on a computer running Ubuntu. | • xdotool on a computer running Ubuntu. | ||
- | • A willingness to learn. | + | • A willingness to learn.** |
- | Briefing | + | Code : |
+ | |||
+ | #! /bin/ bash | ||
+ | mousepad& | ||
+ | sleep 1 | ||
+ | xdotool type "I am too lazy to type this over and over again" | ||
+ | xdotool key Ctrl+S | ||
+ | xdotool type test.txt | ||
+ | xdotool key KP_Enter | ||
+ | xdotool key Alt+S | ||
+ | |||
+ | Ce n'est pas si difficile, n' | ||
+ | |||
+ | Ce dont nous aurons besoin : | ||
+ | ••Un éditeur de texte. | ||
+ | ••xdotool sur un ordinateur sous Ubuntu. | ||
+ | ••La volonté d' | ||
+ | |||
+ | **Briefing | ||
Before we move onto the mouse, what if the program we are opening is already open? (In my case - mousepad). What if we do not want to run a new instance of it every time our script executes? If you had a look at the man page, you would have seen “WINDOW COMMANDS”. Below that, you would have noticed the “- - onlyvisible” “Show only visible windows in the results. This means ones with map state IsViewable.” Now, if you look under the heading “DESKTOP AND WINDOW COMMANDS”, | Before we move onto the mouse, what if the program we are opening is already open? (In my case - mousepad). What if we do not want to run a new instance of it every time our script executes? If you had a look at the man page, you would have seen “WINDOW COMMANDS”. Below that, you would have noticed the “- - onlyvisible” “Show only visible windows in the results. This means ones with map state IsViewable.” Now, if you look under the heading “DESKTOP AND WINDOW COMMANDS”, | ||
Ligne 25: | Ligne 45: | ||
xdotool - -search - -onlyvisible - -class “mousepad& | xdotool - -search - -onlyvisible - -class “mousepad& | ||
- | replace “mousepad& | + | replace “mousepad& |
- | Now oupen mousepad and re-run your script. Are you still with me? Did your text editor get focus and run your script? Great! Let us move forward. (We will look at text and windows in more depth later – I just want to get you excited about what you can do in a short time). If you have done something clever with what we have shown you, please go ahead and show us!). | + | Instructions |
+ | |||
+ | Avant de passer à la souris, que se passe-t-il si le programme que nous ouvrons est déjà ouvert ? (dans mon cas, mousepad) Et que se passe-t-il si nous ne voulons pas lancer une nouvelle instance à chaque fois que notre script s' | ||
+ | |||
+ | xdotool --search --onlyvisible --class “mousepad& | ||
+ | |||
+ | en remplaçant « mousepad& | ||
+ | |||
+ | **Now oupen mousepad and re-run your script. Are you still with me? Did your text editor get focus and run your script? Great! Let us move forward. (We will look at text and windows in more depth later – I just want to get you excited about what you can do in a short time). If you have done something clever with what we have shown you, please go ahead and show us!). | ||
Now let us look at moving the mouse. | Now let us look at moving the mouse. | ||
- | If you noticed in the manpage under “MOUSE COMMANDS”, | + | If you noticed in the manpage under “MOUSE COMMANDS”, |
+ | |||
+ | Maintenant, ouvrez mousepad et relancez votre script. Vous me suivez toujours ? Est-ce que votre éditeur de texte a pris le focus et lancé votre script ? Super ! Continuons. (Nous regarderons plus tard le texte et les fenêtres plus en détail ; je veux simplement vous intéresser à ce que vous pourrez faire dans un laps de temps court. Si vous avez fait quelque chose d' | ||
+ | |||
+ | Maintenant, regardons les mouvements de la souris. | ||
+ | |||
+ | Vous avez peut-être noté que dans la manpage sous « MOUSE COMMANDS » (Commandes de la souris), nous avons « mousemove » et « mousemove_relative » (non, vous ne pouvez pas utiliser votre souris pour déplacer votre grand-mère !). L' | ||
- | Clear your code in myscript.sh, | + | **Clear your code in myscript.sh, |
Try this code: | Try this code: | ||
Ligne 45: | Ligne 79: | ||
xdotool click 3 | xdotool click 3 | ||
- | Instead of holding your hand like the first article, your homework is to make the mouse move to your menu button, click that to start your menu, and click an entry to launch a terminal. You should have all the tools and information you need to do so now. | + | Instead of holding your hand like the first article, your homework is to make the mouse move to your menu button, click that to start your menu, and click an entry to launch a terminal. You should have all the tools and information you need to do so now.** |
+ | Effacez le code de myscript.sh, | ||
+ | Essayez ce code : | ||
+ | #! /bin/bash | ||
+ | xdotool mousemove 200, 200 | ||
+ | sleep 1 | ||
+ | xdotool mousemove 400, 400 | ||
+ | slepp 1 | ||
+ | xdotool click 3 | ||
- | If you are stuck – know that your screen goes from 0,0 in the top left to 0,1920 in the top right, (if your screen size is 1920x1080) and 1080, 0 (if your screen size is 1920x1080) in the bottom left. | + | Au lieu de vous accompagner pas à pas comme dans le premier article, votre travail à la maison est de déplacer la souris jusqu' |
+ | |||
+ | **If you are stuck – know that your screen goes from 0,0 in the top left to 0,1920 in the top right, (if your screen size is 1920x1080) and 1080, 0 (if your screen size is 1920x1080) in the bottom left. | ||
Troubleshooting | Troubleshooting | ||
- | If you were using Geany like we used in Part One in last month’s article, you can use the terminal in the bottom pane to launch your script. If you were using a text editor, you need to launch it from the terminal. Do not forget to make your script executable. Remember to add a sleep statement in between your commands as the terminal is much faster than the GUI. Do not be afraid to go back to the previous article and do it again to refresh your memory. | + | If you were using Geany like we used in Part One in last month’s article, you can use the terminal in the bottom pane to launch your script. If you were using a text editor, you need to launch it from the terminal. Do not forget to make your script executable. Remember to add a sleep statement in between your commands as the terminal is much faster than the GUI. Do not be afraid to go back to the previous article and do it again to refresh your memory.** |
+ | |||
+ | Si vous êtes bloqué - sachez que votre écran va de 0,0 en haut à gauche à 0,1920 en haut à droite (si la taille de votre écran est de 1920 x 1080) et de 1080,0 (si la taille de votre écran est de 1920 x 1080) en bas à gauche. | ||
+ | |||
+ | Résolution des problèmes | ||
+ | |||
+ | Si vous vous servez de Geany comme ndans l' | ||
issue150/tutoriel1.1572506812.txt.gz · Dernière modification : 2019/10/31 08:26 de auntiee