It is currently April 18th, 2024, 5:05 pm

[Solved] Autohotkey and Enigma Toggle

Share and get help with Plugins and Addons
NictraSavios
Posts: 30
Joined: August 23rd, 2011, 8:21 am
Location: Nova Scotia, Canada

[Solved] Autohotkey and Enigma Toggle

Post by NictraSavios »

** I ask everyone to read through the comments, this post is left intact for those who seek help with similar issues in the future. Alot of the main issues I have are solved, and I have a single small issue left, as defined here: http://rainmeter.net/forum/viewtopic.php?f=5&t=9415 **

Alright, I've done my introduction, So now its time to get down to business >:D

The enigma toggle is a very interesting thing, what interests me is how it works I will admit upfront, that I have absolutely no idea how rainmeter works. Now that we have established my incompetence, I make my proposal.

I monitored the system calls from rainmeter, got the state of the file that I believed controlled the on\off, and my plan was simple, I got the file while the state was on, and while it was off. Opened up Cygwin, ran a diff on them and came to the conclusion of this:

When toggle == hide

Code: Select all

State1=Show
State2=Hide
When toggle == show

Code: Select all

State1=Hide
State2=Show
So, to test my theory, I edited the values manally and refreshed rainmeter.... and what do I get? ... nothin. Zip, zero, nada.

My attention now focuses on:

Code: Select all

LeftMouseUpAction=!Execute [!Rainmeter#State1#Group EnigmaSidebar][!RainmeterWriteKeyValue Variables State1 #State2#][!RainmeterWriteKeyValue Variables State2 #State1#][!RainmeterRefresh]
From what I can tell in my highly knowledgeable educationalized super-duper expert opiniononi is that...
(Hold your skulls, your mind will be blown)
When you click the left mouse button, it executes a call to rainmeter to find state one in the group "Enigma Sidebar", then it writes the value of state1 in state2, and then state2 in state1 (hey.... wouldn't that mean one==two, so then two==one?) Then refreshes rainmeter...

So from that highly technical readout, I can see that I just did exactly what I did by hand to text it... and I ... well... I'm back at square one without learning anything.


So ... The Epic Purpose!

I want to learn what, if any, dll calls this makes, and if I can replicate its function in autohotkey (I can take care of that part, no worries)... So what I need to know, is EXACTLY what that string dose to hide rainmeter, and exactly what I did wrong when I tested my theory.

If I can get this working, I can make it so you can toggle enigma via a keyboard and/or mouse shortcut, and distribute an executable for this purpose, savy?

PS: How was my first post?
Last edited by NictraSavios on August 24th, 2011, 5:22 pm, edited 2 times in total.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Autohotkey and Enigma Toggle

Post by Kaelri »

Ok, here's what's going on. State1 and State2 are variables. They're defined in the Toggle skin's [Variables] section, which means they can only affect things in that skin. When Rainmeter executes a command or renders a meter, those variables are parsed.

So when the [Variables] section looks like this -

Code: Select all

[Variables]
State1=Hide
State2=Show
- and your mouse action sends a command like this -

Code: Select all

LeftMouseUpAction=!Execute
[!#State1#Group "EnigmaSidebar"]
[!WriteKeyValue Variables State1 "#State2#"]
[!WriteKeyValue Variables State2 "#State1#"]
[!Refresh]
- it gets translated as this:

Code: Select all

LeftMouseUpAction=!Execute
[!HideGroup "EnigmaSidebar"]
[!WriteKeyValue Variables State1 "Show"]
[!WriteKeyValue Variables State2 "Hide"]
[!Refresh]
So the actual process is probably obvious now: the Toggle skin's mouse action sends the command to either !ShowGroup or !HideGroup, depending on the current value of #State1#. Then it simply reverses the values, so that the next click will have the opposite effect.

Although I don't know exactly how variables work in Autohotkey, I'm sure this would be extremely easy to replicate. !Bang commands can be passed to Rainmeter through the command line, as such:

Code: Select all

"C:\Program Files\Rainmeter\Rainmeter.exe" !HideGroup "EnigmaSidebar"
"C:\Program Files\Rainmeter\Rainmeter.exe" !ShowGroup "EnigmaSidebar"
Your first post is fine. Just relax and enjoy yourself. ;)
NictraSavios
Posts: 30
Joined: August 23rd, 2011, 8:21 am
Location: Nova Scotia, Canada

Re: Autohotkey and Enigma Toggle

Post by NictraSavios »

Kaelri wrote:

Code: Select all

"C:\Program Files\Rainmeter\Rainmeter.exe" !HideGroup "EnigmaSidebar"
"C:\Program Files\Rainmeter\Rainmeter.exe" !ShowGroup "EnigmaSidebar"
Now those two lines, just made it perfect. Autohotkey has a run command (same as the run dialog from Win+R)

Thank you very much! My addition to the community should be ready soon... one question, where would I post it so that others would know about it? And is there a way to contact the enigma dev's about adding the .exe in as a part of the theme?

Edit: Okay, I'm halfway through writing this, and I hit a snag. How do I verify that the toggle widget is active and being used? (That way if enigma isn't being used, they won't turn it off.... [ and useless action] which may cause bugs for other themes, or they will be wondering why the one or two parts of enigma they use just disappeared)
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Autohotkey and Enigma Toggle

Post by Kaelri »

NictraSavios wrote:one question, where would I post it so that others would know about it?
Any of the following:
- DeviantArt.
- Customize.org.
- Our Plugins & Addons forum.
NictraSavios wrote:And is there a way to contact the enigma dev's about adding the .exe in as a part of the theme?
I am the Enigma developer. ;) I'll certainly take a look at your utility when it's available, although I typically limit the skin package to actual Rainmeter skins and themes, rather than peripheral accessories.
NictraSavios wrote:Okay, I'm halfway through writing this, and I hit a snag. How do I verify that the toggle widget is active and being used? (That way if enigma isn't being used, they won't turn it off.... [ and useless action] which may cause bugs for other themes, or they will be wondering why the one or two parts of enigma they use just disappeared)
If you have some method of parsing MS-INI files from Autohotkey, you can check the user's Rainmeter.ini file to see whether the [Enigma\Taskbar\Toggle] section is set as "Active=1" (activated) or "Active=0" (deactivated). I would suggest passing the location of Rainmeter.ini from Rainmeter to Autohotkey as a command line parameter, in order to account for portable installations and other custom settings. I would also have the script check for Active=1 regularly and automatically terminate if the setting changes (or Rainmeter is closed).
NictraSavios
Posts: 30
Joined: August 23rd, 2011, 8:21 am
Location: Nova Scotia, Canada

Re: Autohotkey and Enigma Toggle

Post by NictraSavios »

Kaelri wrote: I am the Enigma developer. ;) I'll certainly take a look at your utility when it's available, although I typically limit the skin package to actual Rainmeter skins and themes, rather than peripheral accessories.
:), I am coding this to blend seamlessly into rainmeter, It will alow your toggle to be activated via the keyboard. And since I am getting it to do it exactly the way your toggle dose, it should not create any new bugs :D
Kaelri wrote: If you have some method of parsing MS-INI files from Autohotkey, you can check the user's Rainmeter.ini file to see whether the [Enigma\Taskbar\Toggle] section is set as "Active=1" (activated) or "Active=0" (deactivated). I would suggest passing the location of Rainmeter.ini from Rainmeter to Autohotkey as a command line parameter, in order to account for portable installations and other custom settings. I would also have the script check for Active=1 regularly and automatically terminate if the setting changes (or Rainmeter is closed).
[/quote][/quote]

** Warning, many questions ahead... Feel free to tell me RTM at anytime, but please provide a link to said manual**

Okay, can you tell me the variable rainmeter uses for the location of rainmeter.ini, I was unable to find it via google.

And uh.... portable... installations? .... fun. (*sigh... extra work*)
So far I've been using the location of %A_MyDocuments%\Rainmeter\Skins\Enigma\Taskbar\Toggle\Toggle.ini

Where %A_MyDocuments% is (In my case) C:\User\NictraSavios\Documents
In a portable installation, where is the toggle stored?
What command would allow rainmeter to pass me the #Skinpath# variable? (That would solve the above issue)


Edit3: I have the variables now: #PROGRAMPATH# and #SETTINGSPATH#, could you tell me how to ask rainmeter where they are? Got it

And finally, (Sorry for all the damn questions), do you think this is proper syntax for rainmeters command line usage?

Code: Select all


C:\Program Files\Rainmeter\Rainmeter.exe !HideGroup "EnigmaSidebar"
C:\Program Files\Rainmeter\Rainmeter.exe !RainmeterWriteKeyValue Variables State1 Show #SKINSPATH#Enigma\Taskbar\Toggle\Toggle.ini
C:\Program Files\Rainmeter\Rainmeter.exe !RainmeterWriteKeyValue Variables State2 Hide #SKINSPATH#Enigma\Taskbar\Toggle\Toggle.ini
C:\Program Files\Rainmeter\Rainmeter.exe !RainmeterRefresh

Don't worry, this is just for hiding it, I will edit it for the reverse option.


EDIT: Sorry, Damn, one last question..... I realized that because of portable installations, rainmeter.exe will not always be in C:\Program Files\Rainmeter\ (and also that I need to account for 32-bit, in Program Files (x86)) .... Hate to ask, whats the variable to get that path? Got it :)

EDIT2: Don't worry, no questions this time :D, I forgot to say this. I don't need to constantly check since this program only runs twice. Once on it startup (where it checks if rainmeter is installed, and that toggle.ini exists), and then on runtime. When you press the shortcut that toggles it, when it is activated (at runtime) I will make it check for that flag, and if it is 0, go no further in the script, savy?

And also, for load averages, I have alot of enigma on my destop, I average about 10% cpu and 15mb of ram to rainmeter... this little .exe will take, at most (at runtime) 500kb of ram, but for the most part, will sit comfortably with arounnd 100, since all it dose is wait for the hotkey trigger.
Last edited by NictraSavios on August 24th, 2011, 12:53 am, edited 4 times in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Autohotkey and Enigma Toggle

Post by jsmorley »

All the documentation is here:

http://rainmeter.net/cms/Support

You REALLY need to go through the documentation and get a handle on how Rainmeter works. You are going a bit fast and furious, and it's just going to lead you down rabbit holes you don't need to go down. For instance, talk about "poking" at Rainmeter with .dll calls is not wise at all. That can only make Rainmeter unstable at best, and it certainly won't do what you expect. You can't just use a Windows API call to so something to a Rainmeter window outside of Rainmeter's code, as it will just come off the rails. We have a "plugin" architecture if you want to interact with Rainmeter using your own C++ or C# code.

http://rainmeter.net/cms/Developers_beta

And if you want to see the C++ code for Rainmeter, it is here:

http://code.google.com/p/rainmeter/source/checkout

Anyway, the way we generally get Rainmeter location info for "addons" is to have them in their own folder in the Rainmeter\Addons\ folder. This will generally be C:\Program Files\Rainmeter\Addons\ or C:\Program Files (x86)\Rainmeter\Addons\ folders, but in a portable install can be about anywhere. Then the addon can always find Rainmeter.exe in ..\..\Rainmeter.exe. This allows it to know where to send bangs as a parameter call to the application. You should really always use bangs to communicate with Rainmeter from an addon executable, (as opposed to a plugin) and addons that need to communicate with Rainmeter should always be installed in \Addons in their own folders. It is easy to distribute addons, either as part of a skin or alone, using a .rmskin. It will know where to put them.

http://rainmeter.net/cms/Bangs_beta
NictraSavios
Posts: 30
Joined: August 23rd, 2011, 8:21 am
Location: Nova Scotia, Canada

Re: Autohotkey and Enigma Toggle

Post by NictraSavios »

jsmorley wrote:All the documentation is here:

http://rainmeter.net/cms/Support

You REALLY need to go through the documentation and get a handle on how Rainmeter works. You are going a bit fast and furious, and it's just going to lead you down rabbit holes you don't need to go down. For instance, talk about "poking" at Rainmeter with .dll calls is not wise at all. That can only make Rainmeter unstable at best, and it certainly won't do what you expect. You can't just use a Windows API call to so something to a Rainmeter window outside of Rainmeter's code, as it will just come off the rails. We have a "plugin" architecture if you want to interact with Rainmeter using your own C++ or C# code.

http://rainmeter.net/cms/Developers_beta

And if you want to see the C++ code for Rainmeter, it is here:

http://code.google.com/p/rainmeter/source/checkout

Anyway, the way we generally get Rainmeter location info for "addons" is to have them in their own folder in the Rainmeter\Addons\ folder. This will generally be C:\Program Files\Rainmeter\Addons\ or C:\Program Files (x86)\Rainmeter\Addons\ folders, but in a portable install can be about anywhere. Then the addon can always find Rainmeter.exe in ..\..\Rainmeter.exe. This allows it to know where to send bangs as a parameter call to the application. You should really always use bangs to communicate with Rainmeter from an addon executable, (as opposed to a plugin) and addons that need to communicate with Rainmeter should always be installed in \Addons in their own folders. It is easy to distribute addons, either as part of a skin or alone, using a .rmskin. It will know where to put them.

http://rainmeter.net/cms/Bangs_beta

Thank you, but may I be so bold as to ask you to read through the comments? I have been using rainmeter.exe and bangs in the script and parsing .ini files for the information it requires. As for C++/C ... I am not using either of them. I may be very experienced with C++, but there is a languages for every job, and in this case, C++ can do the job, but autohotkey can do it better.

I originally thought about using dll calls before I was shown the right way. I have also been reading through the bang article, and am working my way through the documentation, as for the portable installation, if you will be so kind as to read through my banter, I last asked about how to call variables from rainmeter.exe... If I can get that, portable installation won't matter, I can just use variables to find everything I need :P

As for fast and furious... Well now love, this is how I learn. Don't sit on the sidelines and watch a game, get in there and play haha. I'll mess up and fall down, but in the end, I can get a working product and learn alot more :D.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Autohotkey and Enigma Toggle

Post by jsmorley »

Unfortunately, there is no simple way to "get" a variable from Rainmeter. You can find Rainmeter.ini, (it will be in the same folder with Rainmeter.exe on a portable install, and in %APPDATA%\Rainmeter on a normal install) which will get you the path to skins and all the active config names, but that is about all you can get from a purely external application. Might be all you need for this effort though.

The other option is a bit more coding, but you can query Rainmeter with "window messages". That can return some important information.

http://rainmeter.net/cms/Plugins-WindowMessages_beta
NictraSavios
Posts: 30
Joined: August 23rd, 2011, 8:21 am
Location: Nova Scotia, Canada

Re: Autohotkey and Enigma Toggle

Post by NictraSavios »

jsmorley wrote:Unfortunately, there is no way to "get" a variable from Rainmeter. You can find Rainmeter.ini, (it will be in the same folder with Rainmeter.exe on a portable install, and in %APPDATA%\Rainmeter on a normal install) which will get you the path to skins and all the active config names, but that is about all you can get from a purely external application. Might be all you need for this effort though.

The only other option is to query Rainmeter with "window messages". That can return some important information.

http://rainmeter.net/cms/Plugins-WindowMessages_beta
Thank you, I thought that might be the case, but since you have informed me of the location of rainmeter.ini in a portable install, that is infact, everything I need :P

I'll take a stab and say that the variables are defined in there, in which case I can parse the ini rather quickly.

With this new information, I'm going to rewrite the script to be variable dependent instead of path dependent.
NictraSavios
Posts: 30
Joined: August 23rd, 2011, 8:21 am
Location: Nova Scotia, Canada

Re: Autohotkey and Enigma Toggle

Post by NictraSavios »

Alright, I need one last thing (The rest of this is just writing the code)

Is this correct (If you were to run it from the command line, would it work) :

Code: Select all

C:\Program Files\Rainmeter\Rainmeter.exe !RainmeterWriteKeyValue Variables State1 Show "#Enigma\Taskbar\Toggle\Toggle.ini"
I can't seem to get it to work, which is really the one thing I need from rainmeter. I could use autohotkey to write it, but a rainmeter call seems more appropriate and probably more stable.