Click here to Skip to main content
15,907,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need some help with a program I am writing. I am a newbie so please be patient :)

My company uses a lot of Outlook email profiles, instead of using the default small combo box, I have created an interface using a list box to show all available profiles. The user can then double click the desired profile to launch it.

Where we use MS exchange, if the user is logging onto a profile that is not linked with their Windows login, they have to fill in a login box, filling in the email address and password. This is quite time consuming as some of our admin staff have over 10 profiles to keep an eye on (I know, its a ridiculous setup but thats for a different forum).

What I would like my program to do is wait and see if the login window appears, then, if it does, auto complete the username (I can extract this from the registry). It would also be great if I could somehow store and fill in the password, then automatically submit the login box.

Is there a way to wait for the window to appear, then fill it in? preferably without using sendkeys (I know this can cause problems if a user is a bit 'clicky' with the mouse.

Appreciate any help

Jim

PS: I'm coding in Visual C#
Posted

The Sendkey won't help you much — it's too limited. There is only one totally comprehensive way of imitation absolutely any input: you need to P/Invoke Windows API SendInput.

(I feel that you company already abused technology pretty well with relying on Outlook and pushing its limits, so it's hard to improve the situation nicely without replacement the whole approach which might need to much investment in code. You're going to do pretty dirty job, sorry.)

—SA
 
Share this answer
 
Comments
Jim607 4-Jun-11 4:45am    
You are right about abusing the Tech. They all users have at least 3 different email accounts, some have 10. Madness! Thanks though, you have shown me SendInput and while looking at that, I have seen FindWindowByCaption which I believe I can use to make sure the dialog has focus.

I'll have bit of a hack at it but like you said, it's never going to be a nice solution. :( Thanks for your help.
Sergey Alexandrovich Kryukov 4-Jun-11 21:21pm    
Finding window by caption is another unreliable trick. Anyone can create an application with identical caption and screw up things.
Anyway, thank for accepting this solution.

Good luck, call again.
--SA
.NET textbox has a property AutoCompleteMode which you can use for resolving this problem. Also check out this[^]
 
Share this answer
 
v4
Comments
Jim607 3-Jun-11 17:36pm    
Unfortunately the dialog/textbox is not generated by my program. They are part of Outlook. My program simply searches the registry for available email profiles, then launches outlook with an argument to open the selected profile. I need to get the handle (if thats the correct terminology), so I can check if the login dialog exists or not. Maybe I was a bit ambitious for now expecting to do this without using sendkeys.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900