Clicking works with Click (interestingly without comma):
Code: Select all
Click, 1031 41
Code: Select all
ControlClick, X1031 Y41, PDF-XChange Editor
Code: Select all
Click, 1031 41
Code: Select all
ControlClick, X1031 Y41, PDF-XChange Editor
Code: Select all
ControlClick, X1031 Y41, PDF-XChange Editor
ok, thx for the explaination, Lexikoslexikos wrote:No. ControlClick works with any window or control which responds to mouse messages. DavidP was identifying a position on the window, not a control. (Whether it was the right position, I don't know...)
ControlClick is used very heavily with some games, like World of Warcraft, which have no actual controls in the Windows sense, let alone standard ones.
Code: Select all
;###########################
; Header
;###########################
SetTitleMatchMode, 2 ; A window's title can contain WinTitle anywhere inside it to be a match
CoordMode, Mouse, Window ; Sets coordinate mode for Mouse to be relative to the active window
;###########################
; Change Textmarker Color in PDF-XChange Editor -- this works using CLICK
;###########################
#IfWinActive, PDF-XChange Editor
b:: ; make selected highlight blue -- replace "b" with your favorite hotkey
If (A_Cursor != "IBeam") ; only act when not editing text, e.g. don't act when editing a sticky note
{
Click, 1031 41 ; replace with your coordinates of the little black triangle besides the "Fill Color" toolbar button, PDF-XChange Editor toolbar called "properties" must be set to visible, use the Autohotkey Window Spy tool to find the coordinates
Click, 1017 298 ; replace with coordinates of the desired blue color that is shown on the picker when clicking on the "Fill Color" toolbar button
}
Else
Send, b ; send the actual letter if editing text, e.g. in a sticky note
Return
#IfWinActive
;###########################
; Change Textmarker Color in PDF-XChange Editor -- this doesn't work using ControlClick
;###########################
#IfWinActive, PDF-XChange Editor
g:: ; make selected highlight green -- replace "g" with your favorite hotkey
If (A_Cursor != "IBeam") ; only act when not editing text, e.g. don't act when editing a sticky note
{
ControlClick, x1031 y41, PDF-XChange Editor,,,, Pos ; replace with your coordinates of the little black triangle besides the "Fill Color" toolbar button, PDF-XChange Editor toolbar called "properties" must be set to visible, use the Autohotkey Window Spy tool to find the coordinates
ControlClick, x1047 y298, PDF-XChange Editor,,,, Pos ; replace with coordinates of the desired green color that is shown on the picker when clicking on the "Fill Color" toolbar button
; ControlClick, x1047 y298 ; this variant also does not work, not even when [#IfWinActive, PDF-XChange Editor/#IfWinActive] is also deleted
}
Else
Send, g ; send the actual letter if editing text, e.g. in a sticky note
Return
#IfWinActive
;###########################
; repeat the above for more colors
So... which window do you need to click? Your latest screenshot shows two more windows which are separate from the main "PDF-XChange Editor" window.This is the dropdown and color picker that needs to be clicked on the toolbar
True, but they are only shown for visualization. The window title and class as reported by Window Spy always stays the same:lexikos wrote:So... which window do you need to click? Your latest screenshot shows two more windows which are separate from the main "PDF-XChange Editor" window.
Code: Select all
- PDF-XChange Editor
ahk_class PXE:{C5309AD3-73E4-4707-B1E1-2940D8AF3B9D}
The tool window clearly has a different title, so I presume the main window remains active even after you click the tool window; however, when I activate the tool window, Window Spy shows the title of the tool window.The window title and class as reported by Window Spy always stays the same:
If the problem is indeed what Lexikos has found above, then this type of ControlClick bug/issue has been mentioned in the past. A suggested solution is here:lexikos wrote:I have installed an evaluation version of PDF-XChange Editor and confirmed that it does respond to ControlClick, but the mouse cursor must be over the appropriate button. Basically, when this program receives a click message (WM_LBUTTONDOWN), it ignores the position specified by the message and instead queries for the current mouse position (equivalent to MouseGetPos).
hypothetical ControlClick docs wrote: Options
NA [v1.0.45+]: May improve reliability. See reliability below.
MM [v1.1.17|2.0]: May improve reliability. See reliability below.
Reliability
"NA" avoids marking the target window as active and avoids merging its input processing with that of the script, which may prevent physical movement of the mouse from interfering (but usually only when the target window is not active). However, this method might not work for all types of windows and controls.
"MM" will send a WM_MOUSEMOVE message prior to the WM_[L|R]BUTTONDOWN click message. Some rare applications do not respect the coordinates that are sent in the BUTTONDOWN message and instead use the cursor position. Sending this message will simulate the cursor position and allow the clicks to be recognized in those applications.
No, that's a different issue.guest3456 wrote:If the problem is indeed what Lexikos has found above, then this type of ControlClick bug/issue has been mentioned in the past.
Code: Select all
ControlClick, x1031 y41, PDF-XChange Editor,,,, Pos
Yeah that's the main benefit. I suppose if the WM_MOUSEMOVE message won't work like Lexikos said, you could try this wrapper for Click which will quickly move the mouse back:DavidP wrote:I'd only prefer ControlClick because it is more elegant and doesn't actually move the pointer.Code: Select all
ControlClick, x1031 y41, PDF-XChange Editor,,,, Pos
Code: Select all
WinGet, PDFXhwnd, ID, PDF-XChange Editor
BasicClick(1031, 41, PDFXhwnd)
BasicClick(x, y, id) ;// input coords relative to a full window (including borders and caption)
{
CoordMode, Mouse, Screen
MouseGetPos, oldx, oldy
WinActivate, ahk_id %id%
BlockInput, MouseMove
CoordMode, Mouse, Relative
Click %x%, %y%
CoordMode, Mouse, Screen
MouseMove, %oldx%, %oldy%, 0
BlockInput, MouseMoveOff
}
try this from the thread linked above, (prob will only work on 32bit ahk)DavidP wrote:Sorry but I don't understand where and how I am to put the "WM_MOUSEMOVE" command in connection with the ControlClick command.
Code: Select all
ControlClick2(1031, 41, "PDF-XChange Editor")
;// required functions below, add these to the very bottom of your script
ControlClick2(X, Y, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="")
{
hwnd:=ControlFromPoint(X, Y, WinTitle, WinText, cX, cY, ExcludeTitle, ExcludeText)
PostMessage, 0x200, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_MOUSEMOVE
PostMessage, 0x201, 1, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONDOWN
PostMessage, 0x202, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONUP
}
; Retrieves the control at the specified point.
; X [in] X-coordinate relative to the top-left of the window.
; Y [in] Y-coordinate relative to the top-left of the window.
; WinTitle [in] Title of the window whose controls will be searched.
; WinText [in]
; cX [out] X-coordinate relative to the top-left of the control.
; cY [out] Y-coordinate relative to the top-left of the control.
; ExcludeTitle [in]
; ExcludeText [in]
; Return Value: The hwnd of the control if found, otherwise the hwnd of the window.
ControlFromPoint(X, Y, WinTitle="", WinText="", ByRef cX="", ByRef cY="", ExcludeTitle="", ExcludeText="")
{
static EnumChildFindPointProc=0
if !EnumChildFindPointProc
EnumChildFindPointProc := RegisterCallback("EnumChildFindPoint","Fast")
if !(target_window := WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText))
return false
VarSetCapacity(rect, 16)
DllCall("GetWindowRect","uint",target_window,"uint",&rect)
VarSetCapacity(pah, 36, 0)
NumPut(X + NumGet(rect,0,"int"), pah,0,"int")
NumPut(Y + NumGet(rect,4,"int"), pah,4,"int")
DllCall("EnumChildWindows","uint",target_window,"uint",EnumChildFindPointProc,"uint",&pah)
control_window := NumGet(pah,24) ? NumGet(pah,24) : target_window
DllCall("ScreenToClient","uint",control_window,"uint",&pah)
cX:=NumGet(pah,0,"int"), cY:=NumGet(pah,4,"int")
return control_window
}
; Ported from AutoHotkey::script2.cpp::EnumChildFindPoint()
EnumChildFindPoint(aWnd, lParam)
{
if !DllCall("IsWindowVisible","uint",aWnd)
return true
VarSetCapacity(rect, 16)
if !DllCall("GetWindowRect","uint",aWnd,"uint",&rect)
return true
pt_x:=NumGet(lParam+0,0,"int"), pt_y:=NumGet(lParam+0,4,"int")
rect_left:=NumGet(rect,0,"int"), rect_right:=NumGet(rect,8,"int")
rect_top:=NumGet(rect,4,"int"), rect_bottom:=NumGet(rect,12,"int")
if (pt_x >= rect_left && pt_x <= rect_right && pt_y >= rect_top && pt_y <= rect_bottom)
{
center_x := rect_left + (rect_right - rect_left) / 2
center_y := rect_top + (rect_bottom - rect_top) / 2
distance := Sqrt((pt_x-center_x)**2 + (pt_y-center_y)**2)
update_it := !NumGet(lParam+24)
if (!update_it)
{
rect_found_left:=NumGet(lParam+8,0,"int"), rect_found_right:=NumGet(lParam+8,8,"int")
rect_found_top:=NumGet(lParam+8,4,"int"), rect_found_bottom:=NumGet(lParam+8,12,"int")
if (rect_left >= rect_found_left && rect_right <= rect_found_right
&& rect_top >= rect_found_top && rect_bottom <= rect_found_bottom)
update_it := true
else if (distance < NumGet(lParam+28,0,"double")
&& (rect_found_left < rect_left || rect_found_right > rect_right
|| rect_found_top < rect_top || rect_found_bottom > rect_bottom))
update_it := true
}
if (update_it)
{
NumPut(aWnd, lParam+24)
DllCall("RtlMoveMemory","uint",lParam+8,"uint",&rect,"uint",16)
NumPut(distance, lParam+28, 0, "double")
}
}
return true
}
guest3456 wrote: ↑18 Oct 2014, 15:21try this from the thread linked above, (prob will only work on 32bit ahk)DavidP wrote:Sorry but I don't understand where and how I am to put the "WM_MOUSEMOVE" command in connection with the ControlClick command.
Code: Select all
ControlClick2(1031, 41, "PDF-XChange Editor") ;// required functions below, add these to the very bottom of your script ControlClick2(X, Y, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") { hwnd:=ControlFromPoint(X, Y, WinTitle, WinText, cX, cY, ExcludeTitle, ExcludeText) PostMessage, 0x200, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_MOUSEMOVE PostMessage, 0x201, 1, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONDOWN PostMessage, 0x202, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONUP } ; Retrieves the control at the specified point. ; X [in] X-coordinate relative to the top-left of the window. ; Y [in] Y-coordinate relative to the top-left of the window. ; WinTitle [in] Title of the window whose controls will be searched. ; WinText [in] ; cX [out] X-coordinate relative to the top-left of the control. ; cY [out] Y-coordinate relative to the top-left of the control. ; ExcludeTitle [in] ; ExcludeText [in] ; Return Value: The hwnd of the control if found, otherwise the hwnd of the window. ControlFromPoint(X, Y, WinTitle="", WinText="", ByRef cX="", ByRef cY="", ExcludeTitle="", ExcludeText="") { static EnumChildFindPointProc=0 if !EnumChildFindPointProc EnumChildFindPointProc := RegisterCallback("EnumChildFindPoint","Fast") if !(target_window := WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText)) return false VarSetCapacity(rect, 16) DllCall("GetWindowRect","uint",target_window,"uint",&rect) VarSetCapacity(pah, 36, 0) NumPut(X + NumGet(rect,0,"int"), pah,0,"int") NumPut(Y + NumGet(rect,4,"int"), pah,4,"int") DllCall("EnumChildWindows","uint",target_window,"uint",EnumChildFindPointProc,"uint",&pah) control_window := NumGet(pah,24) ? NumGet(pah,24) : target_window DllCall("ScreenToClient","uint",control_window,"uint",&pah) cX:=NumGet(pah,0,"int"), cY:=NumGet(pah,4,"int") return control_window } ; Ported from AutoHotkey::script2.cpp::EnumChildFindPoint() EnumChildFindPoint(aWnd, lParam) { if !DllCall("IsWindowVisible","uint",aWnd) return true VarSetCapacity(rect, 16) if !DllCall("GetWindowRect","uint",aWnd,"uint",&rect) return true pt_x:=NumGet(lParam+0,0,"int"), pt_y:=NumGet(lParam+0,4,"int") rect_left:=NumGet(rect,0,"int"), rect_right:=NumGet(rect,8,"int") rect_top:=NumGet(rect,4,"int"), rect_bottom:=NumGet(rect,12,"int") if (pt_x >= rect_left && pt_x <= rect_right && pt_y >= rect_top && pt_y <= rect_bottom) { center_x := rect_left + (rect_right - rect_left) / 2 center_y := rect_top + (rect_bottom - rect_top) / 2 distance := Sqrt((pt_x-center_x)**2 + (pt_y-center_y)**2) update_it := !NumGet(lParam+24) if (!update_it) { rect_found_left:=NumGet(lParam+8,0,"int"), rect_found_right:=NumGet(lParam+8,8,"int") rect_found_top:=NumGet(lParam+8,4,"int"), rect_found_bottom:=NumGet(lParam+8,12,"int") if (rect_left >= rect_found_left && rect_right <= rect_found_right && rect_top >= rect_found_top && rect_bottom <= rect_found_bottom) update_it := true else if (distance < NumGet(lParam+28,0,"double") && (rect_found_left < rect_left || rect_found_right > rect_right || rect_found_top < rect_top || rect_found_bottom > rect_bottom)) update_it := true } if (update_it) { NumPut(aWnd, lParam+24) DllCall("RtlMoveMemory","uint",lParam+8,"uint",&rect,"uint",16) NumPut(distance, lParam+28, 0, "double") } } return true }
Users browsing this forum: AlFlo and 141 guests