ControlCommand in AutoIt v3 - autoit

I am trying to use ControlCommands with a .NET application (hence, these should all be standard Microsoft controls), but most of the ones that are of interest don't seem to do anything.
I am currently looking at a combobox (the drop down box). I used the "showdropdown" command to have it drop down, and it worked successfully.
I then tried to use "SelectString", but it didn't go to the string that I specified. How does the "SelectString" ControlCommand option work?
I have also tried "SetCurrentSelection".
This is the statement I used:
ControlCommand($windowName, "", "[Name:myComboBox]", "SelectString", "a")
I have also tried searching for it first with:
ControlCommand($windowName, "", "[Name:myComboBox]", "FindString", "a")
but it didn't find it either. Strange, the single character "a" is there.
If it helps, this is the control class: WindowsForms10.COMBOBOX

_GUICtrlComboBox_xxx functions also work on external controls. For example, _GUICtrlComboBox_FindString, _GUICtrlComboBox_SelectString, _GUICtrlComboBox_SetCurSel. Try those instead.
Call ControlGetHandle first, then use this handle to call the functions above.
Remember to include the GuiComboBox library, otherwise you will get an error message "Error: Unknown function name":
#include <GuiComboBox.au3>

You can send key presses to this control, like this:
ControlSend("Window title", "", "[NAME:comboBoxName]", "ComboBox value")
It works because ComboBox interprets input as a search string and selects the first item starting with this string.
Note: Because it searches the matching item as you type, there's no need to send a complete value, only the shortest substring.

Related

how to get list of Auto-IVC component output names

I'm switching over to using the Auto-IVC component as opposed to the IndepVar component. I'd like to be able to get a list of the promoted output names of the Auto-IVC component, so I can then use them to go and pull the appropriate value out of a configuration file and set the values that way. This will get rid of some boilerplate.
p.model._auto_ivc.list_outputs()
returns an empty list. It seems that p.model__dict__ has this information encoded in it, but I don't know exactly what is going on there so I am wondering if there is an easier way to do it.
To avoid confusion from future readers, I assume you meant that you wanted the promoted input names for the variables connected to the auto_ivc outputs.
We don't have a built-in function to do this, but you could do it with a bit of code like this:
seen = set()
for n in p.model._inputs:
src = p.model.get_source(n)
if src.startswith('_auto_ivc.') and src not in seen:
print(src, p.model._var_allprocs_abs2prom['input'][n])
seen.add(src)
assuming 'p' is the name of your Problem instance.
The code above just prints each auto_ivc output name followed by the promoted input it's connected to.
Here's an example of the output when run on one of our simple test cases:
_auto_ivc.v0 par.x

Is it possible to place code into the console in R?

Blasphemy I know to ask IF it is possible to do something in R, but here I am!
I am interested in the ability to create a function that will place code into the console. In other words, if the user types in f("3+3") and hits enter then the console will be waiting for the next command with > 3+3. Then when the user hits enter, it will return 6 in this case. Possible? Any ideas?
I wish I had more to share but I've never even thought this functionality would be useful before...
One way you could do this is to call system2() to invoke an external utility that synthesizes keyboard input. I've written a C++ program called sendkeys that can do this on Windows by (ultimately) calling SendInput(). Demo:
system2('sendkeys','3\\\\+3');
3+3
## [1] 6
(The backslash escaping is necessary because of the way my utility parses its input; + is a metachar that must be escaped to become literal.)
Let me know if you want my C++ code.
Would that be the kind of function you would need? Maybe it is not a very elegant solution, though.
printEval <- function(x){
cat(">", x,"\n")
cat ("Press [enter] to continue")
line <- readline()
eval(parse(text=x))
}
EDIT: Sorry, I just noticed that the eval(parse()) solution was already suggest by #Ping in the comment field right under the question.

Show the euro simbol in a shiny R application

I'm trying to create a shiny R application. I have some troubles to show euro symbol (and return it) in a radio button. I've tried different version of code:
library(shiny)
runApp(list(
ui= navbarPage(title = 'shoe euro',
radioButtons('var', 'var',
c("INCOME_MGL",
"INCOME_MGL€",
"INCOME_MGL€",
"INCOME_MGL€",
"INCOME_MGL\u20ac")
)),
server=function(input, output, session) {
}))
But the "€" doesn't appear in the web page. Moreover if I select the second option the page returns an error:
"Error in fromJSON(content, handler, default.size, depth, allowComments, :
invalid JSON input"
The problem lies in the class shiny-options-group in the div function. The way this class works appears to convert & to &, preventing the browser from converting € into € because it first changes it into &#8364;. Try the following as your ui.R to see it happen.
library(shiny)
options = as.list(c("a","b",HTML("€"),"€"))
shinyUI(fluidPage("test",fluidRow(div(class = "shiny-options-group", options))))
The reason this is happening in your radio button widget is that radioButtons calls generateOptions to create the list of options, and generateOptions returns div(class = "shiny-options-group", options), where options is derived from a manipulation of the choices parameter in the radioButtons function. Here is what you could do:
Get the code for generateOptions here (line 653).
Define the new function generateOptions2 using the exact same code as generateOptions, but change the class parameter at the end.
Get the code for radioButtons by running shiny::radioButtons
Define a new function radioButtons2 and in it replace the generateOptions with generateOptions2.
Set the environment for both new functions to shiny by running something like environment(radioButtons2) <- environment(radioButtons)
Use radioButtons2 in your code instead of radioButtons
The only thing I don't know is what to change the class parameter to in generateOptions2. I don't know much about div classes.
Update
I may have spoken too soon. It looks like the problem goes far deeper. The div function calls tags$div, which calls tag with the first argument set to "div". tag then calls the base function structure with the parameter class = "shiny.tag". structure then calls the primitive function attributes with the parameter class = "shiny.tag". attributes with this parameter then converts & in to &. Therefore, it looks like there is no way to use the div function and get back the euro symbol. I tried replacing div in generateOptions2 with HTML, but that returned a bunch of garbage when I ran the app. You'd have to change the behavior of class = "shiny.tag", but that could have far-reaching unpredictable effects.
Update 2
Figured it out! The trick is to use gsub to replace every & with just & before it is returned from generateOptions2. I put a functioning version of what you posted on github. It requires loading the two functions I mentioned earlier, which (in my repository) are stored in a file called functions.R. The important line in generateOptions2 is gsub(pattern = "&", replacement = "&", div(class = "shiny-options-group", options)).

What is CLASS:wxWindowNR in AutoIt, and how can I click the control?

I'm using AutoIt to try to automate the use of a program called PhotoZoom 4. I'm running into a problem where I need to type text into a box where this is the Class and instance:
[CLASS:wxWindowNR; INSTANCE:8]
I've tried the following with no luck (each line is a separate attempt):
ControlSetText($batchWindowTitle2, "", "[CLASS:wxWindowNR; INSTANCE:8]", '800')
ControlCommand($batchWindowTitle2, "", "[CLASS:wxWindowNR; INSTANCE:8]", "AddString", '800')
ControlClick($batchWindowTitle2, "", "[CLASS:wxWindowNR; INSTANCE:8]", "left", 1, 32, 12)
Send("800")
I expected either ControlCommand or ControlSetText to work at least, but they didn't.
I googled this problem as well, but I literally couldn't find any references of "wxWindowNR" anywhere on the web. I'll attach a photo of the control.
If you don't know what wxWindowNR is either (I expect you might not since I have not seen it anywhere else on the web), what's the best way to automate clicking and typing in the box? I thought ControlClick would do it...
"Tab-cycle" (for example, send("{Tab 5}")) through all your controls until you get there in your GUI and then use a simple send().

Programmatically adding new line in mx:TextArea

I have a flex 4.5 application. I want to add new line in an mx:TextArea when certain event occurs. I have been searching for the proper way to add a OS independent line ending. I found out that the File class has lineEnding property. However the documentation states that this class is not exposed when running inside a browser (which is my case).
I have searched, but I couldn't find any other class, which can provide this information. Actually I am not sure if the TextArea line ending is OS dependent or not.
So actually I have two questions: Are TextArea line endings OS dependent or not? And if so, how can I get the proper line ending in flex?
You can use String.fromCharCode(13). This will return a line ending.
This is the equivalent of PHP's chr() method.
Example:
var address_str:String = "dog" + String.fromCharCode(64) + "house.net";
trace(address_str); // output: dog#house.net
From my experience, "\r" works in both Windows and Mac.
Quite simply, you just need to add the newline character to the text of the textArea.
myTextArea.text+="\n"; //This should work, if not try the other two
myTextArea.text+="\r";
myTextArea.text+="\r\n";

Resources