-
Notifications
You must be signed in to change notification settings - Fork 1
Claude/migrate ahk v2 workflows y3ie m #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| ; ============================================================================ | ||
| ; CitraConfigBase.ahk - Shared initialization for Citra config scripts (v2) | ||
| ; Version: 2.0.0 | ||
| ; Migrated from v1: 2025-12-26 | ||
| ; Changes: Eliminated tf.ahk dependency, modernized v2 syntax | ||
| ; ============================================================================ | ||
|
|
||
| #Requires AutoHotkey v2.0 | ||
| #SingleInstance Force | ||
|
|
||
| ; Performance optimizations | ||
| #KeyHistory 0 | ||
| ListLines False | ||
| SetKeyDelay -1, -1 | ||
| SetMouseDelay -1 | ||
| SetDefaultMouseSpeed 0 | ||
| SetWinDelay -1 | ||
| SetControlDelay -1 | ||
| SendMode "Input" | ||
| SetTitleMatchMode 3 | ||
| SetWorkingDir A_ScriptDir | ||
|
|
||
| ; Include v2 helper functions | ||
| #Include CitraConfigHelpers.ahk | ||
|
|
||
| ; Global config file path | ||
| OneDriveDir := EnvGet("OneDrive") | ||
| if (OneDriveDir = "") { | ||
| MsgBox("OneDrive environment variable not set!`n`nPlease ensure OneDrive is installed and configured.", "Config Error", 16) | ||
| ExitApp 1 | ||
| } | ||
|
|
||
| global CitraConfigFile := OneDriveDir . "\Backup\Game\Emul\Citra\nightly-mingw\user\config\qt-config.ini" | ||
|
|
||
| ; Verify config file exists | ||
| if !FileExist(CitraConfigFile) { | ||
| MsgBox("Citra config file not found:`n" CitraConfigFile "`n`nPlease verify your Citra installation.", "Config Error", 16) | ||
| ExitApp 1 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| ; ============================================================================ | ||
| ; CitraConfigHelpers.ahk - v2 Helper Functions for Citra Configuration | ||
| ; Replaces tf.ahk dependency with native v2 functions | ||
| ; Author: Migrated from v1 - 2025-12-26 | ||
| ; ============================================================================ | ||
|
|
||
| #Requires AutoHotkey v2.0 | ||
|
|
||
| ; ============================================================================ | ||
| ; RegExEscape(str) - Escape regex special characters | ||
| ; | ||
| ; Escapes special regex characters to allow literal string matching | ||
| ; | ||
| ; Parameters: | ||
| ; str - String to escape | ||
| ; | ||
| ; Returns: | ||
| ; Escaped string safe for use in regex patterns | ||
| ; ============================================================================ | ||
| RegExEscape(str) { | ||
| static specials := "()[]{}?*+|^$.\" | ||
| out := "" | ||
| for char in StrSplit(str) | ||
| out .= InStr(specials, char) ? "\" char : char | ||
| return out | ||
| } | ||
|
|
||
| ; ============================================================================ | ||
| ; SetKey(content, key, value) - Set or replace INI key value | ||
| ; | ||
| ; Modifies an INI-style configuration string by setting a key=value pair. | ||
| ; If the key exists, replaces its value. If not, appends the key=value. | ||
| ; | ||
| ; Parameters: | ||
| ; content - Configuration file content as string | ||
| ; key - Key name (e.g., "resolution_factor") | ||
| ; value - Value to set | ||
| ; | ||
| ; Returns: | ||
| ; Modified configuration content | ||
| ; ============================================================================ | ||
| SetKey(content, key, value) { | ||
| pat := "m)^(" . RegExEscape(key) . ")\s*=.*$" | ||
| if RegExMatch(content, pat) | ||
| return RegExReplace(content, pat, "$1=" value, , 1) | ||
| else | ||
| return content "`n" key "=" value | ||
| } | ||
|
|
||
| ; ============================================================================ | ||
| ; LoadConfig(configFile) - Load configuration file | ||
| ; | ||
| ; Reads configuration file into string for manipulation | ||
| ; | ||
| ; Parameters: | ||
| ; configFile - Path to configuration file | ||
| ; | ||
| ; Returns: | ||
| ; File content as string, or empty string if file doesn't exist | ||
| ; ============================================================================ | ||
| LoadConfig(configFile) { | ||
| cfg := "" | ||
| if FileExist(configFile) | ||
| cfg := FileRead(configFile) | ||
| return cfg | ||
| } | ||
|
|
||
| ; ============================================================================ | ||
| ; SaveConfig(cfg, configFile) - Save configuration file | ||
| ; | ||
| ; Writes configuration string to file with backup | ||
| ; | ||
| ; Parameters: | ||
| ; cfg - Configuration content to write | ||
| ; configFile - Path to configuration file | ||
| ; | ||
| ; Returns: | ||
| ; true on success, false on failure | ||
| ; ============================================================================ | ||
| SaveConfig(cfg, configFile) { | ||
| ; Create backup before modifying | ||
| if FileExist(configFile) { | ||
| try { | ||
| FileCopy(configFile, configFile . ".bak", 1) | ||
| } catch { | ||
| ; Backup failed, but continue anyway | ||
| } | ||
| } | ||
|
|
||
| ; Write new config | ||
| try { | ||
| if FileExist(configFile) | ||
| FileDelete(configFile) | ||
| FileAppend(cfg, configFile) | ||
| return true | ||
| } catch as err { | ||
| MsgBox("Error saving config: " . err.Message, "Config Save Error", 16) | ||
| return false | ||
| } | ||
|
Comment on lines
+91
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation deletes the file and then appends to it. A more idiomatic and potentially safer approach in AutoHotkey v2 is to use |
||
| } | ||
|
|
||
| ; ============================================================================ | ||
| ; ReplaceInFile(filePath, searchText, replaceText) - Replace text in file | ||
| ; | ||
| ; Simplified replacement of TF_Replace functionality | ||
| ; Replaces all occurrences of searchText with replaceText in a file | ||
| ; | ||
| ; Parameters: | ||
| ; filePath - Path to file to modify | ||
| ; searchText - Text to search for | ||
| ; replaceText - Text to replace with | ||
| ; | ||
| ; Returns: | ||
| ; true on success, false on failure | ||
| ; ============================================================================ | ||
| ReplaceInFile(filePath, searchText, replaceText) { | ||
| try { | ||
| cfg := LoadConfig(filePath) | ||
| if (cfg = "") | ||
| return false | ||
|
|
||
| cfg := StrReplace(cfg, searchText, replaceText) | ||
| return SaveConfig(cfg, filePath) | ||
| } catch { | ||
| return false | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using #KeyHistory directive with value 0 in a v2 script. In AutoHotkey v2, the correct directive is #KeyHistory MaxEvents where MaxEvents should be a number. To disable key history, use #KeyHistory 0 (which is correct), but the directive should appear before any executable code. However, line 3 has ListLines False which should also be a directive (#NoTrayIcon, not a command). These should be directives at the top.