Jump to content
Macro Express Forums

Prompt for Value


Recommended Posts

Hi all, 

 

I've been using Prompt for Value to setup variables for years now and it was only a single line item. Ie: I type a value and press enter, it'll be the same as clicking 'Ok' button.  After updating to MEP V.6.4.0.1, it appears the Prompt for Value accepts multi-line items.  Ie: I type a value and press enter, it'll go to the next line rather than enter / 'OK' Button.  Now I have to tab and then enter after typing in the value.  

 

This is a welcome change but at the same time, is there a way to revert via a setting/configuration?  

 

Thank you in advance.

  • Like 1
Link to comment
Share on other sites

I don't think there's a built-in way to revert to the older way.

 

However, here's a kludge. Create a second macro with activation of window title gaining focus. The window title you're looking for is "Enter String Value" (exact match).

 

Here's the script for the second macro. It's active while the "Enter String Value" window is open. The second macro waits for you to press "Enter". Then it sends Tab Enter.

 

 

Wait for Key Press: ENTER
Text Type (Simulate Keystrokes): <TAB><ENTER>

 

Link to comment
Share on other sites

9 hours ago, acantor said:

I don't think there's a built-in way to revert to the older way.

 

However, here's a kludge. Create a second macro with activation of window title gaining focus. The window title you're looking for is "Enter String Value" (exact match).

 

Here's the script for the second macro. It's active while the "Enter String Value" window is open. The second macro waits for you to press "Enter". Then it sends Tab Enter.

 

 

Wait for Key Press: ENTER
Text Type (Simulate Keystrokes): <TAB><ENTER>

 

Hey Acantor,

 

Thanks for the work-around, though I am running into a problem with it that doesn't seem to make sense.

 

I've built the 2nd macro and it runs fine when the Enter String Value prompt pops up. I enter my prompted value and press enter, the prompt goes away, but the first macro just sits there until I press Enter again.  It's like the 2nd macro is running twice. 

 

What's worse is that it ends up adding a bunch of carriage returns into the text editor (notepad++, if that matters) when it pastes the info over.

 

Here's my code so you (or anybody else) can tell me what I'm doing wrong.

 

Primary Macro

<VARIABLE SET STRING Option="\x01" Destination="%T[1]%" Prompt="What is the customer's name?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<MACRO RUN Use_ID="FALSE" Name="Enter String Value feature fix" ID="-1" Wait="TRUE"/>
<VARIABLE SET STRING Option="\x01" Destination="%T[2]%" Prompt="What is the Service Request Number?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<MACRO RUN Use_ID="FALSE" Name="Enter String Value feature fix" ID="-1" Wait="TRUE"/>
<TEXT TYPE Action="1" Text="Hello %T[1]%, \r\n\r\nI just wanted to follow up with you on service request: %T[2]%. I haven’t heard from you since my last correspondence and I wanted to see if you wish to continue working on this issue. Please contact me at your soonest convenience by replying to this email. I look forward to working with you towards a resolution on this service request. \r\n\r\nThanks,"/>


Secondary "fix" Macro

<WAIT FOR KEY PRESS Key="ENTER" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<TEXT TYPE Action="0" Text="<TAB><ENTER>"/>

 

This new bug feature is going to mess with my work-flow (I use a lot of templates that prompt for values). It will probably be faster and easier for me to just learn to Tab-Enter (or Tab-Space, more likely) by default rather than track down every macro I have that uses a variable prompt and add in this extra Macro Run command.

 

Hopefully Insight is paying attention and pushes an update that either reverts this or makes the 'multiple lines' feature optional. I'd be okay with a "ctrl+enter = OK" solution like so many other applications support.

 

Thanks for anything you might be able to add to this.

 

Steve

Link to comment
Share on other sites

39 minutes ago, stevecasper said:

It will probably be faster and easier for me to just learn to Tab-Enter (or Tab-Space, more likely) by default

 

Hi Steve,

 

Consider my workaround, and variations of it, as a last-ditch effort. It can fail in many ways, as you have already noted. Re-learning to press a two-key sequence is probably the most elegant solution.

 

But don't overlook the possibility of filing a feature request with ISS. I have found them very responsive to input from Macro Express users.

Link to comment
Share on other sites

I have a macro similar to what acantor suggested.  Try changing it as shown below.

 

Wait for Key Press: ENTER
Text Type (Simulate Keystrokes): <TAB>
Delay: 250 milliseconds // delay so ENTER will not happen until tab selection happens
Text Type (Simulate Keystrokes): <ENTER>

 

No guarantees -- but the delay fixed my problem with a multiple-choice menu.  Since this short macro is interacting (indirectly, via the "keyboard") with the PROMPT macro, the TAB and ENTER keystrokes may need to be separated slightly in time, so the PROMPT macro has time to respond. 

Link to comment
Share on other sites

1 hour ago, stevecasper said:

rather than track down every macro I have that uses a variable prompt and add in this extra Macro Run command.

Hmmm...  That is the problem.  You do NOT NOT NOT want a Macro Run command to execute acantor's macro or my variation on his macro.   Re-read acantor's suggestion.  The "fix" macro is triggered automatically by the appearance of the PROMPT window, named "Enter String Value" (exact match).  You specify that in the Activations tab of the script editor. 

  • Thanks 1
Link to comment
Share on other sites

56 minutes ago, rberq said:

Hmmm...  That is the problem.  You do NOT NOT NOT want a Macro Run command to execute acantor's macro or my variation on his macro.   Re-read acantor's suggestion.  The "fix" macro is triggered automatically by the appearance of the PROMPT window, named "Enter String Value" (exact match).  You specify that in the Activations tab of the script editor. 

OooooOOOooOOoo

 

That was my problem. I was running the 'fix' from the primary, but it was also being activated 'naturally' by the prompt window itself. 

 

I pulled the Macro Run commands out of the primary, and that fixed Problem 1.

 

Problem 2 (extra carriage returns) I resolved by prepending a <BACKSPACE> to the <TAB><ENTER> (the troublesome carriage returns were being generated by me hitting Enter to allow the 'fix' to proceed.

 

Problem 3 (new problem introduced by the fix) was fixed by adding a delay between the first and 2nd prompts. 

 

Working Primary

<VARIABLE SET STRING Option="\x01" Destination="%T[1]%" Prompt="What is the customer's name?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<DELAY Flags="\x01" Time="0.25"/>
<VARIABLE SET STRING Option="\x01" Destination="%T[2]%" Prompt="What is the Service Request Number?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<TEXT TYPE Action="1" Text="Hello %T[1]%, \r\n\r\nI just wanted to follow up with you on service request: %T[2]%. I haven’t heard from you since my last correspondence and I wanted to see if you wish to continue working on this issue. Please contact me at your soonest convenience by replying to this email. I look forward to working with you towards a resolution on this service request. \r\n\r\nThanks,"/>

Updated 'fix'
<WAIT FOR KEY PRESS Key="ENTER" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<TEXT TYPE Action="0" Text="<BACKSPACE><TAB><ENTER>"/>

 

Link to comment
Share on other sites

1 hour ago, acantor said:

 

Hi Steve,

 

Consider my workaround, and variations of it, as a last-ditch effort. It can fail in many ways, as you have already noted. Re-learning to press a two-key sequence is probably the most elegant solution.

 

But don't overlook the possibility of filing a feature request with ISS. I have found them very responsive to input from Macro Express users.

 

To be honest, this gave me motivation to streamline my process anyway. I have a bunch of macros that act as Multiple Clipboards. Certain info is always hooked to specific clipboards. I have been meaning to start hanging customer names to one, but have been too lazy. I always have SR numbers on a hook, so this issue gave me a good reason to update some of my macros that relied unnecessarily on prompts. 

 

i.e. for this macro, I always ran the paste macro to enter the SR number into the prompt... so I was already wasting effort :) 

 

But I will take your suggestion to heart. I'll reach out to ISS through the feature request/bug report process and hope others do the same. I don't dislike the new function, but I can't imagine we're the only ones who have been impacted and had to make our processes more complicated to adjust to it.

 

Thank you for your fix!

Link to comment
Share on other sites

I thought of another workaround. It also involves two macros:

 

The main macro waits for you to input something, maybe something like this:

 

Variable Set String %x%: Prompt
Text Box Display: Value of x

 

Create a second macro with hotkey activation. Select "Enter" as the hotkey. Set its scope to "Enter String Value" (exact match).

 

When the "Enter String Value" window is open, pressing Enter triggers the second macro. The problem is that we don't know what is focused when we press Enter: the text field, the OK button, or the Cancel button.

 

This version seems to work reliably: if the OK button has focus, pressing Enter activates the OK button. If the Cancel button has focus, pressing Enter activates the Cancel button (which cancels the operation). Otherwise, the second macro assumes the text field has focus, and presses Tab Space.

 

Capture Control from Focused Control into %DialogBoxControl%
Get Control Text from %DialogBoxControl% into %Text%
 
If Variable %Text% Equals "OK"
  Text Type (Simulate Keystrokes): <SPACE>
  Macro Stop
End If
If Variable %Text% Equals "Cancel"
  Text Type (Simulate Keystrokes): <SPACE>
  Macro Stop
End If
Text Type (Simulate Keystrokes): <TAB><SPACE>

 

Link to comment
Share on other sites

1 hour ago, acantor said:

I thought of another workaround. It also involves two macros:

 

Clever, and it should run really fast.  I should keep looking for opportunities to use controls, so I can learn more about them.  I always forget to consider them when coding macros. 

 

Would it work, to change the last line of your macro (Text Type (Simulate Keystrokes): <TAB><SPACE>) to find and set focus to the OK button and click on the control?

(Yeah, I know, I should take this opportunity to learn by figuring it out for myself -- but lunch calls.😋)

Link to comment
Share on other sites

Lunch is important!

 

There are probably better ways to handle the situation via controls.

 

I just wanted to see if I could build a proof-of-concept.

 

My initial idea was to "repeat until" the control text or the control class matched a certain value. But I try to avoid repeats that might turn into infinite loops, unless I can incorporate a "failsafe."

There is a built-in failsafe. With only three controls on the screen, there should be no reason to check controls more than three times. But rather than repeat three times, I opted for two IF statements.

 

There might be an issue sending <TAB><SPACE> if the Cancel button happens to be focused. Focus will go to the text field, and the macro will add a space to whatever is in the field.

 

Rather than complicated workarounds, I would prefer an option in Macro Express to accept carriage returns in the field, or to cause Enter to activate the OK button.

 

On the other hand, I find these kinds of workarounds entertaining!

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 1 month later...

Hey all, wanted to provide an update from the Devs:

 

"We have made a change to the Variable Set String from Prompt command in Macro Express Pro. This change allows you to select "Single line" or "Multiple lines". When "Single line" is selected pressing the Enter key will accept the input and close the dialog.

 

 

 

This change will be available in the next released version of Macro Express Pro. "

 

👍 For devs!!!

 

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...