 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
guest3456 Guest
|
Posted: Tue Mar 16, 2010 10:06 pm Post subject: ControlClick the titlebar, etc? |
|
|
according to this documentation:
http://www.autohotkey.com/docs/commands/ControlClick.htm
| Quote: |
Mode 1 (Position): Specify the X and Y coordinates relative to the target window's upper left corner. The X coordinate must precede the Y coordinate and there must be at least one space or tab between them. For example: X55 Y33. If there is a control at the specified coordinates, it will be sent the click-event at those exact coordinates. If there is no control, the target window itself will be sent the event (which might have no effect depending on the nature of the window). Note: In this mode, the X and Y option letters of the Options parameter are ignored. |
but does ControlClick allow you to even click part of the window that isnt part of the client area (such as titlebar, borders, etc)? according to Autohotkey source script2.cpp:
| Code: |
...
// Convert click's target coordinates to be relative to the client area of the control or
// parent window because that is the format required by messages such as WM_LBUTTONDOWN
// used later below:
click = pah.pt;
ScreenToClient(control_window, &click);
...
|
so it converts to client coords for WM_LBUTTONDOWN etc messages but doesnt handle non client coords that are still part of the window, and doesnt send WM_NCLBUTTONDOWN etc messages? or hopefully i am missing something and this can be done?
this doesn't work:
| Code: |
MouseGetPos,,, win
ControlClick, x1 y1, ahk_id%win%
|
this does (but i dont want to move mouse, i want to PostMessage):
| Code: |
CoordMode, Mouse, Screen
MouseGetPos,,, win
WinGetPos, xx, yy, , , ahk_id%win%
xxx := xx+1
yyy := yy+1
Click, %xxx%, %yyy%
|
|
|
| Back to top |
|
 |
svi
Joined: 09 Oct 2006 Posts: 236 Location: Finland
|
Posted: Tue Apr 27, 2010 10:25 pm Post subject: |
|
|
I've used ControlClick on the title bar on my main script, and hadn't found problems with it.
I thought that your coordinates are too near to the corner to hit the window (rounded corners on "XP style"), but that's not the (only) problem.
I made a script to demonstrate how it works (on some windows). The window "My Documents" won't be activated by the ControlClick unless you uncomment the MsgBox line (only it's menu becomes enabled:).
A script to test (works as such at least on XP / English):
| Code: | Run ::{20d04fe0-3aea-1069-a2d8-08002b30309d}
Run ::{450d8fba-ad25-11d0-98a8-0800361b1103}
Sleep 2000
Winmove My Documents, , 0, 0
Winmove My Computer, , 50, 50
WinActivate My Computer
ToolTip Active?: My Computer
Sleep 2500
; MsgBox, , , , 0.001
ControlClick X33 Y6, My Documents
ToolTip Active?: My Documents
Sleep 20000 |
MsgBox seems to only help to activate the window by ControlClick, not eg. to activate the system menu (coordinates ~X14 ~Y11 on my system / current settings). _________________ Pekka Vartto |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Wed Apr 28, 2010 10:20 am Post subject: |
|
|
ControlClick doesn't use the non-client area messages at all, but there's nothing to stop you from posting those message yourself with PostMessage. There's a list of message values in the help file (type "message" into the index), and documentation for each message can be found by searching MSDN Library.
| svi wrote: | | not eg. to activate the system menu | That is because like the title bar and buttons, the system menu is located in the non-client area and will not respond to the "client area" messages posted by ControlClick. |
|
| Back to top |
|
 |
guest3456 Guest
|
Posted: Thu May 06, 2010 1:18 pm Post subject: |
|
|
| Lexikos wrote: | ControlClick doesn't use the non-client area messages at all, but there's nothing to stop you from posting those message yourself with PostMessage.
..
That is because like the title bar and buttons, the system menu is located in the non-client area and will not respond to the "client area" messages posted by ControlClick. |
yes, i'm posting the messages myself. i think the documentation quoted in my OP should be changed then, since the coords used for this command are NOT relative to upper left corner (which in my mind included titlebar/border/sysmenu) , but rather to the client area |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Fri May 07, 2010 9:12 am Post subject: |
|
|
The documentation is correct: the coords are relative to the top-left corner of the window, not the top-left corner of the client area. If any controls exist in that area, they may be clicked even though that part of the control would not be visible. For example,
| Code: | Gui, Add, Button, X-50 Y-50 W49 H49 gFoo, Hello!
Gui, Show, W100 H100
Gui, +LastFound
Sleep 1000
ControlClick, X0 Y0
return
Foo:
MsgBox Foo!
return |
Although it would be more useful to use client coords in most cases, the current behaviour has to be kept for backward-compatibility. |
|
| Back to top |
|
 |
guest3456 Guest
|
Posted: Fri May 21, 2010 1:08 pm Post subject: |
|
|
oh, i see.
thanks for the clarification  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|