Skip to content

Conversation

@FuPeiJiang
Copy link

  <PropertyGroup>
    <PreBuildEvent>if not exist "$(TargetDir)\x86" mkdir "$(TargetDir)\x86"
if not exist "$(TargetDir)\x64" mkdir "$(TargetDir)\x64"
if not exist "$(TargetDir)\x86\interception.dll" xcopy "$(SolutionDir)\dependencies\x86\interception.dll" "$(TargetDir)\x86"
if not exist "$(TargetDir)\x64\interception.dll" xcopy "$(SolutionDir)\dependencies\x64\interception.dll" "$(TargetDir)\x64"</PreBuildEvent>
  </PropertyGroup>
  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <MakeDir Directories="$(TargetDir)x86;$(TargetDir)x64" />
    <Copy SourceFiles="$(ProjectDir)..\dependencies\x86\interception.dll" DestinationFolder="$(TargetDir)x86" SkipUnchangedFiles="true" />
    <Copy SourceFiles="$(ProjectDir)..\dependencies\x64\interception.dll" DestinationFolder="$(TargetDir)x64" SkipUnchangedFiles="true" />
  </Target>

I'm not sure what the correct replacement for Thread.Abort would be ?
but since it's a polling loop, CancellationTokenSource (or a volatile bool) could be used ?

while (true)
while (!_cts.IsCancellationRequested)
        public void Dispose()
        {
            _pollThread.Abort();
            _pollThread.Join();
        }
        public void Dispose()
        {
            _cts.Cancel();

            if (_pollThread != null && _pollThread.IsAlive)
            {
                _pollThread.Join();
            }

            _cts.Dispose();
        }

I was trying to find a way to detect vk and sc for controller Square and Star buttons, but I guess they are non-standard
I guess I read the wrong repo, because this is for mouse and keyboard only, I thought HID vk sc would be device-agnostic

@FuPeiJiang
Copy link
Author

.NET Framework Interop

AHK v2\Lib\CLR.ahk
oh, I missed this part

The script should work with .NET Framework versions up to v4.x. It does not support .NET Core or .NET 5.0, as hosting these runtimes requires the use of different APIs, with significant limitations.

https://github.com/Lexikos/CLR.ahk

@evilC
Copy link
Owner

evilC commented Dec 17, 2025

@FuPeiJiang I am not averse to the idea of updating this library, but is this CLR issue not essentially a show-stopper?
Also, if we were to update, would it not make sense to use an LTS version? (ie 8 or 10)

@FuPeiJiang
Copy link
Author

@evilC I have a proof of concept using coreclr api
https://github.com/dotnet/runtime/blob/main/docs/design/features/native-hosting.md

I tried to work around the unspecified limitations, but still ended up writing a wrapper: C# dll, AHK_Dotnet_Interop.dll
limitations I found were: only static methods are callable, probably to preserve the current garbage collection model

the C# dll can be loaded from memory: LoadAssemblyBytes, so there needs not be a separate .dll on disk, base64 in AHK source, compressed

changes required:

#include %A_LineFile%\..\CLR.ahk
#include %A_LineFile%\..\DotNet.ahk
		asm := CLR_LoadLibrary(dllFile)
		asm := DotNet_LoadLibrary(dllFile)

for this proof of concept, I only replicated CLR_LoadLibrary, and only AHK v2 works

I kinda need feedback on the directory structure, and many things

this is a cool demo:

Console := DotNet.using("System.Console")
Console.WriteLine("Hello from C#")

File_ := DotNet.using("System.IO.File")
Console.WriteLine(File_.ReadAllText(A_LineFile))

https://github.com/FuPeiJiang/DotNet.ahk/blob/main/DotNet.ahk


would it not make sense to use an LTS version? (ie 8 or 10)

Thanks for the LTS, for AHK_Dotnet_Interop.dll, I used net10, I could update this PR, is there anything else to consider ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants