Open FindInFiles dialog from Visual Studio Extension - visual-studio-extensions

I am writing a Visual Studio extension, and I would like to open the FindInFiles dialog with “Current Document” set as scope.
In MS documentation, I ended up finding fields that sound promising:
VSConstants.StandardToolWindows.FindInFiles;
VSConstants.VSStd97CmdID.FindInFiles;
ToolWindowGuids80.FindInFiles…
But I couldn't find a way to actually use them to open the dialog.
I tried a few variations of this code (by changing the various constants):
var mcs = ServiceProvider.GetServiceAsync(typeof(IMenuCommandService)).Result as MenuCommandService;
var command = new CommandID(
VSConstants.StandardToolWindows.FindInFiles,
(int)VSConstants.VSStd97CmdID.FindInFiles);
mcs.GlobalInvoke(command, VSConstants.StandardToolWindows.FindInFiles);
But I did not manage to get the dialog to pop. Plus it sounded a lot like fiddling.
So how can I get my addin to open the SearchInFiles dialog? And more importantly, where did you find the answer 😉?

You can call the Edit.FindInFiles command to open the dialog:
dte.ExecuteCommand("Edit.FindInFiles");

Related

How do I get the BAM Add-Ons in BizTalk 2016/Excel 2016

I want to create a BAM activity/view. I have Office 32-bit. Do I need to open some specific BAM spreadsheet/model first?
This page shows how it works in Excel 2007: https://msdn.microsoft.com/en-us/library/aa559526(v=bts.20).aspx But I haven't found anything for more recent versions.
If I open a new empty spreadsheet, and click Add-Ins, I see nothing but the following:
If I right click "Add-Ins" and select "Customize Quick Access Toolbar", I then see this screen - which looks like probably what I need, but still don't know the exact procedure to add the BAM Adds here.
It might be wiser to find and edit the file outside of Excel first: The add-in file is: "c:\Program Files\Microsoft Office\Office16\Library\Bam.xla"
I clicked on "Business Activity Monitoring" - then what should I do next to get the menus needed to add the BAM Activity.
Looks like you click the "Go" button to the right of "Manage Excel Add-Ins".
Then the following box pops-up, and I can check "Business Activity Monitoring" and then "Ok".
If it doesn't appear there, you can click the "Browse" button, go to the ""c:\Program Files\Microsoft Office\Office16\Library" folder and select "Bam.xla".
If you are in Excel 64-bit, instead of 32-bit, you will get this error:
But so far, after doing that, I still don't see any new "BAM" menu in Excel.
I was seeing error:
Compile error: The code in this project must be updated for use on
64-bit systems. Please review and update Declare statements and then
mark them with the PtrSafe attribute.
If you get that, it means you are probably on 64-bit, not 32-bit version of Excel. I was told by another team they installed 32-bit, but low and behold, they did not. You can check the version using the following steps:
1) File (menu)
2) (click) Account
3) Click the square (almost doesn't look like a button that says "? About Excel"
After getting the 32-bit, it looks okay, the BAM menu appears as follows (under the "Add-Ins" tab:
If you click the "BAM Activity" and get the error "Variable not defined", then see this link: https://oussov.wordpress.com/2013/01/03/bam-xla-variable-not-defined-error-in-excel/

Aptana go to last open editor command

I'm using Aptana Studio 3 and am looking for a command that will take me to the previous editor I was in (a la Netbeans ctrl-tab or Eclipse's ctrl-F6). I've tried several commands with promising sounding names but none of them seem to behave properly. Any thoughts?
Go to Windows->Preferences->General->Keys and have a look at the key binding you have set for the commands 'Next Editor' and 'Previous Editor'. Type those commands in the filter search box to save yourself having to scroll.
On Windows the shortcuts for next and previous editor are in fact Ctrl+F6 and Ctrl+Shift+F6 respectively, which also happen to be the defaults in Eclipse. So if your key bindings for those commands are not set then you can set them here.

How to Right click of File in Windows Explorer by AutoIt

I wish to simulate a right click on a file. This is done by opening a Windows Explorer window and then right clicking on it.
The main issue is finding the location of the file in Windows Explorer. I am currently using Autoit v3.3.8.1.
My code 's first line:
RunWait (EXPLORER.EXE /n,/e,/select,<filepath>)
The next step is the problem. Finding the coordinates of the file.
After that, right clicking at that coordinates (it seems to me at this time) is not a problem....
Some background:
OS: Windows 7 64-bit
Software Languages: C#, Autoit (for scripting)
The Autoit script is called by a code similar to that below:
Process p = new Process();
p.StartInfo.FileName = "AutoItScript.exe";
p.StartInfo.UseShellExecute = false;
p.Start();
The code is compiled into a console class file which is run at startup. The autoit script runs as the explorer window opens up.
It seems as though you are taking the wrong approach to the problem, so I'll answer what you are asking and what you should be asking.
First up though, that line of code is not valid, and is not what you want either. You want to automate the explorer window, and RunWait waits for the program to finish. Furthermore you want those items to be strings, that code would never work.
Finding the item in explorer
The explorer window is just a listview, and so you can use normal listview messages to find the coordinates of an item. This is done most simply by AutoIt's GUIListView library:
#include<GUIListView.au3>
Local $filepath = "D:\test.txt"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Local $hList = ControlGetHandle("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32; INSTANCE:1]")
Local $aClient = WinGetPos($hList)
Local $aPos = _GUICtrlListView_GetItemPosition($hList, _GUICtrlListView_GetSelectedIndices($hList))
MouseClick("Right", $aClient[0] + $aPos[0] + 4, $aClient[1] + $aPos[1] + 4)
As has already been mentioned, sending the menu key is definitely a better way than having to move the mouse.
Executing a subitem directly
This is how it should be done. Ideally you should never need an explorer window open at all, and everything can be automated in the background. This should always be what you aim to achieve, as AutoIt is more than capable in most cases. It all depends on what item you want to click. If it is one of the first few items for opening the file in various programs, then it is as simple as either:
Using ShellExecute, setting the verb parameter to whatever it is you want to do.
Checking the registry to find the exact command line used by the program. For this you will need to look under HKCR\.ext where ext is the file extension, the default value will be the name of another key in HKCR which has the actions and icon associated with the filetype. This is pretty well documented online, so google it.
If the action is not one of the program actions (so is built into explorer) then it is a little more complex. Usually the best way will be to look at task manager when you start the program and see what it runs. Other things can be found online, for example (un)zipping. Actions like copy, delete, rename, create shortcut, send to... They can all be done directly from AutoIt with the various File* functions.
With more information, it would be possible to give you more specific help.
First, you might want to look at the Microsoft Active Accessibility SDK. In particular look at this interface...
http://msdn.microsoft.com/en-us/library/accessibility.iaccessible.aspx
You can use this to walk the items in the control and find the one with the file name you are looking for and its screen location.
From there, maybe try something like this for simulating the right click.
How can I use automation to right-click with a mouse in Windows 7?
Once you have done the right click, use accessibility again to find the right option on the context menu.
Maybe there's an easier way, you should be able to cobble something together like this if you don't find one. Good luck!
Suppose I have a file named test.txt on D drive. It needs to right click for opening Context Menu. To do this, the following code should work:
Local $filepath = "D:\test.txt"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Send('+{F10}')

Flex/AIR: call JSFL

I've written a JSFL file to publish some fla's, and now I'd like to call that script from a flex / AIR application.
So the user should browse to the JSFL-file and select it. After selecting the JSFL-file should run and do whatever is described in the JSFL. If I run the JSFL, no problems occur and everything goes fine. However, I can't seem to call the file from my flex/AIR application.
I've tried writing a flash AS3.0 file and call the JSFL from there but that doesn't work either.
The function I use is MMExecute but still nothing ... Searched for it quite some time now and I'd really like to do this. Anyway, here's some code...
//ABOVE IS THE SELECT EVENT
jsflpath = evt.target.nativePath;
MMExecute('fl.runScript("'+filePath+'" );');
George is exactly right. With AIR 2.0+, you could use NativeApplication to launch the script file directly in Flash.
More on NativeApplication here:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/NativeApplication.html
http://www.adobe.com/devnet/air/flex/quickstart/articles/interacting_with_native_process.html

Make visual studio autoformat my source code?

I've searched but does Visual Studio 2008 have a setting for C# where it will autoformat/beautify my code as I write it? There is a setting for VB.NET called "prettify". I've also searched the archives already and found a macro to execute this on save and I know I can drag and drop it onto the toolbar but I want it to work without my doing ANYTHING for both ASPX and CS files.
Is this possible via built-in setting, modification, or available from an add on?
Thanks
Select the code block and press Ctrl+K+F
Would a keyboard shortcut work for you?
Ctrl + k + d - format the whole document.
Ctrl + k + f - format selection.
In C#, you can also delete and reinsert the } for a similar effect on the block in question.
Under Tools | Options, you can navigate to Text Editor | C# | Formatting and select all three checkboxes. This will cause your code to be auto formatted per the formatting options in C# | Formatting on those certain events: namely typing a semi-colon, typing a close stache, or pasting in code.
Note: In order for this to work, the code in the file must be able to compile without errors. Also, if you don't have any formatting options specified, or left at their default values, you may not see any difference.
You could also look into tools like ReSharper (disclaimer: I work for them)

Resources