Skip to content

Commit

Permalink
Some fixes for experimetal option
Browse files Browse the repository at this point in the history
  • Loading branch information
sebeksd committed Feb 25, 2024
1 parent 30ed9d0 commit 139e056
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
13 changes: 6 additions & 7 deletions MultiKB_For_AutoHotkey.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
<SanitizedProjectName>MultiKB_For_AutoHotkey</SanitizedProjectName>
<DCC_Warnings>error</DCC_Warnings>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.2.0.1;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.1.0.0;Comments=</VerInfo_Keys>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.2.0.2;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.1.0.0;Comments=</VerInfo_Keys>
<VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
<VerInfo_MinorVer>2</VerInfo_MinorVer>
<VerInfo_Build>1</VerInfo_Build>
<VerInfo_Build>2</VerInfo_Build>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_UsePackage>DBXSqliteDriver;IndyIPCommon;RESTComponents;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;bindcompvclsmp;tethering;svnui;bindcompvclwinx;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;svn;FireDACSqliteDriver;FireDACPgDriver;inetdb;soaprtl;DbxCommonDriver;fmx;FireDACIBDriver;fmxdae;xmlrtl;soapmidas;vcledge;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage)</DCC_UsePackage>
Expand All @@ -88,10 +88,8 @@
<DCC_UsePackage>DBXSqliteDriver;IndyIPCommon;RESTComponents;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;bindcompvclsmp;tethering;bindcompvclwinx;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;FireDACSqliteDriver;FireDACPgDriver;inetdb;soaprtl;DbxCommonDriver;fmx;FireDACIBDriver;fmxdae;xmlrtl;soapmidas;vcledge;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage)</DCC_UsePackage>
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_MinorVer>0</VerInfo_MinorVer>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.2.0.2;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
<VerInfo_Build>0</VerInfo_Build>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
Expand All @@ -110,6 +108,7 @@
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.2.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_Build>0</VerInfo_Build>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
Expand All @@ -124,7 +123,7 @@
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.2.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.2.0.0;Comments=</VerInfo_Keys>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.2.0.2;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.2.0.0;Comments=</VerInfo_Keys>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
Expand Down
Binary file modified MultiKB_For_AutoHotkey.res
Binary file not shown.
4 changes: 2 additions & 2 deletions src/Engine.pas
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ procedure TEngine.OnLLHookMessage(var Message: TMessage);
// hook message has no device ID so we need RawInput for that
fLock.Enter;
try
lKS := ConvertHookMessageToKeyStroke(Message.WParam, Message.LParam);
lKS := ConvertLLHookMessageToKeyStroke(Message.WParam, Message.LParam);

if FindDeviceInRawInputLog(lKS) then
begin
lKS.Device := GetDeviceByHandle(lKS.DeviceHandle);
lKS.Device := GetDeviceByHandle(lKS.DeviceHandle);

if Assigned(lKS.Device) then
begin
Expand Down
43 changes: 34 additions & 9 deletions src/KeyStroke.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,25 @@ TKeyLogItem = record
end;

function ConvertHookMessageToKeyStroke(wParam: WPARAM; lParam: LPARAM): TKeyStroke;
function ConvertLLHookMessageToKeyStroke(wParam: WPARAM; lParam: LPARAM): TKeyStroke;

implementation

function ConvertHookMessageToKeyStroke(wParam: WPARAM; lParam: LPARAM): TKeyStroke;
function IsBitSet(const lValue, lIndex: NativeInt): Boolean;
begin
Result := lValue and (1 shl lIndex) <> 0;
end;
function IsBitSet(const lValue, lIndex: NativeInt): Boolean;
begin
Result := lValue and (1 shl lIndex) <> 0;
end;

function ConvertHookMessageToKeyStroke(wParam: WPARAM; lParam: LPARAM): TKeyStroke;
begin
Result.DeviceHandle := 0; // unknown yet
Result.Device := nil; // unknown yet
Result.VKeyCode := Byte(wParam);

// if IsBitSet(lParam, 31) then
Result.Direction := kdUp ;
// else
// Result.Direction := kdDown;
if IsBitSet(lParam, 31) then
Result.Direction := kdUp
else
Result.Direction := kdDown;

if not IsBitSet(lParam, 30) then
Result.PreviousKeyState := kdUp
Expand All @@ -66,6 +67,30 @@ function ConvertHookMessageToKeyStroke(wParam: WPARAM; lParam: LPARAM): TKeyStro
Result.IsExtendedKey := False;
end;

function ConvertLLHookMessageToKeyStroke(wParam: WPARAM; lParam: LPARAM): TKeyStroke;
begin
Result.DeviceHandle := 0; // unknown yet
Result.Device := nil; // unknown yet
Result.VKeyCode := Byte(wParam);

if IsBitSet(lParam, 7) then
Result.Direction := kdUp
else
Result.Direction := kdDown;

Result.PreviousKeyState := kdUnknown;

if not IsBitSet(lParam, 5) then
Result.AltState := kdUp
else
Result.AltState := kdDown;

if IsBitSet(lParam, 0) then
Result.IsExtendedKey := True
else
Result.IsExtendedKey := False;
end;

{ TKeyStroke }

function TKeyStroke.IsEqual(const lKeyStroke: TKeyStroke): Boolean;
Expand Down

0 comments on commit 139e056

Please sign in to comment.