Input Command Caption Title

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
MacschedStudent
Junior Coder
Posts: 36
Joined: Fri Oct 12, 2007 5:55 pm
Location: federal way wa
Contact:

Input Command Caption Title

Post by MacschedStudent » Sat Jan 22, 2011 1:39 am

Hi Guys :

I'm using Msched 7.4. Is there a way to change the title of the Input window when your selecting files. I have a Browse button connected to a SRT with an Input command in it. But when I click on browse the title of the Window says " Macro Scheduler Input" any way to change that title in 7.4???

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Jan 22, 2011 7:45 am

No.

In later versions the caption can be changed but only for compiled macros.

In later versions you can also create your own custom dialogs - with full control over their appearance. So you could replicate the Input browse dialog and make it look however you wish it to look including the caption.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sat Jan 22, 2011 9:36 am

Hi MacschedStudent,

Do you have the compiler? If you do and you are willing to run your macro compiled, then just add the following line near the top of your script:

Code: Select all

Let>APP_TITLE=myApp
Then instead of "Macro Scheduler Input", the title will be "myApp Input".

Note that this isn't a "total" title changing solution because you can't get rid of the "Input" part with this method.

If you want a brute force method using a Win API call, here's a way:

Code: Select all

//make sure the window you want to change the title on has focus
SetFocus>Macro Scheduler Input

//You need to get the handle not the title (you already know the title)
//setting this will make GetActiveWindow> return the window handle
Let>WIN_USEHANDLE=1

GetActiveWindow>hwnd,X,Y,Width,Height
//now the variable hwnd contains the window handle

//setting this back to default is good practice
Let>WIN_USEHANDLE=0

Let>myTitle=Anything I Jolly Well Want It To Say

//Rename the window
LibFunc>User32,SetWindowTextA,r,hwnd,str:%myTitle%
While the above can work, I wouldn't recommend it in your case because:
  • for this code to work, the Input> window has to already exist because you can't grab it's handle unless it actually exists
  • but as soon as the Input> command is executed and the window pops up, the script stops while it waits for user input i.e. you can't execute the above code renaming the window...
  • unless you do it from a different script running simultaneously that is
  • you could write a second script that runs in a loop who's only function is to continually check for the existance of a window with title="Macro Scheduler Input" and as soon as it sees one, it changes its title
If all this sounds like a lot of trouble to go through just to change the title on an Input> dialog, I'd have to say I agree with you.

Instead you could create your own custom dialog which means:
  • open the dialog designer
  • adding a label to tell the the user what to enter
  • adding an Edit field to allow them to type in a value
  • adding at least an OK button
  • saving the dialog and inserting it into your script
  • and now you have to add code to deal with the dialog
  • a line to Show> the Dialog
  • code to process the dialog return code
  • if this is a v12 dialog, you need to add dialog event handlers
This is all great stuff, good to learn and you can do a lot with it... but again, in my opinion... even this is a lot of extra work... just to have an Input> dialog show the title I'd like it to show...

...and that's why, long ago, I felt that the Input> command could have been enhanced to add one more optional parameter so we could specify a title if desired, like this:
a long ago thought I probably never wrote:Input>variable,prompt[,default_value,title]

The optional "title" parameter can be a variable.
That would be about the most concise, low maintennance way to give us this ability... but if this never happens, I won't complain because yes I can use a custom dialog so its not like there isn't a way to set the title and get input.

Now here's something that Input> may not be able to do:
Help File wrote:If the Input dialog is cancelled (cancel is pressed) Input returns an empty string.
And what does it return if the user simply enters nothing and clicks OK?

It returns exactly the same thing... the variable will contain an empty string.

The problem is, I want to do two different things:
  1. If the User clicked the Cancel button, I want to end the macro immediately
  2. But if the user just entered nothing and clicked OK, I want to tell them that a value is required here and present the Input> dialog again...
Question for all: Using an Input> command, how can I tell if the user clicked the Cancel button... or if they entered nothing and clicked OK?

Question for Marcus: If there is no way, could this please be added to the wish list?

Thanks for listening and take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Jan 22, 2011 11:08 am

Another option:

VBSTART
VBEND

VBEval>InputBox("Please enter your name:","My Input Box",""),result

Documented here:
http://msdn.microsoft.com/en-us/library ... s.85).aspx

But note also that this returns an empty string if Cancel is pressed.

Normally it would be assumed that if OK was pressed and nothing entered that this can be interpreted the same as a cancel. Also if something MUST be entered then that would imply that you cannot cancel and therefore even if cancel was pressed you'd still want to say "sorry, you must enter something" and therefore for all logical purposes OK+"" is the same as cancel. A workaround if you do want them to be different is to set the default to " " and then check for that for if ok was pressed with nothing being entered by the user the default of " " would be returned whereas cancel would return "".[/url]
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sat Jan 22, 2011 10:58 pm

Hi Marcus,

Thanks for the quick reply.

I was going to use the workaround method you mentioned... but after some Googling, I found this: http://www.scriptinganswers.com/forum2/ ... p?TID=3602 and learned that with a VBScript InputBox, there actually is a way to differentiate between whether the user clicked Cancel or clicked OK. It has to do with the varType of the data returned by the InputBox... it will be one type if Cancel was clicked and another if OK was clicked.

So I wrote a VBScript Function that can be called with VBEval> that will let me use a VBScript InputBox.
  • If the user clicks Cancel, the script ends immediately
  • If the user blanks out the input text and clicks OK, it knows that OK has been clicked and can see the data and since it is length 0, it reminds the user they must enter something and asks again.
Here it is... hope others find it useful.

Code: Select all

VBSTART

Function MyInputBox (MyPrompt,MyTitle,MyDefault)

  return = InputBox(MyPrompt,MyTitle,MyDefault)
  If vbEmpty = VarType(return) Then cancel_clicked = 1
  If vbString = VarType(return) Then cancel_clicked = 0
  MyInputBox = cancel_clicked & return

End Function

VBEND

//inspired by:
//http://www.scriptinganswers.com/forum2/forum_posts.asp?TID=3602

Let>prompt=Enter User ID:
Let>title=System Logon
Let>default=jpuziano

//If any of the above MS vars could contain a double quote " then uncomment and use
//the next line to vbEscape them first, changing var name/s as appropriate
//StringReplace>my_text_variable,","",my_text_variable

Label>get_input_from_user
VBEval>MyInputBox("%prompt%","%title%","%default%"),result

MidStr>result,1,1,user_clicked_cancel_on_input_box

If>user_clicked_cancel_on_input_box=1,end

MidStr>result,2,1000,input_data
Length>input_data,input_data_length

If>input_data_length>0,user_provided_input

//If we make it to here, user did not cancel but also did not provide any input text
MDL>You must provide a User ID to Logon
Goto>get_input_from_user

Label>user_provided_input
MDL>Input Data: %input_data%%CRLF%%CRLF%Input Data Length: %input_data_length%

//more code here...

Label>end
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts