Initial AutoHotKey Success Testing
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,6 +19,7 @@ Borealis-Server.exe
|
|||||||
# Misc Files/Folders
|
# Misc Files/Folders
|
||||||
.vs/s
|
.vs/s
|
||||||
/Update_Staging/
|
/Update_Staging/
|
||||||
|
/Macro_Testing/
|
||||||
|
|
||||||
# On-the-Fly Downloaded Dependencies
|
# On-the-Fly Downloaded Dependencies
|
||||||
/Dependencies/NodeJS/
|
/Dependencies/NodeJS/
|
||||||
|
40
Borealis.ps1
40
Borealis.ps1
@ -282,8 +282,8 @@ Write-Host " 4) Package Self-Contained EXE of Server or Agent " -NoNewline -Fore
|
|||||||
Write-Host "[Experimental]" -ForegroundColor Red
|
Write-Host "[Experimental]" -ForegroundColor Red
|
||||||
Write-Host " 5) Update Borealis " -NoNewLine -ForegroundColor DarkGray
|
Write-Host " 5) Update Borealis " -NoNewLine -ForegroundColor DarkGray
|
||||||
Write-Host "[Requires Re-Build]" -ForegroundColor Red
|
Write-Host "[Requires Re-Build]" -ForegroundColor Red
|
||||||
Write-Host " 6) Perform Basic Macro Automation Testing " -NoNewline -ForegroundColor DarkGray
|
Write-Host " 6) Perform AutoHotKey Automation Testing " -NoNewline -ForegroundColor DarkGray
|
||||||
Write-Host "[Experimental]" -ForegroundColor Red
|
Write-Host "[Experimental - Dev Testing]" -ForegroundColor Red
|
||||||
Write-Host "Type a number and press " -NoNewLine
|
Write-Host "Type a number and press " -NoNewLine
|
||||||
Write-Host "<ENTER>" -ForegroundColor DarkCyan
|
Write-Host "<ENTER>" -ForegroundColor DarkCyan
|
||||||
$choice = Read-Host
|
$choice = Read-Host
|
||||||
@ -602,4 +602,40 @@ switch ($choice) {
|
|||||||
& (Join-Path $scriptDir "Borealis.ps1")
|
& (Join-Path $scriptDir "Borealis.ps1")
|
||||||
Exit 0
|
Exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"6" {
|
||||||
|
$host.UI.RawUI.WindowTitle = "AutoHotKey Automation Testing"
|
||||||
|
Write-Host " "
|
||||||
|
Write-Host "Lauching AutoHotKey Testing Script..." -ForegroundColor Blue
|
||||||
|
|
||||||
|
$venvFolder = "Macro_Testing"
|
||||||
|
$scriptSourcePath = "Data\Experimental\Macros\Macro_Script.py"
|
||||||
|
$scriptRequirements = "Data\Experimental\Macros\macro-requirements.txt"
|
||||||
|
$scriptDestinationFolder = "$venvFolder\Borealis"
|
||||||
|
$scriptDestinationFile = "$venvFolder\Borealis\Macro_Script.py"
|
||||||
|
$venvPython = Join-Path $scriptDir $venvFolder | Join-Path -ChildPath 'Scripts\python.exe'
|
||||||
|
|
||||||
|
Run-Step "Create Virtual Python Environment" {
|
||||||
|
if (-not (Test-Path "$venvFolder\Scripts\Activate")) {
|
||||||
|
& $pythonExe -m venv $venvFolder
|
||||||
|
}
|
||||||
|
if (Test-Path $scriptSourcePath) {
|
||||||
|
Remove-Item $scriptDestinationFolder -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
New-Item -Path $scriptDestinationFolder -ItemType Directory -Force | Out-Null
|
||||||
|
Copy-Item $scriptSourcePath $scriptDestinationFile -Force
|
||||||
|
Copy-Item "Dependencies\AutoHotKey" $scriptDestinationFolder -Recurse
|
||||||
|
}
|
||||||
|
. "$venvFolder\Scripts\Activate"
|
||||||
|
}
|
||||||
|
|
||||||
|
Run-Step "Install Python Dependencies" {
|
||||||
|
if (Test-Path $scriptRequirements) {
|
||||||
|
& $venvPython -m pip install --disable-pip-version-check -q -r $scriptRequirements | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "`nLaunching Macro Testing Script..." -ForegroundColor Blue
|
||||||
|
Write-Host "===================================================================================="
|
||||||
|
& $venvPython -W ignore::SyntaxWarning $scriptDestinationFile
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
43
Data/Experimental/Macros/Macro_Script.py
Normal file
43
Data/Experimental/Macros/Macro_Script.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# ---------------------- Information Gathering ----------------------
|
||||||
|
import os
|
||||||
|
from ahk import AHK
|
||||||
|
|
||||||
|
# Get the directory containing this script (cross-platform)
|
||||||
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
# Build the path to the AutoHotkey binary (adjust filename if needed)
|
||||||
|
ahk_bin_path = os.path.join(script_dir, 'AutoHotKey', 'AutoHotkey64.exe')
|
||||||
|
|
||||||
|
# ---------------------- Information Analysis ----------------------
|
||||||
|
# Confirm that the AHK binary exists at the given path
|
||||||
|
if not os.path.isfile(ahk_bin_path):
|
||||||
|
raise FileNotFoundError(f"AutoHotkey binary not found at: {ahk_bin_path}")
|
||||||
|
|
||||||
|
# ---------------------- Information Processing ----------------------
|
||||||
|
# Initialize AHK instance with explicit executable_path
|
||||||
|
ahk = AHK(executable_path=ahk_bin_path)
|
||||||
|
|
||||||
|
window_title = '*TargetWindow - Notepad' # Change this to your target window
|
||||||
|
|
||||||
|
# Find the window by its title
|
||||||
|
target_window = ahk.find_window(title=window_title)
|
||||||
|
|
||||||
|
if target_window is None:
|
||||||
|
print(f"Window with title '{window_title}' not found.")
|
||||||
|
else:
|
||||||
|
# Bring the target window to the foreground
|
||||||
|
target_window.activate()
|
||||||
|
|
||||||
|
# Wait briefly to ensure the window is focused
|
||||||
|
import time
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Send keystrokes/text to the window
|
||||||
|
text = "Hello from Python and AutoHotkey!"
|
||||||
|
for c in text:
|
||||||
|
ahk.send(c)
|
||||||
|
import time
|
||||||
|
time.sleep(0.05) # slow down for debugging
|
||||||
|
ahk.send('{ENTER}')
|
||||||
|
|
||||||
|
print("Sent keystrokes to the window.")
|
4
Data/Experimental/Macros/macro-requirements.txt
Normal file
4
Data/Experimental/Macros/macro-requirements.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/Experimental/Macros/macro-requirements.txt
|
||||||
|
|
||||||
|
# Macro Automation
|
||||||
|
ahk # AutoHotKey
|
Reference in New Issue
Block a user