Windows API in outlook to cover send button - c#

I've been tasked with removing the send button in outlook, not just from the ribbon but from the message form. I've tried making some custom forms but they always seem to be lacking. We also have a custom button solution using them Item_send event, so tying into that event was causing issues.
I have been toying around with a different idea, to use the windows API to add a button over the Default send button.
I've done some research on this and have only found 1 suggestion to this being possible but the post didn't include too much information. My question is threefold, is it even possible? Is it a good idea? If so, where do I start?
p.s. Normally I'm a mobile engineer so I feel like a fish out of water when even googling stuff about the windows API but i'm confident I can pick it up with time.

If you need control over the sending process, the accepted and supported mechanism is to hook into the ItemSend event and cancel/approve as required according to your business logic. Otherwise, removing functionality from Outlook is a bad design decision.

Related

Collect the recently clicked 5 buttons in Word with VSTO C#

Does anyone know how to collect the recently clicked 5 buttons, and save them to a new group in the Hometab for reusing? Using C# in VSTO.
It seems a simple thing, however, I find now way to dynamicly monitor the control event in the ribbon and get the ID.
Have searched for several weeks.
Thanks a lot if anyone can help.
Hmm I don't think it's possible or at least I don't know about any way how to do that.
First there is no way how to easily monitor which button was pressed by any API Microsoft provides. You know, there is no command there is called for every button where you can hook your code and listen. I know that out there are amazing tools that can help you with things I originally thought are impossible RubberDuck, Watch Dog, MZ Tools but first, they are mainly for VBA, second it's probably not easy solution that you are looking for.
You would probably have to - somehow - mimic Office ribbon by your own ribbon => way too much work, use one callback, monitor it and determine the last 5 buttons.
Then you would have to change the Home tab by changing the ribbon XML which has two drawbacks
1, I believe it's not possible adding/removing buttons dynamically (you can use callback to change visibility but for adding/removing there is probably nothing)
2, you would have to restart the Office application to see your changes
As you see I'm not entirely sure it's impossible but I do see it as way too much work.
Anyway I'd love to hear if there is a way how to do that, so please if you find any way do let me know. Thanks

Selecting an item from pop-up menu

I'm trying to make an application that will test some features of an existing app and I wanted it not to be window-size dependent and not to require focusing the window or etc.
I've already figured out how to get window handles for different controls in the tested app so I can click buttons, enter text to textboxes etc. with Send/Post Message but still got a few unsolved problems.
The first is selecting an item from a pop-up menu that can be triggered by button click (TAdvGlowMenuButton class) or right click somewhere- I can't even see any messages related to it in Spy++ so I have no idea how to do it, is it possible to select an item by name? as I don't have it's id
The second thing is clicking next to something, for example 10 pixels to the right of a button.
I have the button handle so I can get it's size and it's parent but I still don't know how to get it's position inside the parent - any ideas?:)
And also a quick one but I don't believe it is possible - can I somehow get position of a label in the tested app? I can't even see it in Spy++ .
I hope you can help me to find it out ;)
Edit: I forgot about the most important thing:P , I'd like to achieve it with Send/Post Message if only it is possible.
My recommendation would be to abandon the message sending/posting model altogether and instead use UI Automation. Automated testing tools is exactly what the UI Automation APIs were designed for, and they are much more capable than SendMessage/PostMessage.
Yes, I realize that this is exactly the opposite of the answer you were looking for. But you will have no end of trouble getting messages to do what you want. A fair number of them rely on the application having the focus, and it is completely reasonable for your code to make this assumption when you receive e.g. a WM_KEYDOWN message. A testing tool should not flag that as a bug.
I notice you've tagged this question with the C# and .NET tags. In that case, you may be interested to learn that the UI Automation APIs have been wrapped in the .NET Framework.

Buttons to Message Box in Visual Studio 2008

Is it possible to add custom buttons (or) User defined buttons inside Message Box in Visual Studio Windows Forms application ?
Here's a quick guide to making a custom dialog box, which is going to be the ideal solution for you in this scenario, in my opinion.
The simple answer is: no it's not.
The long answer is that it's not possible using the managed API but it may be possible using the Win32 API. Here's a good tutorial on using Windows Hooks to customize the operating system message box dialog.
The .net MessageBox class does not offer such functionality. However, the native Win32 API does so through the TaskDialog API. The main advantage of this approach, as opposed to writing a custom dialog, is that you will be using a native system component and so your dialog will feel at home on the platform.
A very simple example of the task dialog looks like this:
And there is lots of scope for much more complexity, as is explained in the link above.
You'll need to p/invoke to this function. It's one of the more messy functions to call so expect a little work before you have a working solution. You can find some C# code to wrap it up here, but I can't say that I personally have experience of this.

Profiling how a user interacts with a C# Windows Application

I just inherited a C# windows application codebase. It's a relatively large application with lots and lots of UI "elements" that I believe may have been added by the previous developer with little to no interaction with the actual clients. This application is a robotics control system, it runs at a manufacturing facility, and it has some of the most complex UIs I have ever seen (forms inside of forms inside of tabbed elements inside of etc...)
One of the first things I want to do, is learn about how the actual plant floor associates interact with this application. I have already sent out a survey to the different supervisors, but I would like some empirical data as well.
What I would like to do:
I would like to somehow, capture every time a user presses a button, control, etc... and record it to a file. Something simple like:
timestamp,name of control,any other cool data I can capture (program run state, for example.)
The difficulty is that I'm not really a C# expert at this point, and I can't figure out the appropriate way to add some sort of global behavior to my application which does this, and doesn't impact existing functionality. Any advice would be greatly appreciated.
Global keyboard and mouse hooks would be the way to go. Unless someone knows the design thoroughly and can comment how to extend existing functionality. it is going to be bit difficult.

Checking for Shift+Click or Ctrl+Click in a Web User Control

I have a requirement to produce a Web User Control (in C#) which will exhibit different behaviour when clicked depending on whether the shift (or control) key is pressed at the time. The control itself will contain an ImageButton and/or Hyperlink.
Is this possible?
Basically, if the logged in user is an Admin then I need to allow them access to update the associated URL. I don't want to have a separate page for this admin as it will cause confusion.
Thanks in advance
How about here?
To implement the Ctrl / Alt / Shift detection, you can use the properties event.ctrlKey, event.altKey, event.shiftKey and the deprecated Navigator-specific property event.modifiers.
Your control needs to emit some javascript to detect what keys are being pressed when it is clicked on.
Here is a primer from w3schools on events, here is a list of events of the window object you can listen to (such as onkeydown for keyboard presses).
I'd discourage this as it will get you into serious trouble with different browser versions.
As long as you aren't targeting one browser explicitly you'll be doing maintenance work for various browsers all the time.
A way around this is to find a supported Javascript library like jQuery that supports this behavior and let the maintainers of that library care about browser compatibility (You still need to update that library then..)
Well the 'powers' have decided that the Shift/Ctrl + Click approach was too clunky.
After a brainstorming session we have decided to go down the route of displaying a small 'Edit' button next to the control. This will only be visible for Administrator users and I've pulled it together in about two hours.
Thanks for taking the time to provide your input.
Can someone with a high rep please close this question for me - thanks.

Categories

Resources