It is currently September 20th, 2020, 8:00 pm

ProgramOptions - Interface with running programs

Share and get help with Plugins and Addons
User avatar
theAzack9
Developer
Posts: 522
Joined: March 2nd, 2016, 6:23 pm

ProgramOptions - Interface with running programs

Post by theAzack9 »

Hi,
After weeks of procrastination am I finally ready to release my plugin, and I hope it will come to good use. I hope it isn't to complicated. If you have any questions please ask! :) Warning: Very text heavy...

Download:
Plugins and addtional programs.zip
And a little preview: Image



ProgramOptions

This plugin makes it possible for Rainmeter to talk to running windows programs. It is heavily based on bangs and auto generated variables, so get ready, because the bangs can get quite long.
Firstly, let us talk about the measure

Code: Select all

[ProgramOptions]
Measure=Plugin
Plugin=ProgramOptions
Indexes=16
AdditionalDependencies=”#@#shortcuts”
WindowMirrorPath=#WindowMirrorPath#

These are currently the only options in the plugin itself, but it defines what needs to be keept track of.

The Indexes option defines how many processes the plugin should keep track of, if there are more processes available it will discard the rest. It will also keep track of the programs pinned to the taskbar.

AdditionalDependencies defines extra folders to keep track of; all files in this folder will also be tracked. If you want multiple directories you can separate them with a ‘|’ (without the apostrophes)

The WindowMirrorPath option is just used to tell the plugin where WindowMirror.exe is, I will talk about this later. The plugin returns how many milliseconds it used to update, mostly used to debug, but I left it in because I won’t use the return for anything else. (If you got any ideas for something better, please let me know! :) )

Each time the plugin executes it refreshes the list of running processes, it will also update a few variables:

Processcount is a variable that tells how many processes are currently kept track of, should never exceed the Indexes option.
needsupdate is set to 1 if there was a change in the amount of processes it kept track of.

programname(+ a number between 0->Indexes) which is the name of the process in the selected index, it is “empty” if there are none.

Programscount(+ a number between 0->Indexes) which is the amount of instances of the program is currently running.

Pinnedappscount is a number of how many of the programs are pinned programs




These are the auto generated ones, now over to the bangs.
In the bangs you need to separate each argument by a ‘|’ (again, without the apostrophes), an example:

Code: Select all

[!Commandmeasure ProgramOptions “SetVariable|FunnyName|ChildWindowName|0|2”]
As you can see, these bangs can quickly become rather long.

Let us start with the first one on my list:
The Stop command stops the program, and has two subcommands:

“Child”: this subcommand takes two arguments, the program index and the child index.
Example:
[!CommandMeasure ProgramOptions “Stop|Child|0|0”] will close the first window

“All”: this subcommand only takes one argument, the program index and stops the whole program.
Example:
[!CommandMeasure ProgramOptions “Stop|Child|0”]. Stops the program in the first index

The StartNew command simply starts a new process of the same type, it takes one argument, and that is the program index. Example:
[!CommandMeasure ProgramOptions “StartNew|1”] Starts a new instance of the same process that is stored in index 1.

The ToFront command directs a window to the front, and it has the following subcommands:

“Child”: this subcommand takes two arguments, the program index and the child index.
Example: [!CommandMeasure ProgramOptions “ToFront|Child|0|0”] will close the first window

“Main”: this subcommand is the same as calling
[!CommandMeasure ProgramOptions “ToFront|Child|0|0”], but doesn’t need the child index.

“Handle”: this subcommand takes one argument and it is the direct handle, you can get this variable by using the SetVariable command, makes it easier if it is a specific window you want to go to front. Remember, the handle changes every time you close and open the program!
Example: [!CommandMeasure ProgramOptions “ToFront|Handle|#HandleVar#”]

The PinItem command will create a shortcut to the process in the first additional dependency. It takes one argument, and that is the program index.
Example:
[!CommandMeasure ProgramOptions “PinItem|0”]
The UnpinItem command does the opposite; it will remove the shortcut if it exists.




The SetVariable is used to set variables, the first argument is always the variable name, the second is the subcommand, afterwards is it the subcommands’ arguments:

“SkinHandle”: This is used to retrieve the skin’s window handle from Rainmeter, mainly used to define an area for the drag and drop area.
Example:
[!CommandMeasure ProgramOptions “SetVariable|SkinHandleVariable|SkinHandle”]

“ProcessName”: This subcommand is used to get the name of the process, handy when using the Process plugin and other plugins needing this information. It takes one argument, and that is the program index.
Example:
[!CommandMeasure ProgramOptions “SetVariable|ProcessName|ProcessName|0”]

“ChildWindowName”: This subcommand is used to get the window name, that will say the text that is written on the top of the window. It takes two arguments, the program index and child index.
Example:
[!CommandMeasure ProgramOptions “SetVariable|WindowName|ChildWindowName|0|1”]

“ChildrenAmount”: This subcommand gets the amount of children the current program has. I advise to use the auto-generated variable, but sometimes you will need to get the amount directly. Example:
[!CommandMeasure ProgramOptions “SetVariable|AmountChildren|ChildrenAmount|1|0”]

“ChildHandle”: This subcommand gets the handle of a selected window, can be used to send this window to front or to display it through the window mirror (As I will explain shortly). It takes two arguments, the program index and the child index.
Example:
[!CommandMeasure ProgramOptions “SetVariable|Handle|ChildHandle|1|1”]

“IsValid”: This subcommand just checks if the program index is within a valid area, and sets the variable to either 1 or 0 depending on which is true. It takes one argument and that is the program index.
Example:
[!CommandMeasure ProgramOptions “SetVariable|Valid|IsValid|1337”]

“IsPinned”: This subcommand checks if the program index is a pinned program, and sets the variable to either 1 or 0 depending on whether it is true or not. A pinned program will say that it is found in one of the AdditionalDependencies directories.
Example:
[!CommandMeasure ProgramOptions “SetVariable|Pinned|IsPinned|3”]


Lastly the “DisplayWindow” command, this is used to display a mirror of an existing window, to be able to use this command you need to define the WindowMirror option as a path to the WindowMirror.exe, which you’ll find bundled with the plugin. It has three subcommands and two of them needs an x, y, width and height:

“OpenHandle”: This will directly take the handle of the window, and opens a mirror on the specified coordinates. It takes five variables, x, y, width, height and the handle.
Example:
[!CommandMeasure ProgramOptions “DisplayWindow|OpenHandle|#Handle#|0|0|200|200”]

“Open”: This will take the specified child window and open a mirror of the window. It takes six arguments, the program index, x, y, width, height and the child index.
Example:
[!CommandMeasure ProgramOptions “DisplayWindow|Open|4|0|0|200|200|0”]

“Close”: This will close the open mirror, and it takes no arguments. Does nothing if the mirror is closed.
Example:
[!CommandMeasure ProgramOptions “DisplayWindow|Close”]


Extra programs

WindowMirror

I have also made a few extra programs; they are quite handy tho… I promise. I had to make these external because using a plugin was not possible.
First one is the WindowMirror.exe, it is bundled with the plugin. It makes it possible to mirror an existing window to another window. It is possible to open a mirror with just using this, but you’ll need the handle you want to open. It takes the same arguments as the OpenHandle subcommand. To close it, you just send Close as an argument. You can only open one mirror per exe, this is to not flood your pc with mirrors.
Example:
[“#ROOTCONFIG#WindowMirror.exe” “0|0|200|200|#Handle#”]
[“#ROOTCONFIG#WindowMirror.exe” “Close”]

DragAndDrop

Second one is DragAndDrop.exe, also bundled with the plugin. It lets you define an area in which it is possible to perform drag and drop actions. First four arguments are x, y, width and height, the last one is the directory you want to copy the file to. Again, just send Close as argument to close the file. It currently just makes a shortcut link(.lnk) to the file dropped, so if it's removed or moved it will stop functioning.
Example:
[“#ROOTCONFIG#DragAndDrop.exe” “0|0|200|200|#ROOTCONFIG#Shortcuts”]
["#DragAndDropLoc#" "xPos|yPos|Width|Height|#Shortcutlocation#|(Optional debug tag, makes window opaque)]
["#DragAndDropLoc#" "Close"] To close the window

And to show the drag and drop functionality,
Image

GetIcons

Last is the getIcons.exe, again… bundled with the plugin. It fetches the icons from all open windows, and puts them into a directory called “icons”. This way you can always have an icon for the programs in the plugin. They are saved with the processName, same as the auto-generated variable. :)



Finally am I finished explaining, it only took 1308 words… lol
With all this functionality, it has to take a lot of cpu to do all these things, doesn’t it.
Image
This is with a minimal example tho, if I were to show it with the dock I made with this, it’ll show a more realistic value:
Image
Usually it hangs around 4% with my Intel Core i5-4670K, 3.4 GHz, not overclocked. I don’t think it’s that bad for the functionality. :

If anything is still unclear, just ask and ill happily help! :)

Have fun fellow rainmeteers :)
You do not have the required permissions to view the files attached to this post.
User avatar
Active Colors
Moderator
Posts: 612
Joined: February 16th, 2012, 3:32 am

Re: ProgramOptions - Interface with running programs

Post by Active Colors »

Well done. You have only left making those icons draggable. ;-)
tb.gif
You do not have the required permissions to view the files attached to this post.
User avatar
raiguard
Posts: 667
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: ProgramOptions - Interface with running programs

Post by raiguard »

theAzack9 wrote:I hope it will come to good use.
This is amazing! Great job! I look forward to implementing this in a future skin suite... ;)
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
User avatar
QwopJoans
Posts: 115
Joined: February 6th, 2016, 11:06 pm

Re: ProgramOptions - Interface with running programs

Post by QwopJoans »

I'm having a little difficulty with the DragAndDrop.exe, Trying to figure out how to use it and what it can do. Your example skin is a little hard to understand and follow, so I can't really look to it for help. How can I make something like this work? I'm essentially trying to drag the file from one location to another.

Code: Select all

[Rainmeter]
[Variables]
Path=C:\Users\User\Documents\
[Meter]
Meter=Image
W=40
H=40
SolidColor=0,0,0,255
MouseOverAction=[“#@#DragAndDrop.exe” “0|0|200|200|#Path#”]
Edit: I understand what draganddrop.exe does now, it can pin things to the taskbar essentially, so it won't do what I wanted it to do.
User avatar
theAzack9
Developer
Posts: 522
Joined: March 2nd, 2016, 6:23 pm

Re: ProgramOptions - Interface with running programs

Post by theAzack9 »

QwopJoans wrote:I'm having a little difficulty with the DragAndDrop.exe, Trying to figure out how to use it and what it can do. Your example skin is a little hard to understand and follow, so I can't really look to it for help. How can I make something like this work? I'm essentially trying to drag the file from one location to another.

Code: Select all

[Rainmeter]
[Variables]
Path=C:\Users\User\Documents\
[Meter]
Meter=Image
W=40
H=40
SolidColor=0,0,0,255
MouseOverAction=[“#@#DragAndDrop.exe” “0|0|200|200|#Path#”]
Edit: I understand what draganddrop.exe does now, it can pin things to the taskbar essentially, so it won't do what I wanted it to do.

Sorry for late reply...

I am currently remaking basically everything to be better and easier to use, and i have converted the Drag & Drop.exe to be a plugin instead with a lot more features like copy files, delete files, move files, create shortcut to file and get the file location of the file. If you have any other ideas or needs, please let me know and i'll implement it! :) i aim to release it in two or three weeks to github, reddit and this forum. (Sorry for it being so long, but i have very limited amounts of time thanks to exams)

If you have any other ideas on what should be added to any of the plugins, please let me know...

theAzack9
User avatar
QwopJoans
Posts: 115
Joined: February 6th, 2016, 11:06 pm

Re: ProgramOptions - Interface with running programs

Post by QwopJoans »

Can't wait to see how the plugin turns out, I'm excited for the functionality you've mentioned so far. I'm hoping to use it in my RainExplorer skin so that the user can drag and drop files from one folder to another or from the desktop into the current directory. So far everything you've mentioned is exactly what I'm looking for so I can't wait.
User avatar
theAzack9
Developer
Posts: 522
Joined: March 2nd, 2016, 6:23 pm

Re: ProgramOptions - Interface with running programs

Post by theAzack9 »

QwopJoans wrote:Can't wait to see how the plugin turns out, I'm excited for the functionality you've mentioned so far. I'm hoping to use it in my RainExplorer skin so that the user can drag and drop files from one folder to another or from the desktop into the current directory. So far everything you've mentioned is exactly what I'm looking for so I can't wait.
Just thought i should let you know that i decided to release it early :)

link: https://forum.rainmeter.net/viewtopic.php?f=18&t=23107
User avatar
cturner314
Posts: 1
Joined: February 5th, 2017, 2:02 am

SOLVED: Re: ProgramOptions - Interface with running programs

Post by cturner314 »

You haven't explained how to use getIcons.exe. I have tried to execute it in the skin, but it does not create a folder 'icons'. If I create a folder 'icons' and place getIcons in the same directory, it still does nothing. Loving the programOptions plugin!

Even tried to execute it like you did in my Lua file, but it just creates an error and rainmeter crashes

Code: Select all

	
	if needsupdate == 1 then
			SKIN:Bang('["#@#getIcons.exe"]')
	end
Thanks

Started to TroubleShoot by copying files from your skin instead of the getIcons.exe straight from 'Plugins And Additional Programs.zip', turns out that the Windows API Plugins are required. Once again just wanted to say the effort you have put into these is amazing. Thanks for the Plugins and Programs!
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: ProgramOptions - Interface with running programs

Post by kyriakos876 »

Lovely!
royalrex
Posts: 1
Joined: September 11th, 2017, 6:55 am

Re: ProgramOptions - Interface with running programs

Post by royalrex »

I have a little trouble removing the combining of same applications. WindowMirror.exe was the first thing that I removed but now the problem is, I don't know how to separate same apps to individual icons. Any ideas?