It is currently April 20th, 2024, 12:51 pm

RainInput - Get text input in Rainmeter for programs

Share and get help with Plugins and Addons
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

RainInput - Get text input in Rainmeter for programs

Post by jsmorley »

I though I would move the discussion here from the "Request Features" forum as it fits better here...
Rykennedyan wrote:I've been able to do a lot with Twitter already. The only thing I think Rainmeter needs is the ability to enter text directly, and be able to submit it. That way a Twitter Rainmeter solution would be comprehensive.
Might be able to do that with a helper for the short term... Something in AutoIt3 which puts a text input box of a user defined size and no other GUI elements at a specified screen location and then sends the entered text off to Twitter... That way you could integrate it into your skin (with a fake input box of the same size as a place holder) and when a user clicks on the fake text box the real text box comes alive, takes input, sends it off to Twitter and disappears...

"Enter" accepts the input, "Escape" (or maybe a mouse click outside the text box) exits without doing anything.

Need to call it with parms like "TwitterBox.exe TwitterName, TwitterPassword, LeftPos, RightPos, TopPos, BottomPos, InputBackgroundColor, InputTextColor" so it could be flexible enough to fit with people's skins.

Probably need some kind of counter to the left or right which counts chars in the input box so you know when you are getting near 140. Setting a limit of 140 is easy, but a counter so the user knows how far along they are is more consistent with most Twitter clients.
dragonmage wrote:Before you get started on this, I have an idea...

I like the sounds of this, but if you make the textbox it's own seperate program, that could send the commands to other "mini-apps" (like your Twitter app) I'd like it better.
dragonmage wrote:Or we can just use Launchy or Executor, my preference is the latter. Here's details on setting up Executor to tweet. http://www.burning-star.com/2008/08/take-executor-beyond-application-launching/
Not sure I follow... What is the benefit to limiting this to those who have Executor (I'm not a launchy or executor fan myself, more of a mouse person than a keyboard shortcut person) or trying to build in calls to the hundreds of assorted twitter clients available, rather than just connecting to twitter via TCP and using their API to send the tweet?

Can you expand a bit on your thinking?
dragonmage wrote:I was just giving the Launchy or Executor idea as another option for people to use.

As far as your app, I was suggesting that it be split into two apps. The Twitter app itself, and the text entry app. You would then specify which app to send the text to when typing the text. This would allow you to use the same textbox to send commands to other apps that you or others might make to interact with rainmeter, a sort of commandline.

The text app could then be configured via .ini. You set the dimensions, colors, etc in the ini file, maybe even set some aliases for the app paths. Say we have these apps in Rainmeter\Addons\ , the textbox app would be in Rainmeter\Addons\TextBox the other apps would be beside it (Like Rainmeter\Addons\TwitterBox\. We could put an alias in the TextBox.ini like..

!tw=..\TwitterBox\TwitterBox.exe twittername, twitterpass,

Then to tweet you just type !tw "I'm testing TwitterBox"

The TextBox app passes the parms to TwitterBox

Same concept would allow for other apps to be made that the TextBox could send info to.
Ah... Sounds like a good idea. An extension of that is that rather than concentrating on Twitter, which I despise anyway, just write a helper that collects input and allow the text to be sent as a parameter to any program which accepts command line input. Then it is up to the user to send the text to his Twitter client, Executor, a wallpaper changer, a media player, RainThemes, whatever... Since different programs need different command line parameters, that could still be fleshed out in .cfg files for RainInput.exe (I think I am in a rut on these names... ;-)) So in a \RainInput folder you have TweetDeck.cfg which has all the parms needed to send a tweet using that program, with RainInput filling in a "variable" input parameter. So for instance:

!execute ["C:Program Files\Rainmeter\Helpers\RainInput\RainInput.exe" RainThemes.cfg LeftPos, RightPos, TopPos, BottomPos, InputBackgroundColor, InputTextColor]

(with those "LeftPos", "InputTextColor" etc. variables being numbers of pixels and strings like "255,255,255" of course)

RainInput would collect the input in a text box, and using a RainThemes.cfg file in the \RainInput folder:

RainThemes.cfg
ProgramPath=C:\Program Files\Rainmeter\RainThemes.exe
Parm1=/load
Parm2=$INPUT

would know to do something like this:

ShellExecute($ProgramPath & " " & $Parm1 & " " & $Parm2)

Which would cause RainThemes to load a theme with the name collected in $INPUT by RainInput.

Not all programs accept command line input of course, and there is the potential ugliness of an application GUI being launched by a command line input which may or may not close on its own, but that would have to be sorted out by the user. There are usually alternatives that will work the way they want. Twitter alone has about a hundred clients available in every flavor...

I like it... Gets me out of the Twitter business and is something that if not too hideously complicated to use might be good for lots of other needs.

Let me go figure out how to put up an input box with no other GUI elements. I know it can be done, but I haven't messed with it before. I need to find out how to associate a "control" like an input box with an application with no (or an invisible) "window". I think if I make the application window the same size as the input box, with no Titlebar, Menubar or borders, I can have it behave like a proper Windows application and not just an "orphan" control. My biggest concern is making sure it "exits" properly no matter what the user does or whether or not it has "focus". I don't want to leave a rouge process running which can only be killed with Task Manager or something since it has no "window".
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: RainInput - Get text input in Rainmeter for programs

Post by jsmorley »

Bwahahaha!

Image

Now I have to figure out how to do "Z" positioning so if a user misses the input box and clicks on the skin the input box doesn't go behind the skin, while at the same time not having it pop in front of some other actual window...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: RainInput - Get text input in Rainmeter for programs

Post by jsmorley »

Ok. I have a version done that I think will fit the bill. This is a more complicated doodad, so it will take some testing to find any kinks.

First, the program:

http://www.redirectwebhosting2.com/ghall/share/RainInput.zip

What it does is put a free floating input text box on the screen of any size and at any position. It accepts text input, and then passes this input on to any external program you define, along with additional static parameters if desired. Hitting ENTER on the text input box fires it off to the external program, ESCAPE exits without doing anything.

It is controlled by a RainInput.cfg file which MUST reside in the same directory as RainInput.exe. However, the program and the .cfg file can be located anywhere you wish. You will tell your skin where it is on the !execute command line. That way it is easy to distribute with a skin as it can just live in the skin's folder.

in Rainmeter, you call RainInput with:

SomeAction= !execute ["C:\FullPath\RainInput.exe" SectionName]

Where "SomeAction" can be anything that allows you to run an external program like "LeftMouseDnAction", "MouseOverAction", "IfAboveAction" etc. and "SectionName" is the section in the RainInput.cfg file you wish to use for the parameters for the input box, the program to run and other goodies...

Best way to explain is to show the RainInput.cfg file:

Code: Select all

;====================================================================
;  RainInput 1.0.2
;  Copyright 2009 - Jeffrey Morley
;  Contact: http://rainmeter.net/forums
;  Free for non-commercial use
;
;  Create a text input field in Rainmeter, and pass
;  the entered value to an external program.
;
;  RainInput confgiguration file                                       
;                                                                       
;  All VALUES WITH SPACES IN THEM MUST BE ENCLOSED IN QUOTES
;
;  Possible entries are:                                               
;                                                                       
;  [SectionName]
;    This must be populated with the name you wish to pass to
;    RainInput so your skin will use the correct configuration
;    items.  In the skin you will use:
;
;    !execute ["C:\FullPath\RainInput.exe" SectionName]
;
;  Then for each [SectionName] you will have one or more of the
;  following entries:
;     
;  ProgramPath=                                                         
;    Full path and name of the program you are calling.  Enclose in     
;    quotes if there are spaces in the path or name.                   
;    [DEFAULT = NONE - Program will fail with an error]                 
;                                                                       
;  ProgramWorkingFolder=                                               
;    Path where you would like the program to be executed. Enclose in   
;    quotes if there are spaces in the path. Ending in "\" is optional.
;    Note - Not all programs obey this parameter.  You might be able to
;    use "PrefixText" to overcome this limitation if for instance having
;    a program load a file in its directory when run.
;    [DEFAULT = ".\" the current folder]                            
;                                                                       
;  ProgramRunState=
;    The "visibility" state you want to run the program in.  Choices are:
;    "NORMAL" - Program opens in normal mode
;    "MINIMIZED" - Program opens in "minimized" mode
;    "MAXIMIZED" - Program opens in "maximized" mode
;    "HIDDEN" - Program will be hidden.  Caution!  If the program doesn't
;               exit on it's own when finished, it will require Task
;               Manager to close it.  It will not be visible on the
;               desktop, Taskbar, or System Tray.  Use this with care...
;    [DEFAULT = "NORMAL"]                               
;
;  PrefixParms=                                                         
;    Extra parameters you want to pass to the program.  They will be   
;    passed BEFORE the text input you enter in RainInput. If you want
;    a space between the PrefixParms and your entered text (you probably
;    will) put the space at the end of the entry, with the entire
;    entry enclosed in quotes.
;    [DEFAULT = "" Addtional parameters not required]                   
;
;  PostfixParms=                                                         
;    Extra parameters you want to pass to the program.  They will be   
;    passed AFTER the text input you enter in RainInput.  If you want
;    a space between your entered text and the PostfixParms (you probably
;    will) put the space at the beginning of the entry, with the entire
;    entry enclosed in quotes.
;    [DEFAULT = "" Addtional parameters not required]                       
;
;  PrefixText=                                                         
;    Extra Text you want to put at the BEGINNING of the text input you
;    enter in RainInput. For instance, can be a path name, so you
;    don't have to type it every time. This will be added to the
;    beginning string you input.  If your input string or this entry have
;    spaces in them, the entire new string will be enclosed in 
;    quotes before being sent.
;    [DEFAULT = "" Addtional parameters not required]                   
;
;  PostfixText=                                                         
;    Extra Text you want to put at the END of the text input you
;    enter in RainInput. For instance, can be used to put ".mp3" on
;    the end of a song title.  If your input string or this entry have
;    spaces in them, the entire new string will be enclosed in 
;    quotes before being sent.
;    [DEFAULT = "" Addtional parameters not required]                       
;                                                                       
;  Width=                                                               
;    Width in pixels of the input box                                   
;    [DEFAULT = 200]                                                   
;                                                                       
;  Height=                                                             
;    Height in pixles of the input box                                 
;    [DEFAULT = 20]                                                     
;                                                                       
;  LeftPos=                                                             
;    Left position in pixels on your desktop for the input box         
;    [DEFAULT = 0, Left of desktop]                                     
;                                                                       
;  TopPos=                                                             
;    Top position in pixels on your desktop for the input box           
;    [DEFAULT = 0, Top of desktop]                                     
;                                                                       
;  TextLimit=                                                           
;    Limit the amount of text allowed in the input box.                 
;    [DEFAULT = 999]                                                   
;                                                                       
;  FontFace=                                                           
;    Font you wish for the input box text.                             
;    [DEFAULT = "MS Sans Serif"]                                       
;                                                                       
;  FontSize=                                                           
;    Font size you wish for the input box text.                         
;    [DEFAULT = 11]                                                     
;                                                                       
;  FontColor=                                                           
;    Font color you wish in "RED,GREEN,BLUE" format.                   
;    [DEFAULT = "255,255,255" (White)]                                 
;                                                                       
;  BackgroundColor=                                                     
;    Background color you wish in "RED,GREEN,BLUE" format.             
;    [DEFAULT = "0,0,0" (Black)]
;
;  Debug=                                                     
;    Set this to 1 to output the command line to a text file:
;    RainInput.log instead of calling the external program.
;    [DEFAULT = 0]
;
;  All VALUES WITH SPACES IN THEM MUST BE ENCLOSED IN QUOTES
;
;====================================================================
[RainThemes]
ProgramPath="C:\Program Files\Rainmeter\RainThemes.exe"
ProgramWorkingFolder="C:\Program Files\Rainmeter"
PrefixParms="/load "
PostfixParms=""
Width=306
Height=20
LeftPos=100
TopPos=150
TextLimit=140
FontFace="Tahoma"
FontSize=11
FontColor="241,179,109"
BackgroundColor="108,61,11"
Debug=0
[Winamp]
ProgramPath="C:\Program Files\Winamp\winamp.exe"
ProgramWorkingFolder=""
PrefixParms=""
PostfixParms=""
PrefixText="C:\Users\Jeffrey Morley\Music\"
PostfixText=".mp3"
Width=306
Height=20
LeftPos=100
TopPos=150
TextLimit=140
FontFace="Tahoma"
FontSize=11
FontColor="241,179,109"
BackgroundColor="108,61,11"
Debug=0
If you want to test this just find a program which will accept command line parameters and do something useful, or at least noticeable. I have included a [RainThemes] section in the .cfg to demonstrate how to test with RainThemes, and a [Winamp] section to show how it could be used to play any song on your hard drive with Winamp. It can be tested without building a skin of course, by creating a Windows shortcut to the program and adding the "SectionName" parameter to the shortcut.

I have not yet looked for a Twitter client which works from the command line to send "tweets", but I suspect there is one out there.

I will work on a sample skin which uses this program in order to better demonstrate how to use it, and will post it as soon as I have something knocked together.
nvme
Developer
Posts: 73
Joined: June 18th, 2009, 1:40 am

Re: RainInput - Get text input in Rainmeter for programs

Post by nvme »

Hmm, so is there any way to implement this directly in Rainmeter without the use of an external program. It would be cool to have a 'Text Box' meter, which works the same way as your RainInput tool.
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: RainInput - Get text input in Rainmeter for programs

Post by dragonmage »

That would be very cool! I'm not sure if anyone is currently looking into adding this feature, but if you have any ideas on how to do it nvme I'm sure they would be welcome.
MattKing
Developer
Posts: 98
Joined: August 6th, 2009, 3:03 pm

Re: RainInput - Get text input in Rainmeter for programs

Post by MattKing »

I think that the easiest way to do it would be to actually just use the regular edit control instead of inventing our own. Here is some example code to do that.

Code: Select all

	CreateWindowW( "edit", NULL,
	WS_VISIBLE|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
	0,0, // Position of the window
	m_InputWidth, m_InputHeight, // height weidhth
	m_MeterWindow->GetWindow(),// The reference to the window, so the edit controlls parent
	(HMENU)m_EditID, // this is an id of the edit control
	hInstance,
	NULL);


You'd have to override the WM_ERASEBKGND message to the edit control window so you could have a transparent background to it.

MSDN Edit control refrece


Theres a chance I may look into this because I want a better Notes config.
nvme
Developer
Posts: 73
Joined: June 18th, 2009, 1:40 am

Re: RainInput - Get text input in Rainmeter for programs

Post by nvme »

I'm not much of a graphics guy, so i'll leave this to Matt, unless I feel especially bored :)