xiaohongshu
xiaohongshu
julien-ref-ahk-v2
Best practices AutoHotkey v2. Use when writing AHK v2 scripts - covers global variable declarations, SetTimer usage, event handlers, and GUI positioning.
Full skill instructions
First: At the start of execution, display:
🔧 Skill "julien-ref-ahk-v2" activated
; INCORRECT - Cause erreur "variable not assigned"
SomeFunction() {
g_MyGlobalVar := "value" ; ERREUR!
}
; CORRECT - Déclaration explicite requise
SomeFunction() {
global g_MyGlobalVar ; OBLIGATOIRE
g_MyGlobalVar := "value" ; OK
}
FunctionUsingGlobals() {
; Déclarer TOUTES les variables globales utilisées
global g_AppVersion, g_IsInitialized, g_ConfigFile
global g_CachedPhrases, g_SavedSelections, g_CurrentProject
; Maintenant on peut les utiliser
g_IsInitialized := true
return g_AppVersion
}
; Module.ahv2 - Description du module
; Encodage : UTF-8 avec BOM
; AutoHotkey v2
; Variables globales du module (si nécessaire)
global g_ModuleVar := ""
; 1. Configuration TOUJOURS EN PREMIER
#Include "Config\Settings.ah2"
#Include "Config\Paths.ah2"
; 2. Modules Core
#Include "Core\Logger.ah2"
#Include "Core\FileManager.ah2"
; 3. Modules Features (qui dépendent de Core)
#Include "Features\PhraseManager.ah2"
; 4. GUI en dernier
#Include "GUI\MainInterface.ah2"
; INCORRECT - Timer() n'existe pas en AHK v2
g_TooltipTimer := Timer(GUI_TooltipCheckMouse, 100)
g_TooltipTimer.Start()
; CORRECT - Utiliser SetTimer
SetTimer(GUI_TooltipCheckMouse, 100)
; CORRECT - Arrêter timer
SetTimer(GUI_TooltipCheckMouse, 0) ; 0 = arrêter
; CORRECT - Timer périodique avec variable de contrôle
g_TimerActive := true
SetTimer(MyFunction, 100)
StopMyTimer() {
global g_TimerActive
g_TimerActive := false
SetTimer(MyFunction, 0)
}
; INCORRECT - Signature trop spécifique peut échouer
GUI_HandleResize(GuiObj, MinMax, Width, Height) {
; Cette signature peut ne pas correspondre à l'événement réel
}
; CORRECT - Signature flexible avec paramètres variables
GUI_HandleResize(*) {
; Récupérer dimensions via la GUI elle-même
global g_MainGui
g_MainGui.GetPos(, , &Width, &Height)
; ... traitement
}
; CORRECT - Event handlers standards
g_MainGui.OnEvent("Close", (*) => GUI_Hide())
g_MainGui.OnEvent("Size", GUI_HandleResize) ; Fonction sans parenthèses
g_MainGui.OnEvent("Escape", (*) => GUI_Hide())
; CORRECT - Signatures standard ListView
ListView_OnItemCheck(ListViewObj, Item, Checked) {
; Item = numéro ligne, Checked = true/false
}
ListView_OnItemFocus(ListViewObj, Item) {
; Item = numéro ligne qui a le focus
}
; CORRECT - Assignment
g_ListView.OnEvent("ItemCheck", ListView_OnItemCheck)
g_ListView.OnEvent("ItemFocus", ListView_OnItemFocus)
; PROBLÈME COURANT - Interface mal dimensionnée
CreateGUI() {
; Boutons positionnés trop bas, pas visibles
g_Button1 := g_Gui.Add("Button", "x10 y450 w80 h30", "OK")
g_ListView := g_Gui.Add("ListView", "x10 y70 w620 h400", cols)
; Total height = 70 + 400 + 30 = 500px mais fenêtre fait 480px
}
; SOLUTION - Calculs cohérents
CreateGUI() {
; Définir dimensions fenêtre d'abord
windowHeight := 450
headerHeight := 70
footerHeight := 80 ; boutons + marge
; ListView adaptatif
listViewHeight := windowHeight - headerHeight - footerHeight
g_ListView := g_Gui.Add("ListView", "x10 y" . headerHeight . " w620 h" . listViewHeight, cols)
; Boutons dans footer calculé
buttonY := headerHeight + listViewHeight + 10
g_Button1 := g_Gui.Add("Button", "x10 y" . buttonY . " w80 h30", "OK")
}
; STRUCTURE ENRICHIE POUR CACHE
Cache_LoadData() {
global g_CachedPhrases
currentTitleNumber := 0
currentPhraseNumber := 0
; Créer objets avec métadonnées complètes
for lineNum, currentLine in lines {
if (InStr(currentLine, ";;#") = 1) {
currentTitleNumber++
currentPhraseNumber := 0
titleText := Trim(SubStr(currentLine, 4))
g_CachedPhrases.Push({
Type: "Title",
Text: "[" . currentTitleNumber . "] === " . titleText . " ===",
OriginalText: titleText,
TitleNumber: currentTitleNumber
})
} else {
currentPhraseNumber++
g_CachedPhrases.Push({
Type: "Phrase",
Text: "[" . currentTitleNumber . "." . currentPhraseNumber . "] " . currentLine,
OriginalText: currentLine,
TitleNumber: currentTitleNumber,
PhraseNumber: currentPhraseNumber
})
}
}
}
GUI_ProcessPhrases() {
global g_CachedPhrases
for phraseObj in g_CachedPhrases {
; Vérification existence propriété
originalText := phraseObj.HasProp("OriginalText") ? phraseObj.OriginalText : phraseObj.Text
; Traitement conditionnel par type
if (phraseObj.Type = "Title") {
; Traitement spécial titres
} else if (phraseObj.Type = "Phrase") {
; Traitement phrases normales
}
}
}
; Variables globales
global g_AppVersion := "1.0.0"
global g_IsInitialized := false
global g_ConfigFile := ""
; Fonctions - Module_Action
Logger_Write()
Cache_Initialize()
PhraseManager_LoadData()
; Constantes en majuscules
global MAX_CACHE_SIZE := 1000
global DEFAULT_TIMEOUT := 5000
Avant de déployer un script AutoHotkey v2 :
global appropriées..\..\)xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience