Page 1 of 1

How to push a button on another program programatically?

Posted: Wed Mar 01, 2023 9:19 am
by Caronte3D
Hi! :D
I need to press the button on the windows 10 speech recognition window because that speech recognition starts in suspended mode
Image
I tryed the code below but no luck.
Any ideas of pushing that button or activate the voice recognition from the popup menu programatically?

Thanks!

Code: Select all

Procedure PushButtonOnVoiceRecognition()
  Define mb
  Define pos.RECT
  
  mb = FindWindow_(@"MS:SpeechTopLevel", 0)
  
  GetWindowRect_(mb, @pos)  
  
  SetCursorPos_(pos\left + 35, pos\top + 25)
  
  mouse_event_(#MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
  Sleep_(60)
  mouse_event_(#MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
  
EndProcedure

Re: How to push a button on another program programatically?

Posted: Wed Mar 01, 2023 10:56 am
by BarryG
Needs your app to run as admin, then it works. Probably a security precaution.

Re: How to push a button on another program programatically?

Posted: Wed Mar 01, 2023 11:03 am
by Caronte3D
BarryG wrote: Wed Mar 01, 2023 10:56 am Needs your app to run as admin, then it works. Probably a security precaution.
Ah! Ok! :D
Thanks BarryG :wink: