Activate Window and Send Double-Click

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

Activate Window and Send Double-Click

01 Jan 2019, 15:27

In my script, I need to activate a window and send a double click (to select a word in a text editor).
So I put this code into the QuickCodeEditor.
Try it!
When I push run, it activates the window, then returns focus to QuickCodeEditor. It shouldn't do that.
And it doesn't seem to send double-click.
It seems like it activates the window and clicks once (I think).
Anyway, I can't get this to work. What can I do?
The ahk_id is of a Notepad3 window.

Code: Select all

;setdefaultmousespeed 1   ;I tried this but it doesn't make any difference
winactivate ahk_id 0x131d7a
;click,2
sendevent {click 2}
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Activate Window and Send Double-Click

01 Jan 2019, 15:55

Click,Send,or the other Send events are just clicking sending to the current mouse position.
If the mouse is over your window even when it is active,it will execute double click over it.

You can use for example ControlClick to click over the window even if the mouse is not over it.
If you want to click on a specific position,you can use
CoordMode,Mouse,Window ; or Caret
MouseClick, WhichButton, X, Y, ClickCount
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

Re: Activate Window and Send Double-Click

01 Jan 2019, 23:14

This, maybe?

So, I want to activate the window, get the position of the caret, and double-click there...
This doesn't do it, though.

Code: Select all

winactivate ahk_id 0x131d7a
CoordMode,Mouse,caret	
MouseClick, left, X%a_caretx%, Y%a_carety%, 2
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Activate Window and Send Double-Click

02 Jan 2019, 08:46

Try this.

Code: Select all

q:: ;double-click at caret position
CoordMode, Mouse, Window
;MouseMove, % A_CaretX, % A_CaretY
MouseClick,, % A_CaretX, % A_CaretY, 2
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], sharonhuston and 227 guests