IUIAutomationValuePattern SetValue has no effect - microsoft-ui-automation

I am using MS UIAutomation in C++ to control a third party WPF application. I can read the value of an edit control (IUIAutomationElement objects). When I try to set the value with SetValue (IUIAutomationValuePattern objects) it does not return an error, but does not set the value of the edit control.
The manifest contains , the application is signed and is run from C:\Program Files.

I experienced that some UI Elements do not implement the UI Automation Provider correctly, as a result some patterns do simply not work as expected or even fail (although they are shown available).
To verify that the object is corrupt and not your code you could use the ValuePattern via Inspect.exe. Open Inspect -> select the control -> Action (Toolbar) -> ValuePattern.setValue
As a workaround I would suggest you to use SendKeys. If you need to focus the element first, yourAutomationElement.setFocus() is your friend. If setFocus does not work get the ClickablePoint/BoundingRectangle of the AutomationElement and use user32.dll in order to click the object.

Related

How do I programmatically set the length of Most Recent Used files in Eclipse

In Eclipse, I'm aware of the Preference setting for the number of recently opened files to offer:
For users of my RCP application I'd like to change the default length from 4 to 10.
I'm aware of the PreferenceManager, and can navigate to the correct node using this:
IPreferenceNode editorPrefs = preferenceManager.find
("/org.eclipse.ui.preferencePages.Workbench/org.eclipse.ui.preferencePages.Editors");
But, once I've found the node, I can't see how to access the specific property, in order to modify a value.
Anyone one done this before? Any tips?
Alternatively, I'm happy to do it via extension-point, but I couldn't get even this far via that mechanism.
This preference is set in the preferences for the org.eclipse.ui.workbench plugin. You can access this using ScopedPreferenceStore
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.workbench");
The key for recent files is RECENT_FILES so:
store.setValue("RECENT_FILES", value);
You may need to call the save() method to store the changes.
Note: it should also be possible [1] to update the preference from the .ini file. But it didn't work for me.
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=128411#c2

get the current view which is displayed to user and verify

I am testing my eclipse rcp app GUI using a tool called RCPTT.
In rcptt, i want to check that a specific editor is opened or not.
right now i am using
get-view "Console" | get-table | is-disabled | verify-false
but this is wrong way to do verification.
using this code, if the console is not opened, than it click on console and do verification.
It passed all time.
So, is there any way to
- first get the current view(which view is displaying currently to user.)
- then verify this view.
Thanks
You can not solve it within ECL, there's no support for this.
However you can solve it with Java code. It's not easy, could be a few hours of work.
1) Write a Java method that detects the name of the active View and returns it as a String
2) Make sure it's part of your application as a static class's static method
3) Invoke it from your ECL script with the invoke-static command
4) Compare the returned value in ECL script to what you've expected
Check methods parseComposites(), viewOrEditorIsFocused() and checkNextComposite() from this tutorial:
https://openchrom.wordpress.com/2011/08/12/capture-a-snapshot-of-the-active-vieweditor-in-a-rcp-application/
You do not need all the code from it and you need some editing too.
If you make an error/typo at points 2) or 3), then RCPTT-runner will simply throw an Exception without further explanation; be careful there.

In a VS Code extension, how can I be notified when the user cuts/copies/or pastes?

For my extension I need to know when a cut/copy/paste happens and be able to get the text associated with those operations. I can probably get the text from the editor if I know when they happen.
I cannot find a listener for these operations. I suppose I can look for ctrl-x, ctrl-c, and ctrl-v keyboard inputs but some users may use the edit menu and not use the keyboard.
Is there a way to be notified when these operations happen either from the keyboard or the edit menu?
Original asker here...
I came up with a solution that involves overriding the default cut/copy/paste actions in the editor. Here is the code for 'copy' in extension.js (I am using js not ts):
//override the editor.action.clipboardCopyAction with our own
var clipboardCopyDisposable = vscode.commands.registerTextEditorCommand('editor.action.clipboardCopyAction', overriddenClipboardCopyAction);
context.subscriptions.push(clipboardCopyDisposable);
/*
* Function that overrides the default copy behavior. We get the selection and use it, dispose of this registered
* command (returning to the default editor.action.clipboardCopyAction), invoke the default one, and then re-register it after the default completes
*/
function overriddenClipboardCopyAction(textEditor, edit, params) {
//debug
console.log("---COPY TEST---");
//use the selected text that is being copied here
getCurrentSelectionEvents(); //not shown for brevity
//dispose of the overridden editor.action.clipboardCopyAction- back to default copy behavior
clipboardCopyDisposable.dispose();
//execute the default editor.action.clipboardCopyAction to copy
vscode.commands.executeCommand("editor.action.clipboardCopyAction").then(function(){
console.log("After Copy");
//add the overridden editor.action.clipboardCopyAction back
clipboardCopyDisposable = vscode.commands.registerTextEditorCommand('editor.action.clipboardCopyAction', overriddenClipboardCopyAction);
context.subscriptions.push(clipboardCopyDisposable);
});
}
This definitely doesn't feel like the best solution... however it does seem to work. Any comments/suggestions? Are there any issues that repeatedly registering and unregistering will cause?
There is no api to access the clipboard directly but some extensions override the default copy and paste shortcuts to customize the copy paste behavior. Here are two examples:
https://github.com/aefernandes/vscode-clipboard-history-extension/blob/master/src/clipboard.ts
https://github.com/stef-levesque/vscode-multiclip/blob/master/src/extension.ts
As you note, that approach will not work when copying using the context menu however. For supporting that as well, you could try intercepting the editor.action.clipboardCopyAction command. See how the Vim extension intercepts the type command for an example of this: https://github.com/VSCodeVim/Vim/blob/aa8d9549ac0d31b393a9346788f9a9a93187c222/extension.ts#L208
There is a proposed api in v1.68 for intercepting and modifying pastes. Since it is proposed for now you can only test it in the Insiders Build.
See copy/paste proposed extension api:
The new documentPaste API proposal lets extensions hook into copy
and paste inside text editors. This can be used to modify the text
that is inserted on paste. Your extension can also store metadata when
text copy and use this metadata when pasting (for example for bringing
along imports when pasting between two code files).
The document paste extension
sample
shows this API in action: <-long code example in the release notes->
Here is the actual (brief) api: proposed documentPaste api
See also using a proposed api

How can I create a Hierarchical block with GNURadio Companion?

I am trying to create a Hierarchical block using the GNURadio Companion GUI. Answers I've found in other posts say to select the blocks you want to incorporate, then go to More -> Create Hier. Then a new screen is supposed to appear. However, doing "Create Hier" with any combinations of blocks selected seems to do nothing.
Am I doing something wrong, or is there a problem with my GRC?
It's very simple. You just start with a new flow graph in GRC, and use Pad Sources as input, and Pad Sinks as output.
If you want to let the user configure something, use a Parameter GRC block.
You must set the Generate Options in the Options block to Hier Block, and set a sensible ID there, too – don't stick with top_block, but use something (without spaces or -; it needs to work as a python name) that won't conflict with something else.
Here's an example:
You can then Generate button (or press [F5]), and then, after you've done a rescan of your block library with the refresh button you can find (and use) your new block in the Block Category you specified.

Is there a way to execute MATLAB Figure window menu items via command?

I found a neat bit of code for setting drawing tools via callback:
draw.m .
Edit
My apologies - I didn't realize that the Name property was a red herring - it is the annotation call that enables drawing the various figures.
So my corrected question is: is there a way to execute other menu item commands, such as set(gcf,'Some_property','Rotate 3D') ?
The easiest way to execute a menu item's command is to get a handle to the menu item and then inspect the Callback property to see what it calls internally.
rotate_menu = findall(gcf, 'type', 'uimenu', 'tag', 'figMenuRotate3D');
rotate_menu.Callback
% 'toolsmenufcn Rotate'
As you can see this uses an internal function toolsmenufcn which we could call directly to activate the tool.
toolsmenufcn(gcf, 'Rotate')
If you actually look at the contents of toolsmenufcn.m (edit toolsmenufcn), you will see a list of all available commands.
Using the toolsmenufcn directly is of course undocumented so use at your own risk. On the other hand, dynamically retrieving and executing the Callback for the menu should work across versions.