473,414 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

How to perform a control click?

I tried this but it doesn't work

keybd_event(VK_CONTROL, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)

Any idea how to do this?
Nov 19 '08 #1
6 4004
On Nov 19, 1:27*am, "hurricane_number_...@yahoo.com"
<hurricane_number_...@yahoo.comwrote:
I tried this but it doesn't work

keybd_event(VK_CONTROL, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)

Any idea how to do this?
Are you trying to click one of your applications controls or something
else?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Nov 19 '08 #2
hu******************@yahoo.com wrote:
I tried this but it doesn't work

keybd_event(VK_CONTROL, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
If it's a control in your own application, use

[<control>].PerformClick()

It has all the same restrictions as clicking it interactively - the
control has to be visible and enabled (as do all of its parent controls).

If it's a /different/ application, are you running Vista?
That puts some fairly rigid barriers between types of application,
preventing them from doing just this sort of thing.
Any idea how to do this?
No, but then I'm not familiar with these particular functions.
Take a step back; what is the end /result/ you're trying to achieve?

HTH,
Phill W.
Nov 19 '08 #3
It's another program, this acts like a remote access app. I have no
problem with the clicks, but adding any modifiers don't do anything.
It must be possible, otherwise how would programs like VNC do it?

On Nov 19, 8:25*am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
wrote:
hurricane_number_...@yahoo.com wrote:
I tried this but it doesn't work
keybd_event(VK_CONTROL, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)

If it's a control in your own application, use

[<control>].PerformClick()

It has all the same restrictions as clicking it interactively - the
control has to be visible and enabled (as do all of its parent controls).

If it's a /different/ application, are you running Vista?
That puts some fairly rigid barriers between types of application,
preventing them from doing just this sort of thing.
Any idea how to do this?

No, but then I'm not familiar with these particular functions.
Take a step back; what is the end /result/ you're trying to achieve?

HTH,
* * Phill *W.
Nov 19 '08 #4
On Nov 19, 4:39*pm, "hurricane_number_...@yahoo.com"
<hurricane_number_...@yahoo.comwrote:
It's another program, this acts like a remote access app. I have no
problem with the clicks, but adding any modifiers don't do anything.
It must be possible, otherwise how would programs like VNC do it?

On Nov 19, 8:25*am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
wrote:
hurricane_number_...@yahoo.com wrote:
I tried this but it doesn't work
keybd_event(VK_CONTROL, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
If it's a control in your own application, use
[<control>].PerformClick()
It has all the same restrictions as clicking it interactively - the
control has to be visible and enabled (as do all of its parent controls).
If it's a /different/ application, are you running Vista?
That puts some fairly rigid barriers between types of application,
preventing them from doing just this sort of thing.
Any idea how to do this?
No, but then I'm not familiar with these particular functions.
Take a step back; what is the end /result/ you're trying to achieve?
HTH,
* * Phill *W.
Hi,
If your VNC program accepts an action with modifier key combination
when it's first activated (got focus), just like on normal usage, you
can automate it using SendKeys.Send method based on that approach:

For example, send a CTRL+UP message
' First activate the VNC application
' You can pass its process ID
' or its title string
AppActivate("Welcome to VNC")

' Send CTRL+UP using CTRL modifier
SendKeys.Send("^{UP}")

....where caret (^) is your modifier, in that case, control key.

For more keys:
http://msdn.microsoft.com/en-us/libr...83(VS.85).aspx

Hope that approach makes some sense,

Onur Güzel
Nov 19 '08 #5
I can do keys with modifiers. I'm looking to do a mouse click with
modifiers.
On Nov 19, 11:25*am, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Nov 19, 4:39*pm, "hurricane_number_...@yahoo.com"

<hurricane_number_...@yahoo.comwrote:
It's another program, this acts like a remote access app. I have no
problem with the clicks, but adding any modifiers don't do anything.
It must be possible, otherwise how would programs like VNC do it?
On Nov 19, 8:25*am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
wrote:
hurricane_number_...@yahoo.com wrote:
I tried this but it doesn't work
keybd_event(VK_CONTROL, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
If it's a control in your own application, use
[<control>].PerformClick()
It has all the same restrictions as clicking it interactively - the
control has to be visible and enabled (as do all of its parent controls).
If it's a /different/ application, are you running Vista?
That puts some fairly rigid barriers between types of application,
preventing them from doing just this sort of thing.
Any idea how to do this?
No, but then I'm not familiar with these particular functions.
Take a step back; what is the end /result/ you're trying to achieve?
HTH,
* * Phill *W.

Hi,
If your VNC program accepts an action with modifier key combination
when it's first activated (got focus), just like on normal usage, you
can automate it using SendKeys.Send method based on that approach:

For example, send a CTRL+UP message
' First activate the VNC application
' You can pass its process ID
' or its title string
AppActivate("Welcome to VNC")

' Send CTRL+UP using CTRL modifier
SendKeys.Send("^{UP}")

...where caret (^) is your modifier, in that case, control key.

For more keys:http://msdn.microsoft.com/en-us/libr...83(VS.85).aspx

Hope that approach makes some sense,

Onur Güzel
Nov 19 '08 #6
hu******************@yahoo.com wrote:
Turns out, my code actually does work, just not in Firefox, which is
the program I was testing it with and the one I was hopefully aiming
to get this working for. I tried this in other browsers and it works
fine. I also tried your suggestion, and it performs a doubleclick but
doesn't do anything different than before. Any idea why this wouldn't
work in Firefox only?
It could be that FF thinks something else is in focus (like a blank area).
What if you manually click on the element in question before running your
code?

Andrew
Nov 20 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Rene | last post by:
Hi, I'm spend many hour to fix this problem, read many articles about it but no article gave a solution. To isolate the problem I've created in IIS6 (WServer2003) a virtual directory test to...
4
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label...
9
by: TCORDON | last post by:
I have a user control that contains 2 image buttons, when you click one of them, both must change the image source, the thing is that the first time you click any one of them the page appears to do...
7
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant"...
9
by: Charles Law | last post by:
I have a form on which user controls are placed at runtime. When a control is added to the form a handler is added for an event that a high-level object raises, which must be handled by the new...
3
by: mthomason | last post by:
I keep getting this error when trying to update records using an ObjectDataSource. I have seen others post similar errors...but I haven't found any solutions. ObjectDataSource...
10
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's...
3
by: rn5a | last post by:
The ASPX FileUpload control displays a TextBox along with a 'Browse...' Button. Setting the different properties of this control just reflects the changes in the TextBox but not the Button. For...
3
by: nareshreddy | last post by:
Hi i am using the below code to close the window and i l get promt when click on 'X' button on ie browser with OK and Cancel buttons. if i click ok window will be closed, if i click cancel window...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.