AutoHotkey – One-Click Auto Shutdown

May 5th, 2009

Have you ever had to wait in front of your computer before it shuts down? Once it starts closing all background applications, open windows and other things you don’t even know about, it takes a long while before it finally stops.

There is a DOS command that can execute a complete stop: the shutdown command. Some parameters can be added to it, but for the purpose, let’s stay with the essentials to force you computer to shut down:

shutdown –s –f –t 0

It is easy to put it into AutoHotkey to make it done automatically. However, if you do so, all current applications will close without warning, and you may lose unsaved data. Therefore, I added a simple message box to prompt just before proceeding:

MsgBox, 52, Warning, Computer will shut down. Proceed?
IfMsgBox, Yes, run, shutdown -s -f -t 0
Return

If you click the “Yes” button, the computer will not ask and will make a complete stop. There is now an “OFF” key on my Enterpad that helps me leave my computer station as fast as possible!

Edmond

AutoHotkey – Éteindre votre ordinateur en un seul coup

May 5th, 2009

Avez-vous déjà eu à attendre que votre ordinateur ferme tous les programmes en arrière-plan, les fenêtres ouvertes, et qu’il fasse encore des choses qui nécessitent un temps fou avant même qu’il n’arrive à s’éteindre?

Il existe une commande DOS pour éteindre Windows : la commande shutdown. On peut ajouter des paramètres, mais pour les besoins de la cause, voici comment forcer votre ordinateur à s’éteindre :

shutdown –s –f –t 0

On peut l’appliquer à AutoHotkey pour le faire automatiquement. Toutefois, si on le fait tel quel, on provoque la fermeture de toutes les applications et donc, on perd toute information non sauvegardée. Alors, j’ai cru bon de mettre un message d’avertissement juste au cas, ce qui nous donne ceci :

MsgBox, 52, Arrêt, L'ordinateur va maintenant s'arrêter. Procéder?
IfMsgBox, Yes, run, shutdown -s -f -t 0
Return

Si on appuie sur Oui, l’ordinateur ne s’impose pas et s’éteint automatiquement. Sur mon Enterpad, j’ai donc une touche « OFF » qui apparaît pour mettre à l’arrêt mon ordinateur assez rapidement sans que je n’aie à me soucier que tout est ok!

Edmond

AutoHotkey – Display an on-screen message

May 5th, 2009

When I use AutoHotkey to run background tasks, download files and prepare backups, I want to know what happens without wondering if it is really working or not. Also, I like to be prompted and to confirm actions before running them.

There is a command in AutoHotkey, MsgBox, that displays a message box on screen.

For instance, to show a message that confirms that I open my Calculator, I would write the following AutoHotkey script:

Run Calculator
MsgBox, Calculator is open and running.
Return

This dialog box would show « Calculator is open and running. » with a OK button that I must click to close it.

There are many ways to display an on-screen message with MsgBox by adding parameters, such as (in order):

  • Options (number)
  • Title
  • Text to display in the message box
  • Showing delay (after this delay, the message box closes automatically)


Add a title to the message box

MsgBox, 0, My title, Calculator is open and running.

Display a message box for 3 seconds
MsgBox, 0, My title, Calculator is open and running, 3

Display a confirmation (Yes/No) in the message box

MsgBox, 4, My title, Do you want to open Calculator?

In this case, you can use the confirmation to generate actions whether you clicked Yes or No in the message box. For example, if I want to launch Calculator after clicking on the Yes button:

MsgBox, 4, Calculator, Do you want to open Calculator?
IfMsgBox, Yes, run, calc
Return

For more information about the MsgBox command, please refer to AutoHotkey documentation available on the Web: http://www.autohotkey.com/docs/commands.htm

Edmond

AutoHotkey – Afficher un message à l’écran

May 5th, 2009

Lorsque j’utilise AutoHotkey pour lancer des tâches en arrière-plan, télécharger des trucs, préparer une copie de sauvegarde, j’aime être informé de ce qui se passe sans avoir à me demander si la tâche que j’ai demandée s’exécute vraiment. J’ai le même souci quand je demande des actions à mon ordinateur et que je veux confirmer le tout avant de procéder.

Il existe une commande dans AutoHotkey, MsgBox, qui affiche une boîte de message à l’écran.

Par exemple, pour afficher un message qui confirme que j’ai ouvert ma calculatrice, j’écrirais le script AutoHotkey suivant :

Run Calculator
MsgBox, La calculatrice est ouverte.
Return

Ma boîte de dialogue afficherait le message « La calculatrice est ouverte » avec un bouton OK que je clique pour fermer le message.

Il existe plusieurs façons d’afficher un message à l’écran en ajoutant certains paramètres, en ordre :

  • Les options (nombre)
  • Le titre
  • Le texte dans la boîte de message
  • La durée d’affichage de la boîte de message (après ce délai, la boîte de message se fermer automatiquement

Afficher un titre à la boîte de message
MsgBox, 0, Mon titre, La calculatrice est ouverte.

Afficher une boîte de message pendant trois secondes
MsgBox, 0, Mon titre, La calculatrice est ouverte, 3

Afficher une confirmation (oui/non) à l’écran

MsgBox, 4, Mon titre, Voulez-vous ouvrir la calculatrice?

Dans le dernier cas, il est possible de faire une condition qui fait en sorte qu’une action peut suivre selon qu’on a cliqué sur Oui ou Non. Par exemple, si je veux cliquer Oui pour ouvrir la calculatrice :

MsgBox, 4, Calculatrice, Voulez-vous ouvrir la calculatrice?
IfMsgBox, Yes, run, calc
Return

Pour plus d’informations sur les commandes MsgBox, référez-vous à la documentation de AutoHotkey sur leur site Web : http://www.autohotkey.com/docs/commands.htm

Edmond

Make many Enterpads out of one

May 5th, 2009

For those of you who own an Enterpad programmable keyboard, you probably have had to replace a useful macro with another more useful one… because you had used every available key on your keyboard. When having 120 spaces is no longer enough, you need to find more space quickly to keep yourself efficient. However, you do not want to replace all your macros one by one, over and over again.

Indeed, it is always heartbreaking to let go of a very useful macro only because it seems the least useful among all the others. Since I use my Enterpad, I went through the process many times after all my keys were assigned to a macro. And it happened often enough that I go back in time and put an older macro back into place on my keyboard.

With AutoHotkey, programming my macros was an easy thing. Open the script in Notepad, build up macros with the online doc when needed, save and reload the script. When I started using a graphic design program, I found out two things: I have no time to spend on remembering all the shortcuts (was it Ctrl+J or Ctrl+Shift+J already), and no hope at all of doing so.

I was left with two options. Option A was to try to remember the shortcuts, or not to use them at all (what a waste of time). Option B was to remove over 40 of my common macros to replace them by my graphic design ones.

It is then that I’ve been told to create another AutoHotkey script for my graphic design software only. Since it is rare for me to use both my common and design macros at the same time, I found useful to have them separate for I wouldn’t have to look for my design macros among the others.

I created a second AHK file which I placed in the same folder as my default one. In both scripts, I configured keys #9 and #10 on the Enterpad to have buttons to load any of my scripts, and to save and reload the script in real-time.

Then I had to decide how to display all the information about the hotkeys on my Enterpad, since many of my keys now held two different macros, depending on the script I use. I first thought of separating my keys in half to write both macros, then to write in different colors.

The easiest way to get it done was even simpler. In fact, I found out the overlay printout (available on CEDEQ website at http://www.cedeq.com/enterpad-p120/download/ep_lay_ahk.pdf), and made one copy for each of my scripts. Therefore, when I switch script, I just change the overlay at the same time!

Now with my two keyboards in the same one, I have the possibility to create as many as I need. And it is simple: create a script, print the overlay and add a shortcut to my other scripts. Another way for the Enterpad to make me save time and effort!

Edmond

Multipliez votre Enterpad en plusieurs claviers

May 5th, 2009

Si vous êtes comme moi et que vous utilisez votre Enterpad à toutes les sauces, vous avez sans aucun doute rencontré la même situation que moi : la saturation de votre Enterpad. Plus d’espace pour de nouvelles macros, mais toujours le désir d’être plus rapide, plus efficace.

J’ai acquis mon Enterpad il y a de cela un moment, et j’ai eu la chance de tester plusieurs macros afin d’améliorer mon efficacité dans mes tâches quotidiennes devant mon ordinateur. En quelques mois seulement, j’ai réussi à combler toutes les 120 touches de mon clavier programmable avec des raccourcis et des combinaisons toutes aussi utiles les unes que les autres. J’ai eu le temps de changer à plusieurs reprises les macros de touche sur le clavier, à laisser tomber certaines d’entre elles pour les remplacer… pour finalement les réutiliser plus tard.

Avec AutoHotkey installé sur mon poste, la programmation de toutes mes touches a été très facile. Mon script AHK s’ouvrant dans un éditeur de texte standard, j’ai consulté la documentation sur le site de AutoHotkey et j’ai pu créer l’ensemble de mes macros. Toutefois, il est arrivé le moment où justement, j’avais besoin de place sur mon clavier. En effet, j’ai installé un logiciel de graphisme qui contient une multitude de raccourcis clavier que je n’ai ni l’espoir ni le temps de me souvenir (était-ce Ctrl+J ou Ctrl+Shift+J ?).

Je me tenais donc face à un dilemme : comment faire pour ajouter les macros pour le logiciel graphique alors que toutes mes macros actuelles sont pertinentes? Je me voyais très mal substituer « Aller voir le courriel » par « Outil Rectangle », alors que les deux me serviraient encore tôt ou tard. Je ne pouvais non plus me résigner à supprimer le tiers de mes macros.

C’est donc qu’on m’a conseillé de me créer un autre script avec AutoHotkey expressément conçu pour mon logiciel de graphisme. Comme je n’utilise mes macros personnelles en même temps que mes macros de dessin, il était utile de les séparer afin que je n’aie pas à chercher mes macros graphiques à travers les autres.

J’ai donc créé un deuxième fichier AHK que j’ai placé au même endroit que mon script de base et que j’ai nommé Graphisme.ahk. Ensuite, j’ai, sur les deux scripts, utilisé deux touches dans le coin supérieur droit pour charger et décharger un script. Avec mon bouton « Charger script », je choisis lequel des deux je désire activer, et le bouton « Enregistrer et recharger script » pour enregistrer mes modifications en temps réel.

Je n’avais à ce jour que la feuille d’assignation (overlay) fournie avec le Enterpad. J’avais pensé à séparer mes touches en deux, puis à écrire le texte sur la feuille en deux couleurs pour bien séparer. J’allais commencer le travail quand on m’a conseillé de plutôt télécharger une autre copie de l’overlay pour la mettre sur le clavier (on la retrouve d’ailleurs sur le site de CEDEQ au http://www.cedeq.com/enterpad-p120/download/ep_lay_ahk.pdf). J’ai donc utilisé cette deuxième feuille pour y inscrire mes macros propre au graphisme, et le tout était séparé de façon claire et efficace.

J’ai donc deux feuilles interchangeables qui peuvent se placer aisément sous la pellicule plastique. La feuille par défaut y est présente presque toujours, mais, le moment venu d’utiliser mon Enterpad pour mon usage graphique, j’appuie sur ma touche « Charger script » et je change de feuille. Le tour est joué !

Avec désormais deux claviers en un, j’ai aussi l’opportunité d’en créer encore plusieurs. Et c’est simple : créer le script, imprimer la feuille de touches et ajouter un raccourci dans mon script de base. Encore une autre façon de sauver temps et énergie avec l’Enterpad !

Edmond

5 Reasons To Love AutoHotKeys

April 17th, 2009

If you are not already a fan of this software, then you will be by the end of this post.

And if you are a fan, you can read on to enjoy the exhilarating feeling of smugness about your intelligence in using it.

1. You can automate anything.. or at least absolutely any task that your computer is capable of performing. Write the script or use the macro recorder - it’s your choice.

2. Don’t like the placement of keys on your Keyboard? Remap it. Or maybe you don’t like the way your Windows key brings up the Start Menu? Make it open up the Microsoft Word file or the Internet Explorer or both if you want (yes, you can override Windows defaults too). Or maybe you just want to use your joystick as the mouse? You are the puppeteer of this show, play it the way you want.

3. The AutoHotKeys Version 1.0.48 release means it is now up to 3 times faster.

4. Hate using a different system because you can’t use your personalized hotkeys on them? No problem. Simply convert your scripts in .exe files and run them on any system, even ones that do not have AutoHotKeys installed. AutoIT Users can run their scripts without any changes on AutoHotkeys.

5. Automatically expand abbreviations as you type. No need to worry about unprofessional emails at work anymore.

This software is a true supporter of the No Pain, No Pain Philosophy and a boon for the victims of RSI, especially when combined with the Enterpad.

Ohh.. and did I mention that it is FREE?

Meghna

Replacing a standard keyboard with an Enterpad for the disabled

January 30th, 2009

Many of the disabled have trouble using a standard computer keyboard. An Enterpad P360 can be substituted for a standard keyboard and many of these problems can be eliminated.

Some problems with standard keyboard include:

  1. The keys are too small.
  2. The lack of visual clues to find a key.
  3. If a key is not released quickly the character is repeated.
  4. Lack of audio and visual clues that a key was pressed.
  5. Frustration over entering repeated text.

By assigning the same character to adjacent keys you in effect create a key of twice the size. This gives a larger landing area for each key. By configuring each double key to reproduce the same single character you can create a large keyboard for the disabled.

Additionally the graphic overlay can be color coded to make finding keys easier. Keys with similar functions, such as function keys, can be colored the same. The color of the character and its background can be set making finding keys easier.

Another problem is that some disabled can’t release a key before the repeat function kicks in. With an Enterpad the repeat can be eliminated entirely. Or alternately the delay period before the character is repeated can be set to any value desired.

An Enterpad can also be configured to give an audio tone when a key is pressed. The volume of the tone can be set to loud, medium or quit. The tone helps to further accurse the user of a successful key press.

Finally, some buttons can be configured to send information that the user enters over and over. Their name, address and telephone number are a few examples. Standard commands such as copy, paste, cut and the file open command can also be programmed into a key.

If the Enterpad is used in conjunction with AutoHotkey keys can be created that move the mouse pointer. The pointer can be moved left, right, up and down. It can also be moved diagonally. The speed at which the mouse moves can be controlled. Also both single and double click can be assigned to keys.

To view a template of a P360 configured as a standard keyboard for the disabled visit http://www.pmkidder.com/enterpad/htmlpage1.html

5 Ways To Prevent RSI

December 27th, 2008

Computers have become an indispensable part of life for most of us, whether we like it or not. While their benefits in terms of efficiency and convenience are undeniable, so is their impact on humanity almost as great as the discovery of fire and wheel. 

But like everything else in this world, they come with their own set of problems too. And no, I am not talking about Computer Crashes :)

I am instead referring to their far more serious impact on our health, and in particular to RSI - Repetitive Strain Injury.

Ok agreed, RSI didn’t really begin with computers. After all, it was known as Writer’s Cramp before. But leaving the technicalities aside, computer use definitely seems to have made it more common.

Walk into any IT company, and I challenge you to find even one employee NOT suffering from RSI. And it’s not limited to software engineers either. Anyone who uses computers upwards of 4 hours a day, is bound to get it sooner or later.

As a sufferer myself, I can tell you that it’s not just painful, but can also be disabling. At my worst, I could not even open doors. Even now, I cannot even wear a watch for longer than an hour and it has cost me quite a small fortune in terms of lost watches. :(

Jokes aside, there are quite a few things you can do to prevent RSI and if you already suffer from it, to control it.

1. Good Posture

I sure wish I had listened to my teachers in school when they insisted on us maintaining good posture, it would definitely have saved a lot of trouble. Bad Posture is one of the leading causes of RSI, so straighten up your back, and hold your neck high, and while you are at it, get rid of the LazyBoy.

2. Exercise

Yeah, I know I sound totally boorish now but a little bit of exercise will go a long way in preventing you a lot of pain (and not just from RSI either). Go for stretching and strengthening exercises. My recommendation is Yoga and Pilates.

3. Take Breaks

The one great thing about having RSI is that I can take a break every 30 minutes and my boss can’t complain. ;) Of course, your boss may not be as accommodating, in which case your break might just have to consist of drinking a glass of water or looking out of the window for a couple of minutes. But even that goes a long way in preventing RSI. For the workaholics, get yourself a Pause software such as Workrave (it’s free too) to remind you to take breaks.

4. Ergonomically Designed Hardware

Invest in the right equipment. Specially designed equipment such as the Dvorak Keyboard, vertical mouse, joystick use, stylus pens etc. reduce the strain on your muscles, thus preventing tissue damage that leads to RSI. If you need to type a lot, consider investing in a Speech Recognition Software.

5. Macro Software’s

Macro software can help you automate a number of small tasks such as expanding abbreviations as you type, opening applications in specified order etc. A number of free and easy to use macro softwares’ are available over the Internet. My favorite one is AutoHotKeys for its sheer flexibility and of course a small but useful equipment designed for it called the Enterpad.

In closing, remember that RSI is extremely inconvenient, limiting, painful and above all incurable. So follow these simple rules, and be safe.

Meghna

AutoHotKey Scripting Basics - The RunWait Command

November 1st, 2008

The RunWait command is an extension of the Run command. However, as the name suggest, the RunWait command waits for the specified program to finish executing before continuing.

To simplify further, let’s consider once again the multi-line script example from the previous post:

#m::
Run Notepad
Run www.yahoo.com
Run Calculator
Run www.google.com
return

As I explained before, when you press the Win+m keys on your keyboard, the Run command will open these programs in a top-down sequential manner. But with the Run Command you can specify that the program on the next line opens only once the previous one has finished executing. As an example:

^n::
RunWait Notepad
Run www.yahoo.com
return

When you press Ctrl+N on your keyboard, the Notepad will open on your screen, and only after you close it will the Web site yahoo.com open up in your browser.

If you have to work repeatedly on certain applications in a specific order, you will find the RunWait command really useful. With just one little script, you will never need to bother opening these programs manually. I should warn you though, this gets addictive.

Meghna