Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

ControlClick to activate a button in a minimized/inactive window.


  • Please log in to reply
3 replies to this topic
gummby8
  • Members
  • 120 posts
  • Last active: Nov 30 2018 06:35 PM
  • Joined: 05 Jul 2009

So the easiest test of this can be seen in MSpaint, as an example. The object is to simply click a different brush style.

 

I have tried the following

 

ControlClick, X410 Y90, Untitled - Paint

ControlClick, X410 Y90, Untitled - Paint,,,1,d
sleep, 1000
ControlClick, X410 Y90, Untitled - Paint,,,1,u

I also mixed in the NA option

 

If I change the coordinantes to be inside the drawing area, it will make a dot, as if the mouse was clicked. But if I make the coordinates a button, like to change the brush type, it never clicks the button,unless the mouse pointer is over that button. 

 

Is there a different way to send a mouseclick to an inactive/minimized window that will trigger a button response?

 

EDIT: totally typoed my thread title sad.png



TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006

I'm assuming your using Paint in Windows 7

itGgKhl.jpg

 

ControlClick the Ribbon's child control (ClassNN: NetUIHWND1).
 
This demo shows how to dive into the Ribbon's child controls and click the Brushes dropdown menu

SetTitleMatchMode, 2
DetectHiddenWindows, On

ControlGet, rHwnd, Hwnd,, UIRibbonWorkPane1, Paint ; <- Get the Ribbon Handle
WinGet, ConListHwnds, ControlListHwnd, % "ahk_id " rHwnd ; <- Get a list of control handles in the Ribbon

ControlClick,, % "ahk_id" RegExReplace(ConListHwnds,".*x","0x"),,,, X344 Y112 NA ; <- RegExReplace all but the last handle

Now here's the basic approach

SetTitleMatchMode, 2
DetectHiddenWindows, On

ControlClick, NetUIHWND1, Paint,,,, X344 Y112 NA

It should work whether the window is minimized or not.

 

Important Note:

Ribbons resize as the window does so if you make the window smaller,

the target button will move outside of the coordinates. For instance:
gaduxUD.jpg


Read more on Ribbons here:
http://msdn.microsof...p/cc872782.aspx


Posted Image

don't duplicate, iterate!


gummby8
  • Members
  • 120 posts
  • Last active: Nov 30 2018 06:35 PM
  • Joined: 05 Jul 2009

That does make sence. I was using paint as an example. The actual program is a game, so I am not too sure I can find the control names, but I will have to give it a look.



TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006

ahh i c, yes games can be a little iffy with AHk sometimes.

You should definitely check the Gaming Scripts section: http://www.autohotke...orum/59-gaming/

If you can't find the solution there perhaps post in Games Support: http://www.autohotke...orum/60-gaming/


Posted Image

don't duplicate, iterate!