Jump to content

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

ControlClick on button doesn't work when cursor is in active window



  • Please log in to reply
2 replies to this topic
pball
  • New members
  • 2 posts
  • Last active: Oct 07 2015 08:43 PM
  • Joined: 05 Oct 2015

I wrote a simple script to auto click a warning message that pops up in a program. The script functions properly but it doesn't work while the mouse cursor is in the program. When the script is running and a warning message appears the message will not go away until I move the mouse outside of the program.

 

I could probably fix this by making the script move the mouse before the controlclick and then move it back afterwards. I want to ask if this is normal behavoir before trying a work around though. Thanks

start:
WinWait, Message, OK
ifWinActive, ahk_exe prowin32.exe
{
  WinGetText, text
  if text contains OK`r`n WARNING:
  {
    ControlClick, Button1, Message, OK
  }
}
goto, start


boiler
  • Members
  • 252 posts
  • Last active: Nov 07 2015 09:39 PM
  • Joined: 04 Jun 2014
✓  Best Answer

You can try closing the window with WinClose instead of clicking the OK button.



pball
  • New members
  • 2 posts
  • Last active: Oct 07 2015 08:43 PM
  • Joined: 05 Oct 2015

Thanks for the suggestion. Using WinClose closes the window when the ControlClick didn't.