Is there a way to prompt a user for input (several arguments) and pass the input to a command prompt using HTA/VBScript? The command may take anywhere between 1-2 minutes to run before the next command is executed. This command returns "results" which I would like to display at the bottom of a window in a frame. This could be tricky since I don't know if there is a return code to check for.
For example: The quick brown input1 jumped over the lazy input2
The user would have to input in the textbox "fox dog" delimited by either a space or a comma. If the command executes successfully, it will say "the fox was able to jump over the dog" - if the command fails, it will say "the fox fell short".
Several different commands would have to be executed one after another as long as the previous command completes successfully.
I'm going to answer this as you're not sure where to start and you're thinking about programming an HTA like it is Basic - prompt user -> print answer - when it is actually more like visual basic where you have a form with input boxes and buttons and code that interacts with that form.
The "form" in an HTA is created using HTML (so you need to know some HTML) and the code that interacts with the HTML objects is either Javascript or VBscript*.
I beleive that HTAs offer a great way experiment with programming without having to install servers or import code libraries etc. You can just open Notepad** and start writing code.
You can copy the code below that does roughly what you describe in your question and use it as a starting point to experiment more.
<html>
<style>
#output {font-size:2em;}
</style>
<script language="vbscript">
sub updateText_OnClick
output.innerHTML = "The quick brown " & input1.value & " jumped over the lazy " & input2.value
end sub
</script>
<body>
Brown: <input type="text" name="input1"/>
Lazy: <input type="text" name="input2"/>
<input type="button" name="updateText" value="update"/>
<br/><br/>
<div id="output">The quick brown ? jumped over the lazy ?</div>
</body>
</html>
** You can use something like Notepad++ or another code editing program that will highlight your code and make it easier to spot if you have forgotten to close your quotes "" or misspelled a word.
*VBscript no longer works if you use the meta tag for IE 11 and above.
More example scripts https://gallery.technet.microsoft.com/ScriptCenter/site/search/?f%5B0%5D.Type=SearchText&f%5B0%5D.Value=HTA&x=0&y=0
I recommend the HTA helpomatic as it has useful code snippets.
Related
I would like to put a link inside an aria-live region when an event happens.
However when voiceover reads the aria-live region it does it as text and does not read that there is a clickable link.
so my markup when the event happens is
<div role="region" aria-live="assertive">
hello world
</div>
Voiceover reads hello world when the event happens and then puts the context back on the element it was on prior to the event being raised.
Is there a way to make voiceover read the content in aria-live as more than just straight text?
No, that's the purpose of aria-live - it announces the text that changed. No other info, such as the role (link or button or list) is announced.
You can "force" additional text to be read but you have to do it manually. So you could add something like this:
<div role="region" aria-live="assertive">
hello world <span class="sr-only"> link </span>
</div>
so you would hear "hello world link", but I would remove that extra text after it's announced otherwise when the user navigates all the elements manually (by using swipe right with voiceover), they'll hear:
"hello"
"world link"
"link"
(See What is sr-only in Bootstrap 3? for info on the "sr-only" class).
But that's not really a good workaround. Hearing "hello world link" when your new element is added makes it sound like "hello world" is the link when only "world" is the link.
There's probably a better solution for what you're trying to achieve if you explain the UX a bit more.
Using Spring / Thymeleaf i18n, I'd like to create a HTML paragraph message like "Click here", in which there is a link only for the word "here". What is the best way to do this?
The way I tried doesn't look nice and also results in a like break:
In messages.properties file:
error.generic.click=Click
error.generic.here=here
And in the HTML file:
<p th:text="#{error.generic.click}"></p><p><a th:text="#{error.generic.here}" th:href="#{/contact}"></a></p>
Answer
Your way seems okay to me. If you just want to fix the newline issue go ahead with the following one:
<p>
<span th:text="#{error.generic.click}"></span>
<a th:text="#{error.generic.here}" th:href="#{/contact}"></a>
</p>
The span will make "Click" stay on the same line as "here". However i'd just go for a link that say "Click here" instead of just "here".
For example in german you could say "Hier klicken". "Hier" would mean "here" and "klicken" would mean "click". The Problem is that the meaning for the words changed but the position didn't. You would end up with a link saying "klicken" instead of "Hier".
Not recommented
There is another approach, but it has some drawbacks. You could use:
<p th:utext="#{error.generic}"></p>
with the following messages.properties:
error.generic=Click here
The drawback on this one is that you can't use th:href anymore. I would not recomment this way. However this can be helpfull when using no th:* and just plain html tags. So i wanted to mention it.
I want to put my subroutines in an external file. When I press the help button it pops up errors. Even at startup it shows errors. If I put the contents of scripts.vbs within the HTA they work fine.
Here is the code:
Contents of scripts.vbs file:
Sub Window_Onload
Msgbox "welcome"
end sub
Sub Help
MsgBox "This is an example of progressbar in HTA written by Fredledingue.",,MyTitle
End Sub
Contents of HTA file:
<script type="text/vbscript" src="scripts.vbs">
</script>
<body bgcolor="GreenYellow">
<input id="BtnHelp" type="button" value="Help" onclick="Help">
Importing the script file like that should work, as long as the HTA and VBScript files are located in the same folder. You need to make sure that the <script> tag is closed though:
<script type="text/vbscript" src="scripts.vbs"></script>
If you still get errors you need to show them (full error message, including error number and the line raising the error).
With that said, I'd recommend against externalizing code from HTAs, because it reduces mobility. A self-contained HTA can easily be copied to wherever you like. The need to keep several files together has a negative impact on that.
I'm trying to allow custom "template code" within the source code editor. My code snippets would always look like {* anything here *}. It mostly works, but if used inside an HTML tag things gets scrambled.
I'm already using allowedContent: true, when starting CKEDITOR.
Example:
<p style="{* some "short code" of mine... *}">Text</p>
turns into
<p style="{* some " short="" code"="" of="" mine...="" *}"="">Text</p>
And
<p {* tet_pos_is_inside *}>Fuss</p>
into
<p {*="" tet_pos_is_inside="" *}="">Fuss</p>
Any advise ?
Thanks,
Sebastian
My advise would be to never use them inside tags, it sounds like a nightmare to configure. What is the requirement you are trying to fill with those?
You could go around this issue with pre- and post processing using classes, data attributes and/or custom attributes. For example you could use something like his:
<p class="tet_pos_is_inside_val-12345 foo-val-12345">I love horses</p>
<p data-tet_pos_is_inside="12345" data-foo="">I love bunnies</p>
<p tet_pos_is_inside="12345" foo="">I love cats</p>
Well,
apparently there was a simple solution to solve my current problem:
<p style="{* some 'short code' of mine... *}">Text</p>
works ! Note the use of singe-quotes inside the double quotes.
IOW, as long as there is a <tag attr="val"> then val can be anything except containing more double quotes.
Thanks for the comments.
How to automate Uploading a file using selenium.
How to give file Path ??
My TextBox is Readonly. I cant type the file path directly in the textbox.
Also, how to stop the selinum server until that file completely uploaded.??
My File upload field is a invisible field. And i found its code using firebug add on.
Before adding a file code is like this.
<input id="ctl00_ContentPlaceHolder1_AsyncfileUpload_ClientState" type="hidden" name="ctl00_ContentPlaceHolder1_AsyncfileUpload_ClientState" autocomplete="off" value="{'isEnabled':'true','uploadedFiles':[]}">
And after adding a file(doc file). The code changed to
<input id="ctl00_ContentPlaceHolder1_AsyncfileUpload_ClientState" type="hidden" name="ctl00_ContentPlaceHolder1_AsyncfileUpload_ClientState" autocomplete="off" value="{'isEnabled':'true','uploadedFiles':[{"fileInfo":{"FileName":"scope.docx","ContentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","ContentLength":12887},"metaData":"/wEFsAF7IlRlbXBGaWxlTmFtZSI6ImZyeWd1NGNqLmt1YSIsIkFzeW5jVXBsb2FkVHlwZU5hbWUiOiJUZWxlcmlrLldlYi5VSS5VcGxvYWRlZEZpbGVJbmZvLCBUZWxlcmlrLldlYi5VSSwgVmVyc2lvbj0yMDExLjEuNTE5LjM1LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDQiffOraDjiYXPavAAMYOUAVVhGEKk8"}]}">
What is the Xpath here?
I tried with xpath id="ctl00_ContentPlaceHolder1_AsyncfileUpload_ClientState". The code which i used is
selenium.type("id="ctl00_ContentPlaceHolder1_AsyncfileUpload_ClientState","c:\\docfile1.doc");
But its not working.
Help Me..
The XPath expression for this input would be //input[#id='ctl00_ContentPlaceHolder1_AsyncfileUpload_ClientState'].
However, I fear this won't work since Selenium usually refuses to work with invisible elements. Also, hidden <inputs> are usually just containers for pre-filled data or containers for script-validated-and-edited data.
You should be looking for a <input type='file' /> if there's some, or maybe a javascript handling the click on the enclosing element (but, frankly, that's usually not the case - the scripts tend to act on edit of the input, not on the click on them).
If you can't find it, post some more code. The best thing would be a SSCCE, so take the source of the page and make it naked, strip everything unnecessary for us from it. We love code. And we love anything that's naked.
And about the wait for the upload to be complete: There's no such default thing. If the file is sent during a usual form upload (by clicking the Submit button), then the browser will wait. If it is uploaded immediately, you'll have to wait smartly. Realize what changes after a successful upload, then wait for that element/message to appear. With Selenium 2 (WebDriver), this can be done very easily.
You can use
selenium.type("xpath of text box","path of your file")
OR for IDE
command=type
target=xpath_of_text_box
value=Path_of_your_file
example:
selenium.type("id=cvfile", "D:\\Automation\\resume.doc");