How to push a button on another program programatically?

Windows specific forum
User avatar
Caronte3D
Addict
Addict
Posts: 1361
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

How to push a button on another program programatically?

Post 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
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

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

Post by BarryG »

Needs your app to run as admin, then it works. Probably a security precaution.
User avatar
Caronte3D
Addict
Addict
Posts: 1361
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

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

Post 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:
Post Reply