« AutoHotKey » : différence entre les versions
Apparence
Aucun résumé des modifications |
|||
Ligne 50 : | Ligne 50 : | ||
== Double-clique == | == Double-clique == | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
; Double click | ; Double click | ||
~LButton:: | ~LButton:: | ||
Ligne 59 : | Ligne 59 : | ||
= [http://www.autohotkey.com/docs/commands/MouseClick.htm Générer des événements souris] = | = [http://www.autohotkey.com/docs/commands/MouseClick.htm Générer des événements souris] = | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
; Clique gauche | ; Clique gauche | ||
MouseClick, left | MouseClick, left | ||
Ligne 68 : | Ligne 68 : | ||
= [http://www.autohotkey.com/docs/commands/_IfWinActive.htm Mapping pour une application spécifique] = | = [http://www.autohotkey.com/docs/commands/_IfWinActive.htm Mapping pour une application spécifique] = | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
; Si LibreOffice est actif, mapper le point du pavé numérique avec le point et non la virgule par défaut en FR | ; Si LibreOffice est actif, mapper le point du pavé numérique avec le point et non la virgule par défaut en FR | ||
IfWinActive ahk_class SALFRAME | IfWinActive ahk_class SALFRAME | ||
Ligne 84 : | Ligne 84 : | ||
= Désactiver / remapper les touches Caps Lock, Num Lock, Scroll Lock = | = Désactiver / remapper les touches Caps Lock, Num Lock, Scroll Lock = | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
; set the default state of the lock keys | ; set the default state of the lock keys | ||
SetCapsLockState, off | SetCapsLockState, off | ||
Ligne 99 : | Ligne 99 : | ||
= [http://www.autohotkey.com/docs/commands/IfExpression.htm if else] = | = [http://www.autohotkey.com/docs/commands/IfExpression.htm if else] = | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
if Variable | if Variable | ||
... | ... | ||
Ligne 137 : | Ligne 137 : | ||
Appuyer sur une touche → F5<br> | Appuyer sur une touche → F5<br> | ||
Le code de la 2ème colonne correspond au ScanCode | Le code de la 2ème colonne correspond au ScanCode | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
SC02D::MsgBox, %A_ThisHotKey% was pressed. ; x | SC02D::MsgBox, %A_ThisHotKey% was pressed. ; x | ||
</filebox> | </filebox> | ||
= Exemples = | = Exemples = | ||
<kode lang= | <kode lang=ahk> | ||
; ctrl-w -> ctrl-z | ; ctrl-w -> ctrl-z | ||
^w::^z | ^w::^z | ||
Ligne 171 : | Ligne 171 : | ||
== [http://www.ilovefreesoftware.com/30/tutorial/auto-copy-selected-text-clipboard-windows-10.html Copie la sélection dans le presse-papier] == | == [http://www.ilovefreesoftware.com/30/tutorial/auto-copy-selected-text-clipboard-windows-10.html Copie la sélection dans le presse-papier] == | ||
<kode lang= | <kode lang=ahk collapsed> | ||
~Lshift:: | ~Lshift:: | ||
TimeButtonDown = %A_TickCount% | TimeButtonDown = %A_TickCount% | ||
Ligne 306 : | Ligne 306 : | ||
=== Old === | === Old === | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk collapsed> | ||
CopyToClipboard2() | CopyToClipboard2() | ||
{ | { | ||
Ligne 363 : | Ligne 363 : | ||
== [https://www.autohotkey.com/docs/Hotkeys.htm#AltTabDetail Alt Tab] == | == [https://www.autohotkey.com/docs/Hotkeys.htm#AltTabDetail Alt Tab] == | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
; AltTab avec Ctrl + Backspace | ; AltTab avec Ctrl + Backspace | ||
ctrl & backspace::AltTab | ctrl & backspace::AltTab | ||
</filebox> | </filebox> | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
; AltTab avec CapsLock | ; AltTab avec CapsLock | ||
CapsLock::AltTabAndMenu | CapsLock::AltTabAndMenu | ||
Ligne 388 : | Ligne 388 : | ||
== Verrouiller == | == Verrouiller == | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
; Windows + Esc | ; Windows + Esc | ||
#Escape::DllCall("LockWorkStation") | #Escape::DllCall("LockWorkStation") | ||
Ligne 394 : | Ligne 394 : | ||
== Print Screen == | == Print Screen == | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
; Lancer SnippingTool avec la touche Print Screen | ; Lancer SnippingTool avec la touche Print Screen | ||
PrintScreen::Run SnippingTool.exe | PrintScreen::Run SnippingTool.exe | ||
Ligne 400 : | Ligne 400 : | ||
== Mot de passe sous Windows == | == Mot de passe sous Windows == | ||
<filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang= | <filebox fn="C:\Windows\System32\drivers\etc\AutoHotkey.ahk" lang=ahk> | ||
#a:: | #a:: | ||
RunWait, powershell.exe "pm get key1" | Set-Content -NoNewline %A_Temp%\pm.tmp,,HIDE | RunWait, powershell.exe "pm get key1" | Set-Content -NoNewline %A_Temp%\pm.tmp,,HIDE |
Version du 5 avril 2020 à 18:16
Généralités
AutoHotKey
SciTE4AutoHotkey permet d'avoir la coloration syntaxique avec les fichiers ahk.
Liens
Send
Send | les caractères spéciaux sont transformés |
SendRaw | pas de transformation, envoie les caractères tels qu'ils sont écrits |
SendInput | plus rapide et plus fiable que Send |
SendPlay | similaire à SendInput, mais plus adapté pour les jeux vidéo |
Clavier
# | Windows |
! | Alt |
^ | Ctrl |
+ | Shift |
<^>! | Alt Gr |
![]() |
Si une combinaison ne fonctionne pas avec + essayez la forme: Shift & key::Send {key} |
![]() |
Pour les caractères spéciaux comme % → key::Send `% |
![]() |
$ is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. |
Capture de la Souris
LButton | clique gauche |
RButton | clique droit |
MButton | clique roulette |
XButton1 | bouton 4 (doit être assigné à Browser_Back) |
XButton2 | bouton 5 (doit être assigné à Browser_Forward) |
![]() |
XButton3 n'est pas implémenté car Windows ne supporte que 5 boutons. Il faut donc mapper ce 6ème boutons à une combinaison de touches et remapper ces touches à une action. |
Double-clique
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
; Double click
~LButton::
If (A_TimeSincePriorHotkey<400) and (A_PriorHotkey="~LButton")
MsgBox You double Left clicked on something
Return
|
Générer des événements souris
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
; Clique gauche
MouseClick, left
; Double clique
MouseClick, left, , , 2
|
Mapping pour une application spécifique
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
; Si LibreOffice est actif, mapper le point du pavé numérique avec le point et non la virgule par défaut en FR
IfWinActive ahk_class SALFRAME
NumPadDot::SendInput .
; Si Firefox ou Notepad++ est actif
If WinActive("ahk_class MozillaWindowClass") or WinActive("ahk_class Notepad++") { }
; A window's title can contain WinTitle anywhere inside it to be a match.
SetTitleMatchMode, 2
|
![]() |
Par défaut, l'expression doit correspondre au début du titre de la fenêtre. Si ahk_class est spécifié, l'expression doit correspondre exactement à la classe de la fenêtre. |
Désactiver / remapper les touches Caps Lock, Num Lock, Scroll Lock
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
; set the default state of the lock keys
SetCapsLockState, off
SetNumLockState, on
SetScrollLockState, off
; disable them
$NumLock::Return
$ScrollLock::Return
; make the capslock key behave as menu/AppsKey
CapsLock::AppsKey
|
if else
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
if Variable ... else if (x > y) { ... ... } else ... |
Lire et écrire dans un fichier
; écriture dans %USERPROFILE%\AppData\Local\Temp\file.tmp
"text" > %A_Temp%\file.tmp
; écriture sans saut de ligne
"text" | Set-Content -NoNewline %A_Temp%\file.tmp
; lecture du fichier %USERPROFILE%\AppData\Local\Temp\file.tmp
FileRead, FileContent, %A_Temp%\file.tmp
; lecture de la ligne 1
FileReadLine, FileLineOne, %A_Temp%\file.tmp, 1
|
Exécuter du code PowerShell, Batch
; Batch, écriture du résultat dans %USERPROFILE%\AppData\Local\Temp\result.tmp
RunWait %Comspec% /c "commande batch" > %A_Temp%\result.tmp,,HIDE
; PowerShell, écriture du résultat dans %USERPROFILE%\AppData\Local\Temp\result.tmp
RunWait powershell.exe "commande powershell" > %A_Temp%\result.tmp,,HIDE
|
ScanCode
Clique-droit sur l'icone → Open → View → Key history and script info
Appuyer sur une touche → F5
Le code de la 2ème colonne correspond au ScanCode
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
SC02D::MsgBox, %A_ThisHotKey% was pressed. ; x
|
Exemples
; ctrl-w -> ctrl-z
^w::^z
; ctrl-q -> ctrl-a
^q::^a
$F1::Send ^c ; copy
$F2::Send ^v ; paste
F12::Send !{F4} ; fermer fenêtre avec F12
; clique-milieu -> clique gauche + ctrl-v
MButton::
MouseClick
SendInput ^v
Return
; Alt-A select the whole line
!a::
Send {Home}
Send +{End}
Return
; dans LibreOffice
#IfWinActive ahk_class SALFRAME
NumPadDot::SendInput .
|
Copie la sélection dans le presse-papier
|
Old
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
Alt Tab
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
; AltTab avec Ctrl + Backspace
ctrl & backspace::AltTab
|
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
; AltTab avec CapsLock
CapsLock::AltTabAndMenu
!LButton:: ; The ! prefix makes it fire while the Alt key is down (which it is if the alt-tab menu is visible).
MouseClick, left
Send {Alt up}
return
!Enter::
Send {Enter}
Send {Alt up}
return
|
Contrôle du son avec la molette
Fichier:AutoHotkey.svg | +WheelUp::Send {Volume_Up 1}
+WheelDown::Send {Volume_Down 1}
|
Verrouiller
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
; Windows + Esc
#Escape::DllCall("LockWorkStation")
|
Print Screen
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
; Lancer SnippingTool avec la touche Print Screen
PrintScreen::Run SnippingTool.exe
|
Mot de passe sous Windows
C:\Windows\System32\drivers\etc\AutoHotkey.ahk |
#a::
RunWait, powershell.exe "pm get key1" | Set-Content -NoNewline %A_Temp%\pm.tmp,,HIDE
FileReadLine, Result, %A_Temp%\pm.tmp, 1
FileDelete, %A_Temp%\pm.tmp
SendRaw %Result%
SendInput {Enter}
Return
|
%UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 |
New-Alias pm "C:\Users\[USER]\Documents\WindowsPowerShell\Scripts\PasswordsManager.ps1"
|
C:\Users\[USER]\Documents\WindowsPowerShell\Scripts\PasswordsManager.ps1 |
Stocker et récupérer un mot de passe
Installation
- après l'installation, redémarrer pour mettre à jour le menu contextuel New
- créer un script: clique-droit dans un dossier → New → AutoHotkey Script
- modifier le script
- double-cliquer sur le fichier pour l'associer, l’icône AutoHotKey apparaît dans la zone de notification
Exécuter un script au démarrage
- Copier le script
- Coller le raccourci (Paste shortcut) dans %AppData%\Microsoft\Windows\Start Menu\Programs\Startup
Exécuter AutoHotKey au démarrage
- Menu Start → AutoHotKey → copier le raccourci
- Coller le raccourci (Paste shortcut) dans %AppData%\Microsoft\Windows\Start Menu\Programs\Startup
Définir Notepad++ comme éditeur par défaut
HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command
(Default) = "C:\Program Files\Notepad++\notepad++.exe" "%1"
Coloration syntaxique
- Language → Define your language → Import → Notepad++ AutoHotKey Syntax Highlighting Dark.xml
- redémarrer