Skip to content

Commit

Permalink
Added release preperation script and Installer creation script, chang…
Browse files Browse the repository at this point in the history
…ed versioning, additional cleanup
  • Loading branch information
sebeksd committed Apr 1, 2022
1 parent 41d7636 commit dbdf94b
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ __history/
*.ini
*.tmp
__recovery/
Publish/
15 changes: 11 additions & 4 deletions AutoHotkey_example.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,37 @@
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

; you can uncomment next 3 lines to run MultiKB_For_AutoHotkey every time this script is started (remember to set up correct path to exe)
;Process, Exist, MultiKB_For_AutoHotkey.exe
;If Not ErrorLevel ; errorlevel will = 0 if process doesn't exist
; Run, C:\PATH_TO_EXE\MultiKB_For_AutoHotkey.exe

; do not modify
OnMessage(1325 , "MsgFunc")
return

; do not modify
MsgFunc(wParam, lParam, msg, hwnd)
{
; do not modify
OnUniqueKeyboard(wParam, lParam & 0xFF, (lParam & 0x100) > 0, (lParam & 0x200) > 0, (lParam & 0x400) > 0, (lParam & 0x800) > 0, (lParam & 0x1000) > 0, (lParam & 0x2000) > 0, (lParam & 0x4000) > 0, (lParam & 0x8000) > 0)
}

; KeyboardNumber - configured by you in MultiKB_For_AutoHotkey, this identify keyboard device
; VKeyCode - Key Code, https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
; IsDown - is this press or release
; IsDown - is key pressed or released
; WasDown - like IsDown but this is previous state of this key
; IsExtended - is it normal or extended key (multimedia key, right alt/ctrl etc.)
; LeftCtrl, RightCtrl, LeftAlt, RightAlt, Shift (any) - is corresponding "control key" pressed at the same time
OnUniqueKeyboard(KeyboardNumber, VKeyCode, IsDown, WasDown, IsExtended, LeftCtrl, RightCtrl, LeftAlt, RightAlt, Shift)
{
; Test message generated on unique configured keyboard, remove after your sure that it is working fine
;MsgBox % "Keyboard: " . KeyboardNumber . " Key: " . VKeyCode . " IsDown: " . (IsDown ? "yes" : "no") . " WasDown: " . (WasDown ? "yes" : "no") . " IsExtended: " . (IsExtended ? "yes" : "no") . " LeftCtrl: " . (LeftCtrl ? "yes" : "no") . " RightCtrl: " . (RightCtrl ? "yes" : "no") . " LeftAlt: " . (LeftAlt ? "yes" : "no") . " RightAlt: " . (RightAlt ? "yes" : "no") . " Shift: " . (Shift ? "yes" : "no")

; example, keyboard 1 - "G" + RightCtrl + LeftAlt + Shift
; example, remove, keyboard 1 - "G" + RightCtrl + LeftAlt + Shift
if (KeyboardNumber = 1 and VKeyCode = 71 and RightCtrl and LeftAlt and Shift)
MsgBox "Test message"

; Add your code here
; ---> Add your code below <---


}
12 changes: 7 additions & 5 deletions MultiKB_For_AutoHotkey.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<VerInfo_Locale>1033</VerInfo_Locale>
<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_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_AutoGenVersion>true</VerInfo_AutoGenVersion>
<VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
</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 Down Expand Up @@ -125,6 +125,8 @@
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
<VerInfo_Build>2</VerInfo_Build>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.2;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
Expand Down Expand Up @@ -179,15 +181,15 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win64\Debug\MultiKB_For_AutoHotkey.exe" Configuration="Debug" Class="ProjectOutput">
<DeployFile LocalName="Win64\Debug\MultiKB_For_AutoHotkey.rsm" Configuration="Debug" Class="DebugSymbols">
<Platform Name="Win64">
<RemoteName>MultiKB_For_AutoHotkey.exe</RemoteName>
<RemoteName>MultiKB_For_AutoHotkey.rsm</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win64\Debug\MultiKB_For_AutoHotkey.rsm" Configuration="Debug" Class="DebugSymbols">
<DeployFile LocalName="Win64\Debug\MultiKB_For_AutoHotkey.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win64">
<RemoteName>MultiKB_For_AutoHotkey.rsm</RemoteName>
<RemoteName>MultiKB_For_AutoHotkey.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
Expand Down
Binary file modified MultiKB_For_AutoHotkey.res
Binary file not shown.
137 changes: 137 additions & 0 deletions NSIS_Installer.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@

; This script is used to create Installer for Multi_Keyboard_For_AutoHotkey application

/*
SaveGame Backup Tool - Application for automatic Games Saves backup
Released under MIT licence see LICENCE file, Copyright (c) 2022 sebeksd
*/
;--------------------------------
!define PROGRAM_NAME "Multi_Keyboard_For_AutoHotkey"
!define DESCRIPTION "Application for extanding AutoHotkey with unique keybords detection"
!define COPYRIGHT "sebeksd (c) 2022"
!define INSTALLER_VERSION "1.0.0.0"

!define MAIN_APP_EXE "MultiKB_For_AutoHotkey.exe"
!define DESTINATION_PATH "Publish"
!define SOURCE_FILES_PATH "Publish\Files"

!define REG_ROOT "HKLM"
!define HKLM_REG_UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall"

;--------------------------------
; The name of the installer
Name "${PROGRAM_NAME} Installer"

; Installer file info
!getdllversion "${SOURCE_FILES_PATH}\${MAIN_APP_EXE}" Expv_
VIProductVersion "${Expv_1}.${Expv_2}.${Expv_3}.${Expv_4}"
VIAddVersionKey "ProductName" "${PROGRAM_NAME}"
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
VIAddVersionKey "FileDescription" "${DESCRIPTION}"
VIAddVersionKey "FileVersion" "${INSTALLER_VERSION}"

SetCompressor /SOLID LZMA
XPStyle on
Unicode True

; The file to write
OutFile "${DESTINATION_PATH}\Install_MultiKeyboardForAutoHotkey.exe"

; The default installation directory
InstallDir "$PROGRAMFILES\${PROGRAM_NAME}"

; Request application privileges for Windows Vista
RequestExecutionLevel admin
;--------------------------------

; Pages
Page license
LicenseData "${SOURCE_FILES_PATH}\LICENSE"

Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------

Section "Install"
; Set output path to the installation directory.
SetOutPath $INSTDIR

# define uninstaller name
WriteUninstaller $INSTDIR\uninstall.exe

; Put file there
File "${SOURCE_FILES_PATH}\${MAIN_APP_EXE}"
File "${SOURCE_FILES_PATH}\*.dll"
File "${SOURCE_FILES_PATH}\*.md"
File "${SOURCE_FILES_PATH}\LICENSE"
File "${SOURCE_FILES_PATH}\*example*"

; Create start menu items
CreateDirectory "$SMPROGRAMS\${PROGRAM_NAME}"
CreateShortCut "$SMPROGRAMS\${PROGRAM_NAME}\${PROGRAM_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"

; Write the uninstall keys for Windows
WriteRegStr ${REG_ROOT} "${HKLM_REG_UNINSTALL_PATH}\${PROGRAM_NAME}" "DisplayName" "${PROGRAM_NAME}"
WriteRegStr ${REG_ROOT} "${HKLM_REG_UNINSTALL_PATH}\${PROGRAM_NAME}" "DisplayVersion" "${Expv_1}.${Expv_2}.${Expv_3}.${Expv_4}"
WriteRegStr ${REG_ROOT} "${HKLM_REG_UNINSTALL_PATH}\${PROGRAM_NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr ${REG_ROOT} "${HKLM_REG_UNINSTALL_PATH}\${PROGRAM_NAME}" "InstallLocation" '"$INSTDIR\"'
WriteRegDWORD ${REG_ROOT} "${HKLM_REG_UNINSTALL_PATH}\${PROGRAM_NAME}" "NoModify" 1
WriteRegDWORD ${REG_ROOT} "${HKLM_REG_UNINSTALL_PATH}\${PROGRAM_NAME}" "NoRepair" 1
SectionEnd ; end the section

Section "Uninstall"
; Remove registry keys
DeleteRegKey ${REG_ROOT} "${HKLM_REG_UNINSTALL_PATH}\${PROGRAM_NAME}"

# Always delete uninstaller first
Delete $INSTDIR\uninstall.exe

# delete installed file
Delete $INSTDIR\*.exe
Delete $INSTDIR\*.dll
Delete $INSTDIR\*.md
RMDir "$INSTDIR"

# delete start menu items
Delete "$SMPROGRAMS\${PROGRAM_NAME}\*.*"
RMDir "$SMPROGRAMS\${PROGRAM_NAME}"
SectionEnd

# helper function to TrimQuotes
Function TrimQuotes
Exch $R0
Push $R1

StrCpy $R1 $R0 1
StrCmp $R1 `"` 0 +2
StrCpy $R0 $R0 `` 1
StrCpy $R1 $R0 1 -1
StrCmp $R1 `"` 0 +2
StrCpy $R0 $R0 -1

Pop $R1
Exch $R0
FunctionEnd

!macro _TrimQuotes Input Output
Push `${Input}`
Call TrimQuotes
Pop ${Output}
!macroend
!define TrimQuotes `!insertmacro _TrimQuotes`

# check for path from previous installation (for update)
Function .onInit

ReadRegStr $R0 ${REG_ROOT} "${HKLM_REG_UNINSTALL_PATH}\${PROGRAM_NAME}" "InstallLocation"

StrCmp $R0 "" noUpdate

${TrimQuotes} $R0 $R0
StrCpy $InstDir $R0

noUpdate:
FunctionEnd
19 changes: 19 additions & 0 deletions PreparePackage.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rem This script will make a copy of release compilation and create 7z archive
rem After running this script compile installer through from NSIS_Installer.nsi script
rem in result you will get "portable" .7z archive and installer in Release directory

SET SourcePath=%~dp0Win64\Release\
SET DestinationCompilePath=%~dp0Publish\Files\
SET DestinationPath=%~dp0Publish\

del "%DestinationCompilePath%*.*" /q /f
del "%DestinationPath%*.*" /q /f

xcopy "%SourcePath%*.dll" "%DestinationCompilePath%" /y
xcopy "%SourcePath%*.exe" "%DestinationCompilePath%" /y
xcopy "%~dp0*.md" "%DestinationCompilePath%" /y
xcopy "%~dp0LICENSE" "%DestinationCompilePath%" /y
xcopy "%~dp0*example*" "%DestinationCompilePath%" /y

7z.exe a -mx9 "%DestinationPath%Multi_Keyboard_For_AutoHotkey_Portable.7z" "%DestinationCompilePath%*.exe" "%DestinationCompilePath%*.dll" "%DestinationCompilePath%*.md" "%DestinationCompilePath%LICENSE" "%DestinationCompilePath%*example*"

2 changes: 1 addition & 1 deletion src/common/WindowsHook_Common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface

const
WM_HOOK_LIB_EVENT = WM_USER + 300;
HOOK_MEMORY_NAME = 'LuaMacrosSharedMem';
HOOK_MEMORY_NAME = 'MKFAH_SharedMem';

type
PMMFData = ^TMMFData;
Expand Down

0 comments on commit dbdf94b

Please sign in to comment.