<p dir="auto">Last week I made a post about the connection between the Logitech LCD and<br />
the Steemit blockchain. <a href="https://steemit.com/programming/@flash4yard/python-programming-project-control-logitech-g510-lcd-and-show-steemit-stats" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Here
<p dir="auto"><span>A few days ago <a href="/@techtek">@techtek presented me his project 'Blinkit' on discord, and he asked me to make it possible to use Logitech Keyboards with RGB Backlight too.
<h2>The plan
<p dir="auto">We talked about how the idea of a flashing keyboard can be integrated into his existing project.<br />
Blinkit itself is written in VB.NET/VBScript. So I had to find a way to get this working.<br />
Here are the things I have used to solve this task:
<ul>
<li>Logitech LED SDK Wrapper.dll <a href="https://www.logitechg.com/de-de/developers" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">You can get it here
<li>VB.net as the programming language to create a new .dll<br />
(I will tell you later why we need another .dll file)
<li>VBScript as the final project language
<li>Visual Studio Community Edition 2017 <a href="https://www.visualstudio.com/de/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Download
<li>Notepad ++ <a href="https://notepad-plus-plus.org/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Download
<h3>The program I created runs by itself, but it is designed to be integrated into the BlinkIt project.
<h2>The resulted problem
<p dir="auto">The problem is that the LogitechLedEnginesWrapper.dll is not coded in a vb.net<br />
compatible format. So if I want to load this DLL in vbs it does not run and gives an error.
<pre><code>dim dll
set dll = CreateObject("LogitechLedEnginesWrapper.dll")
<h1>The solution
<p dir="auto">I created ,in VB.NET, a DLL that imports the functions needed from the Original .dll so VBScript can read the new dll.
<p dir="auto">To accomplish that follow these steps:
<h1>Step 1
<ul>
<li>open Visual Studio 2017 with administrator privileges
<li>file -> new Project<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/Fb0N4bA.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/Fb0N4bA.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/Fb0N4bA.png 2x" />
<li>choose Class Library(.net framework) and give it a name as you like<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/BsR0p4n.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/BsR0p4n.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/BsR0p4n.png 2x" />
<li>This should now pop up
<li>rightclick Class1.vb and delete it
<li>Now go to project -> add new item<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/aP64c59.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/aP64c59.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/aP64c59.png 2x" />
<li>There should pop up a new window:<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/NGtypK9.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/NGtypK9.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/NGtypK9.png 2x" />
<li>There you choose COM Class and press Add
<li>Visual studio created some lines of code for us:<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/IOg1joC.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/IOg1joC.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/IOg1joC.png 2x" />
<p dir="auto">(You can rename the ComClass1 if you like)
<p dir="auto"><em>At first there is a warning saying:
<pre><code>'Microsoft.VisualBasic.ComClassAttribute' is specified for class 'ComClass1' but 'ComClass1' has no public members that can be exposed to COM; therefore, no COM interfaces are generated.
<p dir="auto">Don't get confused by that. We will fix it later.
<h3>We have set everything up to start coding :D
<h2>Step 2
<p dir="auto">To import native dll files we need to use the System.Runtime.InteropServices library.
<ul>
<li>Import this library in the top of the project<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/2MWaDa3.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/2MWaDa3.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/2MWaDa3.png 2x" />
<li>Include the attribute as shown in the red box<br /><br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/4BS8aRU.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/4BS8aRU.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/4BS8aRU.png 2x" /><br />
The ClassID, InterfaceID and EventsID variable is set by the IDE. Don't change these values.<br />
We will need the ClassID later.<span>
After renaming the class and opening the <a href="/trending/region"> #Region it should look like this:
<h2>Step 3
<ul>
<li>Include the code that imports the functions from the Logitech DLL<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/acvIUH6.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/acvIUH6.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/acvIUH6.png 2x" /><br />
We have to specify the correct name of the function in that specific dll like LogiLedInit()<br />
and the right return value and also the right parameters have to be set. You can get these informations in the<br />
documentary of the original dll.
<h2>Step 4
<ul>
<li>Create a function that make the keyboard flashing in different colors<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/Gsp6hGv.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/Gsp6hGv.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/Gsp6hGv.png 2x" /><br />
The function is called LogiLed and it takes two parameters. The color as a string and the time how long the effect should be played.<br />
The return value is an integer. See now the error described above is gone :D
<h3>Explanation of the function
<ul>
<li>To start the connection with the keyboard we have to initialise the keyboard (line 39)
<li>This takes a little while so we put a Sleep function after that (line 40)
<li>The Select function chooses which color we want to be shown (line 42)
<li>If one case gets executed the LogiLedFlashLighting function gets called (lines 44,47,50)
<h4>The function takes 5 parameters:
<ul>
<li>red - percentage of the color red 0-100
<li>green - percentage of the color green 0-100
<li>blue - percentage of the color blue 0-100
<li>time - how long the effect should show up in ms
<li>interval - the time between each on/off cycle in ms
<p dir="auto">If this function gets called the keyboard starts flashing but the programm goes on and does not wait<br />
until the keyboard stopped. So we have to wait as long as we want the effect to go on.<br />
After the effect is gone we disconnect our application from the keyboard with the<br />
LogiLedShutdown function (line 54)
<h3>Thats the hole program!
<h2>Step 5
<p dir="auto">Now we have to add a "Strong name" to our dll. This is done by rightclicking the project.
<p dir="auto"><img src="https://images.hive.blog/768x0/https://i.imgur.com/J5XEmqX.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/J5XEmqX.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/J5XEmqX.png 2x" />
<p dir="auto">and go to properties.
<p dir="auto"><img src="https://images.hive.blog/768x0/https://i.imgur.com/m5cbKRe.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/m5cbKRe.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/m5cbKRe.png 2x" />
<p dir="auto">This should pop up.
<p dir="auto">On the left go to "Signing" and tick the box "Sign the assembly"<br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/1zPQ6wh.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/1zPQ6wh.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/1zPQ6wh.png 2x" />
<p dir="auto">In the drop down menu choose <new..><br />
<img src="https://images.hive.blog/768x0/https://i.imgur.com/LnALkz4.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/LnALkz4.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/LnALkz4.png 2x" />
<p dir="auto">Choose a name and disable the "protect my keyfile with a password".<br />
Now you can close the window in the tab menu.
<p dir="auto"><img src="https://images.hive.blog/768x0/https://i.imgur.com/K8izD3e.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/K8izD3e.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/K8izD3e.png 2x" />
<p dir="auto">If not done yet save the project. Go to file -> save all.
<p dir="auto"><img src="https://images.hive.blog/768x0/https://i.imgur.com/xh2Mjuu.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/xh2Mjuu.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/xh2Mjuu.png 2x" /><br />
Make sure that the marked tick box is ticked^^
<p dir="auto">After that being done. We can build our dll file by rightclicking the project like we did last time<br />
and hit build. You will get an error if Visual Studio is not opened with administrator privileges!
<h2>Here is a picture of the complete code:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://i.imgur.com/zpPzdTJ.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/zpPzdTJ.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/zpPzdTJ.png 2x" />
<p dir="auto">Now we can close Visual Studio.<br />
Next go to the directory where you saved your project.<br />
(pathtoproject\bin\Debug) There you can find your .dll file.
<p dir="auto">As the next step we have to register this dll to windows.<br />
This is done by the use of the RegAsm.exe found in:
<pre><code>C:\Windows\Microsoft.NET\Framework\v4.0.30319
<p dir="auto">Open a command prompt and go to this directory.<br />
After that type:
<pre><code>RegAsm.exe pathtoproject\bin\Debug\name.dll /codebase
<p dir="auto">This registers the dll in windows. If you want to remove the registration type:
<pre><code>RegAsm.exe pathtoproject\bin\Debug\name.dll /u
<p dir="auto">To check everthing worked open regedit.exe.<br />
There you press Ctrl+f to start a search. Put in there the ClassID from the beginning.
<p dir="auto">It should show something like this:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://i.imgur.com/acj6WAc.png" srcset="https://images.hive.blog/768x0/https://i.imgur.com/acj6WAc.png 1x, https://images.hive.blog/1536x0/https://i.imgur.com/acj6WAc.png 2x" />
<p dir="auto">There you can see the path where the dll is located.
<h2>Starting with VBScript
<p dir="auto">Create a new file and add .vbs as the format.<br />
Open that file with an editor like Notepad++<br />
and write in there:
<pre><code>dim logi
set logi = CreateObject(LogitechDll.LogitechDll) 'or parameter that is shown in the registry under Class
logi.LogiLed "blue",3000
<p dir="auto">First we create a new variable called logi. After that we set it as a new object from the dll.<br />
At this point we can access the functions inside the dll.<br />
Then we call the function LogiLed and pass the string that defines the color and the time how<br />
long the effect should be shown.<br />
Make sure the LogitechLedEnginesWrapper.dll is in the same directory as the .vbs file!
<p dir="auto">If you run this file it should look like this:
<p dir="auto"><img src="https://images.hive.blog/0x0/https://i.imgur.com/utsx8S3.gif" />
<h3>And thats it!
<p dir="auto">You created your own "bridge" between a native dll and VBScript, if you dont want to make everything by yourself you can use the files i build and uploaded!
<p dir="auto">You can download the project files <a href="https://github.com/flash4yard/blinkitLogitechLED" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here.
<p dir="auto">Blinkit can be downloaded <a href="https://github.com/techtek/Blinkit/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here.
<p dir="auto">I hope everything is easy to follow, and if anything is unclear please let me know in the comments or on the github project page.
<p dir="auto"><br /><hr /><em>Posted on <a href="https://utopian.io/utopian-io/@flash4yard/blinkit-or-logitech-rgb-keyboard-preparation" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Utopian.io - Rewarding Open Source Contributors<hr /><p>
Blinkit | Logitech RGB Keyboard preparation
7 years ago in #utopian-io by flash4yard (53)
$1.54
- Past Payouts $1.54
- - Author $1.22
- - Curators & beneficiaries $0.33
- > utopian.pay: $0.12
26 votes
- drmake: $0.68
- jefpatat: $0.26
- techtek: $0.23
- mkt: $0.16
- steemmakers: $0.14
- yuxi: $0.02
- theobaldjoachim: $0.00
- jjay: $0.00
- thepocketgamer: $0.00
- electronicsworld: $0.00
- applicationist: $0.00
- maxxx: $0.00
- fuckyeah: $0.00
- flash4yard: $0.00
- salvadorcrg: $0.00
- dmxmaster: $0.00
- shatilist: $0.00
- agata93: $0.00
- electricswine: $0.00
- rosynesn: $0.00
- and 6 more
I am afraid that your contribution cannot be accepted because it does not follow the rules:
Chat with us on Discord.Need help? Write a ticket on https://support.utopian.io.
[utopian-moderator]
Hey @justyy, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
Thank you for helping and contributing to the Blinkit project, and for adjusting your code, to make it prepared for Blinkit. It was a lot of fun getting in touch, and your a very fast programmer, and i hope to see more contributions from you in the future.
The new interface for Blinkit is worked on and unfinished but it's going well, and i'm looking forward to have it all in place and functional, Thanks again for your help.
another fantastic way to receive notifications with Blinkit !! This really shows how Blinkit is flexible and awesome !! more to come soon with new integrations (by me) and new interface (by @techtek). Let's make the world blink with Blinkit
Join our Discord Channel to connect with us and nominate your own or somebody else's posts in our review channel.
Help us to reward you for making it ! Join our voting trail or delegate steem power to the community account.
Your post is also presented on the community website www.steemmakers.com where you can find other selected content.
If you like our work, please consider upvoting this comment to support the growth of our community. Thank you.