From b4e84cfb4f87619d83f2d668baf9dd6f939afc0a Mon Sep 17 00:00:00 2001 From: Jonas Lindenskov Nielsen Date: Sun, 19 Feb 2017 06:30:23 +0100 Subject: [PATCH 1/4] Added intial install script for interception. Still needs interception.exe and setup of keymap --- .gitignore | 3 +- Intercept/Installer.bat | 63 ++++++++++++++++++++ Intercept/installer/download.vbs | 28 +++++++++ Intercept/installer/elevated.bat | 45 ++++++++++++++ Intercept/installer/install_interception.bat | 18 ++++++ Intercept/installer/unzip.vbs | 31 ++++++++++ 6 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 Intercept/Installer.bat create mode 100644 Intercept/installer/download.vbs create mode 100644 Intercept/installer/elevated.bat create mode 100644 Intercept/installer/install_interception.bat create mode 100644 Intercept/installer/unzip.vbs diff --git a/.gitignore b/.gitignore index 6da8a9e..991eeb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ PR 2014.txt -PR 2017.txt \ No newline at end of file +PR 2017.txt +Intercept/Interception diff --git a/Intercept/Installer.bat b/Intercept/Installer.bat new file mode 100644 index 0000000..36accd5 --- /dev/null +++ b/Intercept/Installer.bat @@ -0,0 +1,63 @@ +@echo off +setlocal EnableDelayedExpansion + +echo "Press enter to confirm the installation..." +pause > NUL + +If NOT exist "tmp" ( + mkdir tmp +) + +REM @TODO: We should only download and install interception if it's not already avalible on the system + +If exist "tmp/interception.zip" ( + echo "Interception already downloaded. Skipping...." + GOTO unzip_interception +) + +:download_interception + +echo "Downloading Interception..." + +REM Using a static link to version 1.0 meaning we wont get updates. +REM We could write some more complicated logic that checks for new +REM versions but im not gonna do that now +set interception_url="https://github.com/oblitum/Interception/releases/download/1.0.0/Interception.zip" + +REM Since batch cant download files directly we have to use a vbs file. +REM We're just gonna tell it to download the latest release of Interception +REM from github and save it as interception.zip +echo "Extracting Interception..." +cscript //Nologo installer/download.vbs %interception_url% tmp/interception.zip + +:unzip_interception +REM Just exiting if we where not able to download the program +If not exist "tmp/interception.zip" ( + echo "Oh noes. We where not able to download interception. Aborting program..." + pause + goto exit +) + +REM If the zip file is not extracted we then do it... +if not exist "Interception" ( + :: Since batch cant extract zip files either, we're gonna use a VBscript here again. + cscript //Nologo installer/unzip.vbs tmp/interception.zip ./ +) else ( + echo "Interception already extracted. Skipping...." +) + +:install_interception +echo. +echo. +ECHO ************************************** +ECHO ATTENTION +ECHO ************************************** +echo "We're now gonna install 'Interception' for you. This requires administrator rights. Press yes on the popup for the installation to continue." +pause + +start /B /WAIT installer\elevated.bat install_interception.bat + +:exit +REM cleaning up a bit before we exit +REM rmdir /s /q tmp +REM rmdir /q /q Interception diff --git a/Intercept/installer/download.vbs b/Intercept/installer/download.vbs new file mode 100644 index 0000000..3d0be53 --- /dev/null +++ b/Intercept/installer/download.vbs @@ -0,0 +1,28 @@ +Option Explicit +Dim args, http, fileSystem, adoStream, url, target, status + +Set args = Wscript.Arguments +Set http = CreateObject("WinHttp.WinHttpRequest.5.1") +url = args(0) +target = args(1) +'WScript.Echo "Getting '" & target & "' from '" & url & "'..." + +http.Open "GET", url, False +http.Send +status = http.Status + +If status <> 200 Then + WScript.Echo "FAILED to download: HTTP Status " & status + WScript.Quit 1 +End If + +Set adoStream = CreateObject("ADODB.Stream") +adoStream.Open +adoStream.Type = 1 +adoStream.Write http.ResponseBody +adoStream.Position = 0 + +Set fileSystem = CreateObject("Scripting.FileSystemObject") +If fileSystem.FileExists(target) Then fileSystem.DeleteFile target +adoStream.SaveToFile target +adoStream.Close diff --git a/Intercept/installer/elevated.bat b/Intercept/installer/elevated.bat new file mode 100644 index 0000000..0014e33 --- /dev/null +++ b/Intercept/installer/elevated.bat @@ -0,0 +1,45 @@ +:::::::::::::::::::::::::::::::::::::::::::: +:: Automatically check & get admin rights V2 +:: http://www.winhelponline.com/blog/automatically-elevate-batch-file-run-administrator/ +:::::::::::::::::::::::::::::::::::::::::::: +@echo off +CLS +ECHO. + +:init +setlocal DisableDelayedExpansion +set "batchPath=%~0" +for %%k in (%0) do set batchName=%%~nk +set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs" +setlocal EnableDelayedExpansion + +:checkPrivileges +NET FILE 1>NUL 2>NUL +if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) + +:getPrivileges +if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges) +ECHO ************************************** +ECHO Asking for administrator permissions. +ECHO ************************************** + +ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%" +ECHO args = "ELEV " >> "%vbsGetPrivileges%" +ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%" +ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%" +ECHO Next >> "%vbsGetPrivileges%" +ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%" +"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %* +exit \B + +:gotPrivileges +setlocal & pushd . +cd /d %~dp0 +if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) + +:::::::::::::::::::::::::::: +::START +:::::::::::::::::::::::::::: +start /B /WAIT %1 + +cmd /k diff --git a/Intercept/installer/install_interception.bat b/Intercept/installer/install_interception.bat new file mode 100644 index 0000000..aba87ab --- /dev/null +++ b/Intercept/installer/install_interception.bat @@ -0,0 +1,18 @@ +@echo off +cls +echo "Starting interception installer..." + +echo %cd% +echo "----------------------------------------------" + +REM Going back to our main directory +cd .. + +if exist "Interception\command line installer\install-interception.exe" ( + "Interception\command line installer\install-interception.exe" /install +) else ( + echo "aww" +) + + +exit diff --git a/Intercept/installer/unzip.vbs b/Intercept/installer/unzip.vbs new file mode 100644 index 0000000..7457e65 --- /dev/null +++ b/Intercept/installer/unzip.vbs @@ -0,0 +1,31 @@ +Option Explicit +Dim args, src, dist, fso, zip, files, objShell,FilesInZip + +Set args = Wscript.Arguments +Set fso = CreateObject("Scripting.FileSystemObject") + +'The location of the zip file. +src = fso.GetAbsolutePathName(args(0)) +'The folder the contents should be extracted to. +dist= fso.GetAbsolutePathName(args(1)) + +'WScript.Echo "Unzipping '" & src & "' to '" & dist & "'..." + +'If the extraction location does not exist create it. +If NOT fso.FolderExists(dist) Then + fso.CreateFolder(dist) +End If + +'Extract the contants of the zip file. +set objShell = CreateObject("Shell.Application") +set zip=objShell.NameSpace(src) + +if (not zip is nothing) then + set files=zip.items + + objShell.NameSpace(dist).CopyHere(files) + Set fso = Nothing + Set objShell = Nothing +else + WScript.Echo "Could not find zip file '" + src + "'" +end if From e920e3869982767f3a3af2b654614a2b1b1e0e2e Mon Sep 17 00:00:00 2001 From: Jonas Lindenskov Nielsen Date: Sun, 19 Feb 2017 16:11:34 +0100 Subject: [PATCH 2/4] Installation script also downloads intercept.exe now. Also created a keymap script that will get us the keyboard id --- .gitignore | 2 ++ Intercept/Installer.bat | 51 +++++++++++++++++++++++++++++++++-------- Intercept/keymap.bat | 3 +++ 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 Intercept/keymap.bat diff --git a/.gitignore b/.gitignore index 991eeb0..5831db9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ PR 2014.txt PR 2017.txt Intercept/Interception +Intercept/intercept +Intercept/tmp diff --git a/Intercept/Installer.bat b/Intercept/Installer.bat index 36accd5..84a8389 100644 --- a/Intercept/Installer.bat +++ b/Intercept/Installer.bat @@ -1,7 +1,7 @@ @echo off setlocal EnableDelayedExpansion -echo "Press enter to confirm the installation..." +echo Press enter to confirm the installation... pause > NUL If NOT exist "tmp" ( @@ -11,14 +11,12 @@ If NOT exist "tmp" ( REM @TODO: We should only download and install interception if it's not already avalible on the system If exist "tmp/interception.zip" ( - echo "Interception already downloaded. Skipping...." + echo Interception already downloaded. Skipping.... GOTO unzip_interception ) :download_interception -echo "Downloading Interception..." - REM Using a static link to version 1.0 meaning we wont get updates. REM We could write some more complicated logic that checks for new REM versions but im not gonna do that now @@ -27,13 +25,13 @@ set interception_url="https://github.com/oblitum/Interception/releases/download/ REM Since batch cant download files directly we have to use a vbs file. REM We're just gonna tell it to download the latest release of Interception REM from github and save it as interception.zip -echo "Extracting Interception..." +echo Downloading Interception... cscript //Nologo installer/download.vbs %interception_url% tmp/interception.zip :unzip_interception REM Just exiting if we where not able to download the program If not exist "tmp/interception.zip" ( - echo "Oh noes. We where not able to download interception. Aborting program..." + echo Oh noes. We where not able to download interception. Aborting program... pause goto exit ) @@ -41,9 +39,10 @@ If not exist "tmp/interception.zip" ( REM If the zip file is not extracted we then do it... if not exist "Interception" ( :: Since batch cant extract zip files either, we're gonna use a VBscript here again. + echo Extracting Interception... cscript //Nologo installer/unzip.vbs tmp/interception.zip ./ ) else ( - echo "Interception already extracted. Skipping...." + echo Interception already extracted. Skipping.... ) :install_interception @@ -52,12 +51,46 @@ echo. ECHO ************************************** ECHO ATTENTION ECHO ************************************** -echo "We're now gonna install 'Interception' for you. This requires administrator rights. Press yes on the popup for the installation to continue." +echo We're now gonna install 'Interception' for you. This requires administrator rights. Press yes on the popup for the installation to continue. pause start /B /WAIT installer\elevated.bat install_interception.bat +echo Press enter when the interception install is done AND you've closed the secondary window. +pause>nul +:download_intercept + +echo Downloading Intercept.exe... + +set intercept_url="http://octopup.org/img/code/interception/intercept.zip" + +REM Since batch cant download files directly we have to use a vbs file. +REM We're just gonna tell it to download the latest release of Interception +REM from github and save it as interception.zip +cscript //Nologo installer/download.vbs %intercept_url% tmp/intercept.zip + +:unzip_intercept +REM Just exiting if we where not able to download the program +If not exist "tmp/intercept.zip" ( + echo Oh noes. We where not able to download intercept. Aborting program... + pause + goto exit +) + +REM If the zip file is not extracted we then do it... +if not exist "intercept" ( + :: Since batch cant extract zip files either, we're gonna use a VBscript here again. + echo Extracting Intercept.exe... + cscript //Nologo installer/unzip.vbs tmp/intercept.zip ./ +) else ( + echo Intercept.exe already extracted. Skipping.... +) + +echo Installation successfull. Now reboot your computer and run 'keymap.bat' + + :exit REM cleaning up a bit before we exit REM rmdir /s /q tmp -REM rmdir /q /q Interception +REM rmdir /s /q Interception +REM rmdir /s /q intercept diff --git a/Intercept/keymap.bat b/Intercept/keymap.bat new file mode 100644 index 0000000..d34792f --- /dev/null +++ b/Intercept/keymap.bat @@ -0,0 +1,3 @@ +@echo off + +echo "@TODO: Implement this file" From d564e27a102de3685341b6354d7f4a74eaa90449 Mon Sep 17 00:00:00 2001 From: Jonas Lindenskov Nielsen Date: Sun, 19 Feb 2017 18:36:11 +0100 Subject: [PATCH 3/4] Updated installation script to download getdeviceid. --- .gitignore | 1 + Intercept/Installer.bat | 39 +++++++++++++++++++++++++++++++++------ Intercept/keymap.bat | 2 ++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 5831db9..879f347 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ PR 2017.txt Intercept/Interception Intercept/intercept Intercept/tmp +Intercept/installer/getdeviceid.exe diff --git a/Intercept/Installer.bat b/Intercept/Installer.bat index 84a8389..505c506 100644 --- a/Intercept/Installer.bat +++ b/Intercept/Installer.bat @@ -8,6 +8,7 @@ If NOT exist "tmp" ( mkdir tmp ) +:download_interception REM @TODO: We should only download and install interception if it's not already avalible on the system If exist "tmp/interception.zip" ( @@ -15,8 +16,6 @@ If exist "tmp/interception.zip" ( GOTO unzip_interception ) -:download_interception - REM Using a static link to version 1.0 meaning we wont get updates. REM We could write some more complicated logic that checks for new REM versions but im not gonna do that now @@ -58,8 +57,9 @@ start /B /WAIT installer\elevated.bat install_interception.bat echo Press enter when the interception install is done AND you've closed the secondary window. pause>nul -:download_intercept + +:download_intercept echo Downloading Intercept.exe... set intercept_url="http://octopup.org/img/code/interception/intercept.zip" @@ -86,11 +86,38 @@ if not exist "intercept" ( echo Intercept.exe already extracted. Skipping.... ) + +:download_other_dependencies +echo Downloading other dependencies... + +REM Using a static link to version 1.0 meaning we wont get updates. +REM We could write some more complicated logic that checks for new +REM versions but im not gonna do that now +set getdeviceid_url="https://github.com/jlndk/getdeviceid/releases/download/v1.0/getdeviceid.zip" + +REM Since batch cant download files directly we have to use a vbs file. +REM We're just gonna tell it to download the latest release of Interception +REM from github and save it as interception.zip +cscript //Nologo installer/download.vbs %getdeviceid_url% tmp/getdeviceid.zip + +:unzip_intercept +REM Just exiting if we where not able to download the program +If not exist "tmp/getdeviceid.zip" ( + echo Oh noes. We where not able to download getdeviceid. Aborting program... + pause + goto exit +) + +REM If the zip file is not extracted we then do it... +if not exist "installer/getdeviceid.exe" ( + :: Since batch cant extract zip files either, we're gonna use a VBscript here again. + echo Extracting Dependencies... + cscript //Nologo installer/unzip.vbs tmp/getdeviceid.zip installer +) + echo Installation successfull. Now reboot your computer and run 'keymap.bat' :exit REM cleaning up a bit before we exit -REM rmdir /s /q tmp -REM rmdir /s /q Interception -REM rmdir /s /q intercept +rmdir /s /q tmp diff --git a/Intercept/keymap.bat b/Intercept/keymap.bat index d34792f..59ebbf5 100644 --- a/Intercept/keymap.bat +++ b/Intercept/keymap.bat @@ -1,3 +1,5 @@ @echo off echo "@TODO: Implement this file" + +start /B /WAIT intercept/intercept.exe From ac5f9a620e683d037f9cab18c6a128a0d09b25b2 Mon Sep 17 00:00:00 2001 From: Jonas Lindenskov Nielsen Date: Sun, 19 Feb 2017 20:02:46 +0100 Subject: [PATCH 4/4] Added templating functionality to the keymap script --- .gitignore | 1 + Intercept/installer/create_keyremap.vbs | 52 ++ Intercept/installer/iniReader.vbs | 203 ++++++ Intercept/installer/template.ini | 647 +++++++++++++++++++ Intercept/keymap.bat | 17 +- Intercept/{keyremap.ini => keyremap.org.ini} | 0 6 files changed, 918 insertions(+), 2 deletions(-) create mode 100644 Intercept/installer/create_keyremap.vbs create mode 100644 Intercept/installer/iniReader.vbs create mode 100644 Intercept/installer/template.ini rename Intercept/{keyremap.ini => keyremap.org.ini} (100%) diff --git a/.gitignore b/.gitignore index 879f347..c66e638 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ Intercept/Interception Intercept/intercept Intercept/tmp Intercept/installer/getdeviceid.exe +Intercept/deviceid.ini diff --git a/Intercept/installer/create_keyremap.vbs b/Intercept/installer/create_keyremap.vbs new file mode 100644 index 0000000..827bf9e --- /dev/null +++ b/Intercept/installer/create_keyremap.vbs @@ -0,0 +1,52 @@ +'http://stackoverflow.com/questions/23641070/create-a-text-document-from-template-vbscript + +Dim objFSO +Set objFSO = CreateObject("Scripting.FileSystemObject") + +' IMPORT inireader functions +DIM objShell +Set objShell = wscript.createObject("wscript.shell") +Dim iniReaderPath +iniReaderPath = objFSO.GetAbsolutePathName("installer\iniReader.vbs") +Dim vbsFile +Set vbsFile = objFSO.OpenTextFile(iniReaderPath, 1, False) +Dim functions +functions = vbsFile.ReadAll +vbsFile.Close +Set vbsFile = Nothing +ExecuteGlobal functions +'END import inireader function + + +Dim args +Set args = Wscript.Arguments + +Dim iniPath +iniPath = objFSO.GetAbsolutePathName(args(0)) + +Dim distPath +distPath = objFSO.GetAbsolutePathName(args(1)) + +Dim devId +devId = ReadIni(iniPath,iniPath,"device") + +Const ForReading = 1 +Const ForWriting = 2 + +Dim templatePath +templatePath = objFSO.GetAbsolutePathName("installer\template.ini") + +Dim objTemplateTS +Set objTemplateTS = objFSO.OpenTextFile(templatePath, ForReading, False) + +Dim strAllTemplateText +strAllTemplateText = objTemplateTS.ReadAll() +objTemplateTS.Close() +strAllTemplateText = Replace(strAllTemplateText, "", devId) + + +Dim objOutputTS +Set objOutputTS = objFSO.OpenTextFile(distPath, ForWriting, True) + +objOutputTS.Write(strAllTemplateText) +objOutputTS.Close() diff --git a/Intercept/installer/iniReader.vbs b/Intercept/installer/iniReader.vbs new file mode 100644 index 0000000..9b85114 --- /dev/null +++ b/Intercept/installer/iniReader.vbs @@ -0,0 +1,203 @@ +'http://www.robvanderwoude.com/vbstech_files_ini.php + +Public Function ReadIni( myFilePath, mySection, myKey ) + ' This function returns a value read from an INI file + ' + ' Arguments: + ' myFilePath [string] the (path and) file name of the INI file + ' mySection [string] the section in the INI file to be searched + ' myKey [string] the key whose value is to be returned + ' + ' Returns: + ' the [string] value for the specified key in the specified section + ' + ' CAVEAT: Will return a space if key exists but value is blank + ' + ' Written by Keith Lacelle + ' Modified by Denis St-Pierre and Rob van der Woude + + Const ForReading = 1 + Const ForWriting = 2 + Const ForAppending = 8 + + Dim intEqualPos + Dim objFSO, objIniFile + Dim strFilePath, strKey, strLeftString, strLine, strSection + + Set objFSO = CreateObject( "Scripting.FileSystemObject" ) + + ReadIni = "" + strFilePath = Trim( myFilePath ) + strSection = Trim( mySection ) + strKey = Trim( myKey ) + + If objFSO.FileExists( strFilePath ) Then + Set objIniFile = objFSO.OpenTextFile( strFilePath, ForReading, False ) + Do While objIniFile.AtEndOfStream = False + strLine = Trim( objIniFile.ReadLine ) + + ' Check if section is found in the current line + If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then + strLine = Trim( objIniFile.ReadLine ) + + ' Parse lines until the next section is reached + Do While Left( strLine, 1 ) <> "[" + ' Find position of equal sign in the line + intEqualPos = InStr( 1, strLine, "=", 1 ) + If intEqualPos > 0 Then + strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) + ' Check if item is found in the current line + If LCase( strLeftString ) = LCase( strKey ) Then + ReadIni = Trim( Mid( strLine, intEqualPos + 1 ) ) + ' In case the item exists but value is blank + If ReadIni = "" Then + ReadIni = " " + End If + ' Abort loop when item is found + Exit Do + End If + End If + + ' Abort if the end of the INI file is reached + If objIniFile.AtEndOfStream Then Exit Do + + ' Continue with next line + strLine = Trim( objIniFile.ReadLine ) + Loop + Exit Do + End If + Loop + objIniFile.Close + Else + WScript.Echo strFilePath & " doesn't exists. Exiting..." + Wscript.Quit 1 + End If +End Function + +Public Sub WriteIni( myFilePath, mySection, myKey, myValue ) + ' This subroutine writes a value to an INI file + ' + ' Arguments: + ' myFilePath [string] the (path and) file name of the INI file + ' mySection [string] the section in the INI file to be searched + ' myKey [string] the key whose value is to be written + ' myValue [string] the value to be written (myKey will be + ' deleted if myValue is ) + ' + ' Returns: + ' N/A + ' + ' CAVEAT: WriteIni function needs ReadIni function to run + ' + ' Written by Keith Lacelle + ' Modified by Denis St-Pierre, Johan Pol and Rob van der Woude + + Const ForReading = 1 + Const ForWriting = 2 + Const ForAppending = 8 + + Dim blnInSection, blnKeyExists, blnSectionExists, blnWritten + Dim intEqualPos + Dim objFSO, objNewIni, objOrgIni, wshShell + Dim strFilePath, strFolderPath, strKey, strLeftString + Dim strLine, strSection, strTempDir, strTempFile, strValue + + strFilePath = Trim( myFilePath ) + strSection = Trim( mySection ) + strKey = Trim( myKey ) + strValue = Trim( myValue ) + + Set objFSO = CreateObject( "Scripting.FileSystemObject" ) + Set wshShell = CreateObject( "WScript.Shell" ) + + strTempDir = wshShell.ExpandEnvironmentStrings( "%TEMP%" ) + strTempFile = objFSO.BuildPath( strTempDir, objFSO.GetTempName ) + + Set objOrgIni = objFSO.OpenTextFile( strFilePath, ForReading, True ) + Set objNewIni = objFSO.CreateTextFile( strTempFile, False, False ) + + blnInSection = False + blnSectionExists = False + ' Check if the specified key already exists + blnKeyExists = ( ReadIni( strFilePath, strSection, strKey ) <> "" ) + blnWritten = False + + ' Check if path to INI file exists, quit if not + strFolderPath = Mid( strFilePath, 1, InStrRev( strFilePath, "\" ) ) + If Not objFSO.FolderExists ( strFolderPath ) Then + WScript.Echo "Error: WriteIni failed, folder path (" _ + & strFolderPath & ") to ini file " _ + & strFilePath & " not found!" + Set objOrgIni = Nothing + Set objNewIni = Nothing + Set objFSO = Nothing + WScript.Quit 1 + End If + + While objOrgIni.AtEndOfStream = False + strLine = Trim( objOrgIni.ReadLine ) + If blnWritten = False Then + If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then + blnSectionExists = True + blnInSection = True + ElseIf InStr( strLine, "[" ) = 1 Then + blnInSection = False + End If + End If + + If blnInSection Then + If blnKeyExists Then + intEqualPos = InStr( 1, strLine, "=", vbTextCompare ) + If intEqualPos > 0 Then + strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) + If LCase( strLeftString ) = LCase( strKey ) Then + ' Only write the key if the value isn't empty + ' Modification by Johan Pol + If strValue <> "" Then + objNewIni.WriteLine strKey & "=" & strValue + End If + blnWritten = True + blnInSection = False + End If + End If + If Not blnWritten Then + objNewIni.WriteLine strLine + End If + Else + objNewIni.WriteLine strLine + ' Only write the key if the value isn't empty + ' Modification by Johan Pol + If strValue <> "" Then + objNewIni.WriteLine strKey & "=" & strValue + End If + blnWritten = True + blnInSection = False + End If + Else + objNewIni.WriteLine strLine + End If + Wend + + If blnSectionExists = False Then ' section doesn't exist + objNewIni.WriteLine + objNewIni.WriteLine "[" & strSection & "]" + ' Only write the key if the value isn't empty + ' Modification by Johan Pol + If strValue <> "" Then + objNewIni.WriteLine strKey & "=" & strValue + End If + End If + + objOrgIni.Close + objNewIni.Close + + ' Delete old INI file + objFSO.DeleteFile strFilePath, True + ' Rename new INI file + objFSO.MoveFile strTempFile, strFilePath + + Set objOrgIni = Nothing + Set objNewIni = Nothing + Set objFSO = Nothing + Set wshShell = Nothing +End Sub diff --git a/Intercept/installer/template.ini b/Intercept/installer/template.ini new file mode 100644 index 0000000..e0adb24 --- /dev/null +++ b/Intercept/installer/template.ini @@ -0,0 +1,647 @@ +;TARAN NOTE: +;okay, so basically how this works, is that, according to this .ini file, +;every single keystroke from your 2nd keyboard is blocked. Is is then sort of +;"wrapped" in F23. That is, F23 is pressed down, the original key is pressed down, then released, +;and then F23 is released. In this way, F23 acts as a sort of "modifier" key. + +;then, in Autohotkey, it listens for F23 using the code #if (getKeyState("F23", "P")) +;and all the keys under that can be treated and remapped just like a normal keypress!! +;But because F23 is always used, we always know that the keypress came from the 2nd keyboard! + + +; 58,0,0 is the scan code for "F12 down," +; 58,0,1 is the scan code for "F12 up." +; ------------------------------------- +; 6D,0,0 is the scan code for "F22 down," +; 6D,0,1 is the scan code for "F22 up." +; 6E,0,0 is the scan code for "F23 down," +; 6E,0,1 is the scan code for "F23 up." +; 76,0,0 is the scan code for "F24 down," +; 76,0,1 is the scan code for "F24 up." + +;I'll make a video about this whole process, which will appear on my youtube channel: +; https://www.youtube.com/user/TaranVH/videos + +;(I have F24 dedicated to luaMacros, but you don't have to do this.) + +[Escape -> RELEASE F23] +device= +trigger=1,0,0 +combo=6E,0,1 +; [ESCAPE KEY - POSSIBLY UNWISE TO HAVE] +; device= +; trigger=1,0,0 +; combo=6E,0,0|1,0,0|1,0,1|6E,0,1 + + +[f1] +device= +trigger=3b,0,0 +combo=6E,0,0|3b,0,0|3b,0,1|6E,0,1 +[f2] +device= +trigger=3c,0,0 +combo=6E,0,0|3c,0,0|3c,0,1|6E,0,1 +[f3] +device= +trigger=3d,0,0 +combo=6E,0,0|3d,0,0|3d,0,1|6E,0,1 +[f4] +device= +trigger=3e,0,0 +combo=6E,0,0|3e,0,0|3e,0,1|6E,0,1 +[f5] +device= +trigger=3f,0,0 +combo=6E,0,0|3f,0,0|3f,0,1|6E,0,1 +[f6] +device= +trigger=40,0,0 +combo=6E,0,0|40,0,0|40,0,1|6E,0,1 +[f7] +device= +trigger=41,0,0 +combo=6E,0,0|41,0,0|41,0,1|6E,0,1 +[f8] +device= +trigger=42,0,0 +combo=6E,0,0|42,0,0|42,0,1|6E,0,1 +[f9] +device= +trigger=43,0,0 +combo=6E,0,0|43,0,0|43,0,1|6E,0,1 +[f10] +device= +trigger=44,0,0 +combo=6E,0,0|44,0,0|44,0,1|6E,0,1 +[f11] +device= +trigger=57,0,0 +combo=6E,0,0|57,0,0|57,0,1|6E,0,1 +[f12 - tap escape AND release F23 in case it is held down.] +device= +trigger=58,0,0 +combo=1,0,0|1,0,1|6E,0,1 + +; [f6] +; device= +; trigger=40,0,0 +; combo=290,0,0|290,0,1 +; [f7] +; device= +; trigger=41,0,0 +; combo=d0,0,0|d0,0,1 +; [f8] +; device= +; trigger=42,0,0 +; combo=e0,0,0|e0,0,1 +; [f9] +; device= +; trigger=43,0,0 +; combo=f0,0,0|f0,0,1 +; [f10] +; device= +; trigger=44,0,0 +; combo=100,0,0|100,0,1 +; [f11] +; device= +; trigger=57,0,0 +; combo=130,0,0|130,0,1 +; [f12 - needs fixing] +; device= +; trigger=6E,0,0 +; combo=390,0,0|390,0,1 + + + + +[tilde] +device= +trigger=29,0,0 +combo=6E,0,0|29,0,0|29,0,1|6E,0,1 +[1] +device= +trigger=2,0,0 +combo=6E,0,0|2,0,0|2,0,1|6E,0,1 +[2] +device= +trigger=3,0,0 +combo=6E,0,0|3,0,0|3,0,1|6E,0,1 +[3] +device= +trigger=4,0,0 +combo=6E,0,0|4,0,0|4,0,1|6E,0,1 +[4] +device= +trigger=5,0,0 +combo=6E,0,0|5,0,0|5,0,1|6E,0,1 +[5] +device= +trigger=6,0,0 +combo=6E,0,0|6,0,0|6,0,1|6E,0,1 +[6] +device= +trigger=7,0,0 +combo=6E,0,0|7,0,0|7,0,1|6E,0,1 +[7] +device= +trigger=8,0,0 +combo=6E,0,0|8,0,0|8,0,1|6E,0,1 +[8] +device= +trigger=9,0,0 +combo=6E,0,0|9,0,0|9,0,1|6E,0,1 +[9] +device= +trigger=a,0,0 +combo=6E,0,0|a,0,0|a,0,1|6E,0,1 +[0] +device= +trigger=b,0,0 +combo=6E,0,0|b,0,0|b,0,1|6E,0,1 +[minus] +device= +trigger=c,0,0 +combo=6E,0,0|c,0,0|c,0,1|6E,0,1 +[equals] +device= +trigger=d,0,0 +combo=6E,0,0|d,0,0|d,0,1|6E,0,1 +[backspace] +device= +trigger=e,0,0 +combo=6E,0,0|e,0,0|e,0,1|6E,0,1 + +[tab] +device= +trigger=f,0,0 +combo=6E,0,0|f,0,0|f,0,1|6E,0,1 +[q] +device= +trigger=10,0,0 +combo=6E,0,0|10,0,0|10,0,1|6E,0,1 +[w] +device= +trigger=11,0,0 +combo=6E,0,0|11,0,0|11,0,1|6E,0,1 +[e] +device= +trigger=12,0,0 +combo=6E,0,0|12,0,0|12,0,1|6E,0,1 +[r] +device= +trigger=13,0,0 +combo=6E,0,0|13,0,0|13,0,1|6E,0,1 +[t] +device= +trigger=14,0,0 +combo=6E,0,0|14,0,0|14,0,1|6E,0,1 +[y] +device= +trigger=15,0,0 +combo=6E,0,0|15,0,0|15,0,1|6E,0,1 +[u] +device= +trigger=16,0,0 +combo=6E,0,0|16,0,0|16,0,1|6E,0,1 +[i] +device= +trigger=17,0,0 +combo=6E,0,0|17,0,0|17,0,1|6E,0,1 +[o] +device= +trigger=18,0,0 +combo=6E,0,0|18,0,0|18,0,1|6E,0,1 +[p] +device= +trigger=19,0,0 +combo=6E,0,0|19,0,0|19,0,1|6E,0,1 +[leftbracket] +device= +trigger=1a,0,0 +combo=6E,0,0|1a,0,0|1a,0,1|6E,0,1 +[rightbracket] +device= +trigger=1b,0,0 +combo=6E,0,0|1b,0,0|1b,0,1|6E,0,1 +[backslash] +device= +trigger=2b,0,0 +combo=6E,0,0|2b,0,0|2b,0,1|6E,0,1 + + +[caps lock] +device= +trigger=3a,0,0 +combo=6E,0,0|3a,0,0|3a,0,1|6E,0,1 +[a] +device= +trigger=1e,0,0 +combo=6E,0,0|1e,0,0|1e,0,1|6E,0,1 +[s] +device= +trigger=1f,0,0 +combo=6E,0,0|1f,0,0|1f,0,1|6E,0,1 +[d] +device= +trigger=20,0,0 +combo=6E,0,0|20,0,0|20,0,1|6E,0,1 +[f] +device= +trigger=21,0,0 +combo=6E,0,0|21,0,0|21,0,1|6E,0,1 +[g] +device= +trigger=22,0,0 +combo=6E,0,0|22,0,0|22,0,1|6E,0,1 +[h] +device= +trigger=23,0,0 +combo=6E,0,0|23,0,0|23,0,1|6E,0,1 +[j] +device= +trigger=24,0,0 +combo=6E,0,0|24,0,0|24,0,1|6E,0,1 +[k] +device= +trigger=25,0,0 +combo=6E,0,0|25,0,0|25,0,1|6E,0,1 +[l] +device= +trigger=26,0,0 +combo=6E,0,0|26,0,0|26,0,1|6E,0,1 +[semicolon] +device= +trigger=27,0,0 +combo=6E,0,0|27,0,0|27,0,1|6E,0,1 +[singlequote] +device= +trigger=28,0,0 +combo=6E,0,0|28,0,0|28,0,1|6E,0,1 +[enter] +device= +trigger=1c,0,0 +combo=6E,0,0|1c,0,0|1c,0,1|6E,0,1 + + +; [leftShift] +; device= +; trigger=2a,0,0 +; combo=6E,0,0|60,0,0|60,0,1|6E,0,1 + +[z] +device= +trigger=2c,0,0 +combo=6E,0,0|2c,0,0|2c,0,1|6E,0,1 +[x] +device= +trigger=2d,0,0 +combo=6E,0,0|2d,0,0|2d,0,1|6E,0,1 +[c] +device= +trigger=2e,0,0 +combo=6E,0,0|2e,0,0|2e,0,1|6E,0,1 +[v] +device= +trigger=2f,0,0 +combo=6E,0,0|2f,0,0|2f,0,1|6E,0,1 +[b] +device= +trigger=30,0,0 +combo=6E,0,0|30,0,0|30,0,1|6E,0,1 +[n] +device= +trigger=31,0,0 +combo=6E,0,0|31,0,0|31,0,1|6E,0,1 +[m] +device= +trigger=32,0,0 +combo=6E,0,0|32,0,0|32,0,1|6E,0,1 +[comma] +device= +trigger=33,0,0 +combo=6E,0,0|33,0,0|33,0,1|6E,0,1 +[period] +device= +trigger=34,0,0 +combo=6E,0,0|34,0,0|34,0,1|6E,0,1 +[forwardSlash] +device= +trigger=35,0,0 +combo=6E,0,0|35,0,0|35,0,1|6E,0,1 +; [rightShift] +; device= +; trigger=36,0,0 +; combo=6E,0,0|61,0,0|61,0,1|6E,0,1 + + +; [leftCtrl] +; device= +; trigger=1d,0,0 +; combo=6E,0,0|62,0,0|62,0,1|6E,0,1 +[leftWin] +device= +trigger=5b,0,2 +combo=6E,0,0|63,0,0|63,0,1|6E,0,1 +; [leftAlt] +; device= +; trigger=38,0,0 +; combo=6E,0,0|64,0,0|64,0,1|6E,0,1 + +[spacebar] +device= +trigger=39,0,0 +combo=6E,0,0|39,0,0|39,0,1|6E,0,1 + +; [rightAlt] +; device= +; trigger=38,0,2 +; combo=6E,0,0|65,0,0|65,0,1|6E,0,1 +[rightWin] +device= +trigger=5c,0,2 +combo=6E,0,0|66,0,0|66,0,1|6E,0,1 + +[appskey to scancode 62] +device= +trigger=5d,0,2 +combo=6E,0,0|62,0,0|62,0,1|6E,0,1+ + +[appskey up blocker] +device= +trigger=5d,0,3 +combo= + +; [rightCtrl] +; device= +; trigger=1d,0,2 +; combo=6E,0,0|67,0,0|67,0,1|6E,0,1 + +[rightCtrl] +device= +trigger=1d,0,2 +combo=6E,0,0|1d,0,2|1d,0,3|6E,0,1 + + + +[num0] +device= +trigger=52,0,0 +combo=6E,0,0|52,0,0|52,0,1|6E,0,1 +[num1] +device= +trigger=4f,0,0 +combo=6E,0,0|4f,0,0|4f,0,1|6E,0,1 +[num2] +device= +trigger=50,0,0 +combo=6E,0,0|50,0,0|50,0,1|6E,0,1 +[num3] +device= +trigger=51,0,0 +combo=6E,0,0|51,0,0|51,0,1|6E,0,1 +[num4] +device= +trigger=4b,0,0 +combo=6E,0,0|4b,0,0|4b,0,1|6E,0,1 + +; [num5] +; device= +; trigger=4c,0,0 +; combo=6E,0,0|4c,0,0|4c,0,1|6E,0,1 + + +; [num5 down] +; device= +; trigger=4c,0,0 +; combo=2a,0,0 +; [num5 up] +; device= +; trigger=4c,0,1 +; combo=2a,0,1 + +[num5 down AND f23 down] +device= +trigger=4c,0,0 +combo=6E,0,0|2a,0,0 +[num5 up AND f23 up] +device= +trigger=4c,0,1 +combo=2a,0,1|6E,0,1 + + +;;original code above ^^ +; [num5] +; device= +; trigger=4c,0,0 +; combo=2a,0,0 +;num5 has been modified so that the key acts as a SHIFT instead. tee hee!! + + +[num6] +device= +trigger=4d,0,0 +combo=6E,0,0|4d,0,0|4d,0,1|6E,0,1 +[num7] +device= +trigger=47,0,0 +combo=6E,0,0|47,0,0|47,0,1|6E,0,1 +[num8] +device= +trigger=48,0,0 +combo=6E,0,0|48,0,0|48,0,1|6E,0,1 +[num9] +device= +trigger=49,0,0 +combo=6E,0,0|49,0,0|49,0,1|6E,0,1 +[numLock] +device= +trigger=45,0,0 +combo=6E,0,0|45,0,0|45,0,1|6E,0,1 +[num/] +device= +trigger=35,0,2 +combo=6E,0,0|35,0,2|35,0,3|6E,0,1 +[num*] +device= +trigger=37,0,0 +combo=6E,0,0|37,0,0|37,0,1|6E,0,1 +[num-] +device= +trigger=4a,0,0 +combo=6E,0,0|4a,0,0|4a,0,1|6E,0,1 +[num+] +device= +trigger=4e,0,0 +combo=6E,0,0|4e,0,0|4e,0,1|6E,0,1 +[numpad enter] +device= +trigger=1c,0,2 +combo=6E,0,0|1c,0,2|1c,0,3|6E,0,1 +[num.] +device= +trigger=53,0,0 +combo=6E,0,0|53,0,0|53,0,1|6E,0,1 + + + +[printscreen MAYBE] +device= +trigger=37,0,2 +combo=6E,0,0|37,0,2|37,0,3|6E,0,1 +[printscreen MAYBE] +device= +trigger=37,0,2 +combo=6E,0,0|37,0,2|37,0,3|6E,0,1 +; [scroll lock MAYBE] +; device= +; trigger=46,0,0 +; combo=6E,0,0|46,0,0|46,0,1|6E,0,1 +[scroll lock to 61] +device= +trigger=46,0,0 +combo=6E,0,0|61,0,0|61,0,1|6E,0,1 + +[scroll lock UP] +device= +trigger=46,0,1 +combo= +;remapped to scan code 61. + + + +[insert] +device= +trigger=52,0,2 +combo=6E,0,0|52,0,2|52,0,3|6E,0,1| +[home] +device= +trigger=47,0,2 +combo=6E,0,0|47,0,2|47,0,3|6E,0,1 +[pageup] +device= +trigger=49,0,2 +combo=6E,0,0|49,0,2|49,0,3|6E,0,1 +[delete] +device= +trigger=53,0,2 +combo=6E,0,0|53,0,2|53,0,3|6E,0,1 +[end] +device= +trigger=4f,0,2 +combo=6E,0,0|4f,0,2|4f,0,3|6E,0,1 +[pagedown] +device= +trigger=51,0,2 +combo=6E,0,0|51,0,2|51,0,3|6E,0,1 + + +[up] +device= +trigger=48,0,2 +combo=6E,0,0|48,0,2|48,0,3|6E,0,1 +[left] +device= +trigger=4b,0,2 +combo=6E,0,0|4b,0,2|4b,0,3|6E,0,1 +[down] +device= +trigger=50,0,2 +combo=6E,0,0|50,0,2|50,0,3|6E,0,1 +[right] +device= +trigger=4d,0,2 +combo=6E,0,0|4d,0,2|4d,0,3|6E,0,1 +[pause break???? but it's just CTRL numlock????] +device= +trigger=1d,0,4 +combo=1d,0,5|45,0,1 + +;END OF SECOND KEYBOARD +;BEYOND HERE IS A SEPERATE USB NUMPAD -- SORT OF A THIRD KEYBOARD ... IT USES F22 TO WORK +;YOU CAN DELETE EVERYTHING BELOW THIS LINE + +[num /] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=35,0,2 +combo=6d,0,0|35,0,2|35,0,3|6d,0,1 +[num *] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=37,0,0 +combo=6d,0,0|37,0,0|37,0,1|6d,0,1 + +[numpad 1 real] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=4f,0,0 +combo=6d,0,0|4f,0,0|4f,0,1|6d,0,1 +[numpad 0] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=52,0,0 +combo=6d,0,0|52,0,0|52,0,1|6d,0,1 +[numpad 2] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=50,0,0 +combo=6d,0,0|50,0,0|50,0,1|6d,0,1 +[numpad 3] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=51,0,0 +combo=6d,0,0|51,0,0|51,0,1|6d,0,1 +[numpad 4] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=4b,0,0 +combo=6d,0,0|4b,0,0|4b,0,1|6d,0,1 +[numpad 5] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=4c,0,0 +combo=6d,0,0|4c,0,0|4c,0,1|6d,0,1 +[numpad 6] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=4d,0,0 +combo=6d,0,0|4d,0,0|4d,0,1|6d,0,1 +[numpad 7] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=47,0,0 +combo=6d,0,0|47,0,0|47,0,1|6d,0,1 +[numpad 8] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=48,0,0 +combo=6d,0,0|48,0,0|48,0,1|6d,0,1 +[numpad 9] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=49,0,0 +combo=6d,0,0|49,0,0|49,0,1|6d,0,1 +[numpad +] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=4e,0,0 +combo=6d,0,0|4e,0,0|4e,0,1|6d,0,1 + +; [numpad backspace - maybe screwed up] +; device=HID\VID_046D&PID_C221&REV_0170&MI_00 +; trigger=e,0,0 +; combo=6d,0,0|e,0,0|e,0,1|6d,0,1 + +; [numpad delete maybe screwed up] +; device=HID\VID_046D&PID_C221&REV_0170&MI_00 +; trigger=53,0,0 +; combo=6d,0,0|53,0,0|53,0,1|6d,0,1 + +[numpad delete i ghuess] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=53,0,0 +combo=6d,0,0|53,0,0|53,0,1|6d,0,1 +[numpad enter key DOWN, to CTRL down] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=1c,0,2 +combo=1d,0,2 +[numpad enter key UP, to CTRL up] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=1c,0,3 +combo=1d,0,3 +[numpad minus] +device=HID\VID_13BA&PID_0001&REV_0100 +trigger=4a,0,0 +combo=6d,0,0|4a,0,0|4a,0,1|6d,0,1 +; [backspace but it is screwed up] +; device=HID\VID_046D&PID_C221&REV_0170&MI_00 +; trigger=1e,0,1 +; combo= diff --git a/Intercept/keymap.bat b/Intercept/keymap.bat index 59ebbf5..289cd36 100644 --- a/Intercept/keymap.bat +++ b/Intercept/keymap.bat @@ -1,5 +1,18 @@ @echo off -echo "@TODO: Implement this file" +echo When a new window pops up, follow the instructions. +echo After the keyboard detection is done, this dialog will continue. +pause -start /B /WAIT intercept/intercept.exe +if not exist "installer\getdeviceid.exe" ( + echo run installer before running this program + pause + goto exit +) + +start /WAIT installer/getdeviceid.exe + +cscript //Nologo installer/create_keyremap.vbs deviceid.ini keyremap.ini + +:exit +del deviceid.ini diff --git a/Intercept/keyremap.ini b/Intercept/keyremap.org.ini similarity index 100% rename from Intercept/keyremap.ini rename to Intercept/keyremap.org.ini