|
Hi, thanks for your reply, but the problem is that i need to do this without setting focus on the application .
I'm trying to do this with the notepad (for test), sending CTRL+F to open the "Search" window, but when i run the application, the notepad shows a "F" in the edit area. I don't know why it's ignoring the "CTRL".
|
|
|
|
|
1. I think in this case you can't use the SendKeys function, because they send the input to the window that has the focus.
Can't you just switch the focus for this very short period of time to your app and than back to the app that had the focus before?
2. Ever tried to send KEYDOWN at first (try with ALT modifier set/unset) and after you sent left ALT + some key just sent an KEYUP event?
Something like this:
PostMessage(hWnd, KEYDOWN, VK_LEFTALT);
PostMessage(hWnd, KEYDOWN, VK_F);
Sleep(100);
PostMessage(hWnd, KEYUP, VK_F);
PostMessage(hWnd, KEYUP, VK_LEFTALT);
Greetings
Covean
|
|
|
|
|
Hi! I found the solution! it is a mix between a sendkeys and postmessage, that works
First, set the "ControlKey" to "active" (i think it's like if we "press" the keyboard controlkey), then send the PostMessage to the hWnd (application), and then restore the "ControlKey" state.
keybd_event(VK_CONTROL, (byte)MapVirtualKey(VK_CONTROL, 0), 0, 0);
PostMessage(hWnd, WM_KEYDOWN, (uint)VK_F, 0);
keybd_event(VK_CONTROL, (byte)MapVirtualKey(VK_CONTROL, 0), 2, 0);
Thanks to all for the replies.
|
|
|
|
|
I think the problem is, that you send an ALT key but not left or right ALT, what is a big difference for the OS.
VK_ALT is only used in user application the simplify some things.
1. send VK_LEFTALT = 0xA4 or VK_RIGHTALT = 0xA5
or
2. use SendKeys.Send
or
3. Have a look at (low-level) windows key hooking (SetWindowsHookEx). This helps the understand how key strokes are queued in the windows messaging system.
Greetings
Covean
|
|
|
|
|
Hi,
When i am running a browser ( which i was created in windows application ), no one should kill my processes through Task Manager. How can i do this.
Thanks.
krishna
|
|
|
|
|
You can't. Many others have asked that over the years. You probably won't be the last either.
|
|
|
|
|
I don't know of a way to do this, and I'd strongly consider beating you severely if you did this to me. I stopped using Internet Explorer because I got tired of it launching multiple instances of itself that consume 100% of resources over time. Acrobat Reader does the same thing. Without the ability to kill a process in Task Manager, your application is no better than a virus.
That being said, certain users in a business environment should be restricted from accessing Task Manager at all. That's simply good security practice, and can be accomplished by an Administrator using Group Policies. Look into Group Policy management if you want to do this for a legitimate reason.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
You can't. Since your app is launched by the user, it runs AS the user. The user can kill any process they launch and there's nothing you can do about it.
|
|
|
|
|
You can, actually.. at least under XP. But that would make your program malware, so I'm not going to help with that.
On a related note, you can easily (without hacks) make it so that your program will not close when "killed" from the Applications list. It can still be closed from the Processes list, so that wouldn't make it malware.
If you have a Form, subscribe to the FormClosing event and set e.Cancel to true .
|
|
|
|
|
You can have your processes save their state at regular intervals, and run a second "shadow" process that monitors the primary processes.
When the shadow process detects that one of the primary processes was stopped (e.g. with Task Manager), it restarts that process, using that process' saved state to pick up where it left off.
|
|
|
|
|
krishnavaradharajan wrote: no one should kill my processes through Task Manager.
And what are you going to do, if the user tripped the power cable? Why do you want to prevent the user from killing your buggy application.
|
|
|
|
|
hi,
the easy way would be to disable the taskmanager for the user using policies.. it sounds like the user will have no ability to to certain changes on the system either, so would be using policies the right way if not it would be a way too =)
|
|
|
|
|
Remember that it is your software, but it is not your computer! All the tricks you can apply to prevent the owner of the computer from closing an application running on it could be considered as not politically correct!
|
|
|
|
|
Can you tell us why you'd like to implement this behavior? There may be a more acceptable means of meeting your requirements (which may be perfectly valid), but it's hard to guess without a use case. If you stated the big picture, you may get some helpful replies.
/ravi
PS:
I've often fallen into this trap myself. When I ask someone how to do something, I invariably end up at a better solution by answering why I'd like to do this (i.e. what's the end result I'm trying to achieve).
|
|
|
|
|
|
I would use a ListBox , and choose DrawMode.OwnerDrawVariable ; then use the MeasureItem and DrawItem events, and the Graphics.MeasureString() and DrawString() methods.
|
|
|
|
|
Hi all other system giving
DateTime.Now.ToLongDateString() as Wednesday, July 28, 2010
But my system giving 28 July 2010
wht is the probs, y its giving like tht?,
To get asusal like others system dateformat where i should change in my PC?
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
You could - but you don;'t need to. The default DateTime.ToString method returns whatever your PC is set to, but you can tell it to return exactly what you want. See Here[^] for full details.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Hi Griff, Thanks for ur reply,
I already created lot of project in the same way...,
So i cant go and modify all the project place the date format like (MM/dd/YYY)...,
If i change on single place(PC), it will work for all projects...,
Thats y asking, where to change the date format in PC, to get asusal format like others machine...,
i have changed in my date format and restarted, thn also getting same dd MMM yyyy
Plz any one guide me
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
Member 3879881 wrote: If i change for PC it will work for all projects...,
...that are run on that PC.
Run your app on someone else's PC and you have no idea what results you will get... Bad idea to rely on PC user setup for specific features!
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
i have checked the same project with other pc i got my result exactly...,
my i/p & o/p goiing fine in other pc...,
But in this pc wht i need i didnt get
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
So it proves that your code does not work in all cases. The solution is to update your code so that it does, not change the cases where it doesn't.
|
|
|
|
|
This is not the correct way to go. Changing a system setting like that will only screw up the data/time format for EVERYTHING on that PC, not just your app.
It's your job to update your code so that is works and plays nice with others. The solution you want is just you being lazy. The correct solultion is to properly write the code so that the users don't need to worry about what your app is doing to other apps on their machines.
|
|
|
|
|
there is a Control Panel often called Regional Settings where each PC user chooses the way dates, times, currencies, etc. are shown by default. For user interaction your app can (and should) choose to use those default settings (that is when you use those specialized methods such as ToLongDateString(), they really mean "take whatever format the user has chosen"). The advantage is the user gets what he prefers, the disadvantage is you cannot predict how wide things will be and the screenshots in your manual may slightly differ from the user's reality.
Of course, there also are situations where the format must be fixed, e.g. when writing the date to a file that is going to be used on some other system. That is where you should use ToString() and either pass an explicit formatting string or have your thread's CultureInfo fixed.
|
|
|
|
|
Hi,
How to increase the font size of the text and size of the controls, when we click on maximize button of the form. Please guide me to achieve this. Thanks in advance.
|
|
|
|