Press ENTER in a program via .bat file

I want to start WhatsApp and send message with a .bat file. I will run this .bat file via another program. I haven't used a .bat file before so I don't know anything about it. I just wrote this :

start chrome "".

This starts WhatsApp but couldn't send message because it needs pressing ENTER. Can you help me please? thanks.

5

1 Answer

<!-- ::
@echo off & start "" /b chrome ""
"%__AppDir__%WScript.exe" "%~dpnx0?.wsf" && goto :EOF || rem :: -->
<job><script language="vbscript">Set objShell=WScript.CreateObject("WScript.Shell")
objShell.AppActivate "chrome.exe" : WScript.Sleep 1000
For x = 1 To 8 WScript.Sleep 200 : objShell.SendKeys "{TAB}"
Next
WScript.Sleep 1000 : objShell.SendKeys "Hey, how are you?~" : WScript.Sleep 1000 : objShell.SendKeys "~" </script></job>

1. You may need to add VBS in your bat file...

2. Some adjustments for navigation via keys may be necessary to adjust when in use for App/Web interfaces

3. You may also need to adjust the timeout according to the interface in use


$wshell = New-Object -ComObject wscript.shell
Start-Process "chrome.exe" ""
sleep -m 600 ; $wshell.AppActivate('Share on WhatsApp') ; Start-Sleep -m 200
1..8 | % {; sleep -m 300 ; [System.Windows.Forms.SendKeys]::SendWait("{TAB}")}
[System.Windows.Forms.SendKeys]::SendWait('~') ; sleep -m 500
[System.Windows.Forms.SendKeys]::SendWait('Hey, how are you?~')


Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like