Can I open office communicator (Lync 2010) in chat mode? - shellexecute

In an Win/IE environment with the right settings you can fire up a .exe file.
The following code runs fine to fire up Microsoft Lync (the new name for Office Communicator).
...
start chat
</body>
</html>
<script type="text/javascript">
function fnShellExecute()
{
var objShell = new ActiveXObject("shell.Application");
objShell.ShellExecute("communicator.exe", "", "C:\Program Files (x86)\Microsoft Lync", "open", 10);
}
</script>
But I can't work out the parameters (or if it is possible) to create a shortcut that would open the Lync client with the chat box to another available user open. Basically I know who is available and I want to be able to create (in HTML) a simple link that would open a chat window to that person (outside of WPF or Silverlight or any of the built in controls).
Does anyone know how to adjust this line in the javascript to open a Lync chat window to a specified contact?
objShell.ShellExecute("communicator.exe", "", "C:\Program Files (x86)\Microsoft Lync", "open", 10);
Or if there is another way to open Lync in chat mode via some kind of shortcut?
Thank you in advance.

Depending on your requirements, the easiest will be to use the existing NameCtrl persona menu - this is the pop-up menu that gets displayed in SharePoint (and other web-based apps like Dynamics CRM) when hovering over a users presence icon. This menu allows you to call the user, start a new conversation etc. You'd need Office installed on the machine you are running on in order for it to work.
As an example, try this on any client machine running Office 2007/2010 and IE. Hover over the "Your Contact" text to see the persona menu:
<script>
var sipUri = "your.contact#your.domain.com";
var nameCtrl = new ActiveXObject('Name.NameCtrl.1');
if (nameCtrl.PresenceEnabled)
{
nameCtrl.OnStatusChange = onStatusChange;
nameCtrl.GetStatus(sipUri, "1");
}
function onStatusChange(name, status, id)
{
// This function is fired when the contacts presence status changes.
// In a real world solution, you would want to update an image to reflect the users presence
alert(name + ", " + status + ", " + id);
}
function ShowOOUI()
{
nameCtrl.ShowOOUI(sipUri, 0, 15, 15);
}
function HideOOUI()
{
nameCtrl.HideOOUI();
}
</script>
<span onmouseover="ShowOOUI()" onmouseout="HideOOUI()" style="border-style:solid">Your Contact</span>

If the NameCtrl answer doesn't meet your requirements, you could try the Lync SDK. It would be pretty straightforward to create a .NET DLL that uses the Automation API to open a conversation with a given user.
You would then need to expose this via COM to ensure it could be called from JavaScript. Again, pretty straightforward using .NET's COM Interop features.

Related

SendKeys for Xamarin.Mac

I am building a Mac app in Xamarin and have a need to send keystrokes (with words and phrases) to other applications. Something like SendKeys in .Net on Windows.
Is there a SendKeys equivalent API for Mac in Xamarin?
CGEventCreateKeyboardEvent is what you are looking for, it is Quartz-based and thus a low-level C API.
Xamarin has a shim-wrapper over it via an CGEvent .ctor. After you create the event, include any-keyboard modifiers (shift/apple/alt/....), you can Post it to a process id of your choosing.
Really quick example that sends stackoverflow to active process/window.
using (var eventSource = new CGEventSource(CGEventSourceStateID.HidSystem))
{
var eventString = "StackOverflow";
foreach (var eventChar in eventString)
{
// 🍣 my most favorite Enum.Parse line ever written 🍣
var key = (ushort)(NSKey)Enum.Parse(typeof(NSKey), eventChar.ToString().ToUpper());
using (var keyEvent = new CGEvent(eventSource, key, true))
{
CGEvent.Post(keyEvent, CGEventTapLocation.HID);
}
}
}
Note: To see it in action, place a Task.Delay before it, run it and then switch to/activate an editor, maybe Visual Studio for Mac :-) and let it type into the active editor panel.
FYI: You might want to refer to the Xamarin wrapper/source code for CGEvent.cs, as their naming is not vary ObjC or Swift friendly in terms of be able from translate Apple docs to Xamarin.Mac code.
Re: xamarin-macios/src/CoreGraphics/CGEvent.cs

Invoking a button press in a desktop application from an external application when HWND and control automation ID are known

I am trying to automate button presses for a desktop application on Windows 7 - 10. I have been able to do this using AutoHotKey and PowerShell. However, I have had the following issues:
The controls I am trying to click do not have text that I can use to
isolate the control
The ClassNN name for the components is not
static
I have looked through the MSDN documentation for the System.Windows.Automation namespace, but the documentation doesn't provide actual examples or describe how to use the namespace.
Question
If I always have a window handle (HWND) and an Automation ID for a control, how do I invoke a button press on the control using AutoHotKey, PowerShell(3.0+), or C#?
You can do it with C# and System.Windows.Automation.
First of all get your control as an AutomationElement (let's call it thiselement).
Then you can invoke InvokePattern to perform click action.
InvokePattern ip;
ip = thiselement.GetCurrentPattern(InvokePattern.Pattern) as
InvokePattern;
ip.Invoke();
Suppose your window handle is 'handle' and automation id of the button is 'automationId' then you can do something like
AutomationElement parentWin = AutomationElement.FromHandle(handle);
Condition c1 = new PropertyCondition(AutomationElement.AutomationIdProperty,
automationId);
AutomationElement thiselement = parentWin.FindFirst(TreeScope.Descendants, c1);
once you get the button object,just invoke the InvokePattern .Please forgive the foramatting of text

Is there a way to see if a specific Add-In is installed?

Is there a way (API or other?) to find out if an add-in is installed?
I'm looking at augmenting the Exchange install to insert my own button to tell my user if an Outlook add-in is installed or not?
Is there an API for finding out?
The Office Object Model has a COMAddins collection accessible from the Outlook.Application object that you can use to iterate through all registered add-ins. Any add-in that is loaded will have COMAddin.Connect set to True (which you can set to False to unload the add-in).
https://msdn.microsoft.com/en-us/library/ff870066.aspx
The trick to doing this in Exchange and OWA (not desktop Outlook) is to use JS to manually open the Add-Ins pane and try to click your add-in. Not perfect, I realize, but it does satisfy the original requirement even though there is no direct API support.
Edit the file named, microsoft.owa.mail.compose.js and find a good place to enter something similar to the following.
var workDocument = (this.bh.bz) ? $(this.bh.bz.document) : window.document;
var yourAddIn = $(workDocument).find('iframe[title="Your_Add-In_Name"]');
if (yourAddIn.length > 0) {
yourAddIn[0].contentWindow.postMessage({ id: 'Look_for_your_id_using_DevTools_F12_and_Find_the_id', message: 'send'}, '*');
return;
} else {
// Click Add-in button, click the add-in name in the add-ins list
var addInsButton = $(workDocument).find("button[title='Add-ins']");
if (addInsButton.length <= 0) {
return;
}
addInsButton[0].click();
}

Adding ActiveX control to powerpoint

I have an ActiveX control that installed on my machine, and can be added from PowerPoint via:
Developers->Controls->More Controls->"My control".
I want the user to be able to add the ActiveX via Custom button on the Ribbon.
I successfully added a button to my custom Ribbon (VSTO). but I can't find a way to make this button adding "My Control" to the slide.
I also successfully added an Excel sheet by calling:
Shapes.AddOLEObject(1, 1, 100, 100, "Excel.Sheet", "", MsoTriState.msoFalse, "", 0, "", MsoTriState.msoFalse);
but I can't fint the appropriate way to add my custom ActiveX.
What am I doing wrong?
How can I load this ActiveX from C#?
After two days of searching an answer I found the trick:
the problem is that you need a specific string that recognize the ActiveX control.
what I did is:
open Word and on the developers ribbon record a macro (this option not exists in powerpoint) of mouse clicks
add your control (Controls->More Controls->"My control")
stop recording macro.
view the macro's VBA created (click edit macro) you can find a
string like "myControlLib.myControlctrl.1"
this is the string needed by the Shapes.AddOLEObject(...) as class name.
Microsoft have a utility called OLE/COM Object viewer. You can use it to find the ProgID (the string used to add ActiveX controls in PowerPoint) along with pretty much everything else you'll want to know about your control. Have a look at:
http://msdn.microsoft.com/en-us/library/d0kh9f4c.aspx

Outlook addin has failed to find Office control by ID

I've just built an MS Outlook Add In using Visual Studio and Office 2010. I've installed it ok on 4 machines, but one user is getting the following error -
Error found in Custom UI XML of "...."
...
...
Failed to find Office control by ID
Everyone is running Windows 7 and Outlook 2010 - not sure why this person is having a problem. Can anyone suggest how to diagnose this?
For those having similar issues, you don't have to remove any add-in.
What is happening is: Outlook will try to load all ribbons (found in your ribbon xml) into any window the user goes to. Then it'll complain about not finding ID x or y.
Just make sure your GetCustomUI method in Ribbon.cs does not load the entire ribbon XML at once but rather loads it per fragment.
If you're not sure what IDs you need to target, use a breakpoint in GetCustomUI then start Outlook, surf different views (main, new email, new appointment, calendar...etc) in order to gather the IDs for the views wherein you need to show you add-in.
In my case, I needed Microsoft.Outlook.Explorer, Microsoft.Outlook.Mail.Compose and Microsoft.Outlook.Appointment.
Therefore I changed my GetCustomUI to:
public string GetCustomUI(string ribbonID)
{
switch (ribbonID)
{
case "Microsoft.Outlook.Explorer":
return GetResourceText("MyAddin.RibbonsForOutlookExplorer.xml");
case "Microsoft.Outlook.Mail.Compose":
return GetResourceText("MyAddin.RibbonForOutlookMailCompose.xml");
case "Microsoft.Outlook.Appointment":
return GetResourceText("MyAddin.RibbonForOutlookAppointment.xml");
default:
return null;
}
}
Of course, I had to break down my Ribbon.xml into the three XML files mentioned above. The result: Outlook will ONLY load the fragment needed for a given screen (appointment, new email ...) and will not complain about "not finding an ID on screen X or Y".
Finally, for those who are not sure why some users get that error while others don't: it's because of "Show add-in user interface errors" option (in Options -> Advanced). If that is unchecked then Outlook will ignore the malformed ribbon XML errors. If it checked, users will get related errors about your add-in (if any exists) and also about other add-ins.
If it works for everyone except one user. As #Brijesh Mishra mentioned check if the user has got any other addin and if he is having own quick access tool bar customized.
If he has got any of this then, remove the other addins and try to install or reset the quick access tool bar customization.
For all of you that use a Designer-based VSTO plugin, and not the XML solution.
I searched all the web for this problem, but only found XML-based solutions.
There's nothing for Visual Designer on the web, because in this case you don't have to override the "GetCustomUI" method.
Ribbons designed by using the Visual Designer return a RibbonManager by default.
This RibbonManager object represents all Ribbon (Visual Designer) items in the project and is automatically handled in background through the active window inspector.
So you don't have to write any special code to handle different windows.
To configure it correctly you just have to:
Add one extra Visual Designer Ribbon for every window the user goes to
in the Ribbon Object go under "RibbonType", open the checkbox list an only activate the corresponding window, where the ribbon should appear.
If there is more than one window checked in the list, Outlook trys to insert the ribbon in all the marked windows. Even if the corresponding window is currently not opened. That's the reason, why the error "Failed to find control ID" appears.
the actual fix for me was to separate the ribbon XML files containing the customUI and redirecting to the correct one in the GetCustomUI method (implemented using Office.IRibbonExtensibility)
in example:
public string GetCustomUI(string RibbonID)
{
switch (RibbonID)
{
case "Microsoft.Outlook.Mail.Read":
return GetResourceText("namespace.type1.xml");
case "Microsoft.Outlook.Mail.Compose":
return GetResourceText("namespace.type2.xml");
default:
return null;
}
}

Resources