Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Can .bat Files Execute Button Commands?  (Read 17808 times)

0 Members and 1 Guest are viewing this topic.

H2O

  • Guest
Can .bat Files Execute Button Commands?
« on: May 01, 2011, 03:07:36 PM »
I was wondering if it was possible to execute button commands in a batch file. For example Alt+Enter.

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Can .bat Files Execute Button Commands?
« Reply #1 on: May 01, 2011, 11:04:49 PM »
Only way to interface with buttons etc would be to use another keyboard/mouse macro that specificially clicks on an x,y location of the screen that is executable from the command prompt by which a batch file could use the start command to trigger the button command. I use this product for my automation needs: http://www.jitbit.com/macro-recorder/  This software works great and you can compile your automation routine as a stand alone exe to do anything you want.

Linux711



    Mentor

    Thanked: 59
    • Yes
    • Programming Blog
  • Certifications: List
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Can .bat Files Execute Button Commands?
« Reply #2 on: May 01, 2011, 11:07:50 PM »
Quote
Only way to interface with buttons etc would be to use another macro that specificially clicks on an x,y location of the screen that is executable from the command prompt by which a batch file could use the start command to trigger the button command.

I think the OP was referring to buttons pressed on the keyboard.
Quote
For example Alt+Enter.


If that's the case. It only works in vbscript. Here is how you could do it.

Copy and paste into notepad and save as .vbs
Code: [Select]
Set ws = CreateObject("WScript.Shell")
ws.SendKeys "%{ENTER}"
Set ws = Nothing

Now you call it from a batch file:
Code: [Select]
@echo off
wscript /nologo whatever.vbs

If you are trying to send ALT + ENTER to the command prompt in order to full screen it, it won't work. It's a Microsoft bug. It will work for any other program though. If you need to maximize the command prompt inside batch, there is a way. Just post back if that's what you are trying to do.
YouTube

"Genius is persistence, not brain power." - Me

"Insomnia is just a byproduct of, "It can't be done"" - LaVolpe

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Can .bat Files Execute Button Commands?
« Reply #3 on: May 01, 2011, 11:23:37 PM »
I was thinking that they were referring to a button in a GUI environment in which a button alt+enter event would be contained to only happening within the batched command shell itself when if its to control something outside the batch I cant see any way of doing it without the way that I suggested or other similar method of a keyboard/mouse macro.

Linux711



    Mentor

    Thanked: 59
    • Yes
    • Programming Blog
  • Certifications: List
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Can .bat Files Execute Button Commands?
« Reply #4 on: May 01, 2011, 11:35:18 PM »
Quote
button alt+enter event would be contained to only happening within the batched command shell itself when if its to control something outside the batch

The method I posted should be able to control other programs after they are started from the batch.
YouTube

"Genius is persistence, not brain power." - Me

"Insomnia is just a byproduct of, "It can't be done"" - LaVolpe

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Can .bat Files Execute Button Commands?
« Reply #5 on: May 01, 2011, 11:43:20 PM »
Cool... so based on the window focus then after starting them with START within batch so the batch shell window is then not the focus.. Interesting!

Linux711



    Mentor

    Thanked: 59
    • Yes
    • Programming Blog
  • Certifications: List
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Can .bat Files Execute Button Commands?
« Reply #6 on: May 01, 2011, 11:52:48 PM »
Right, it wouldn't be the focus because they are trying to send keys to the other program. I interpreted the question that they were looking for a way to use sendkeys in batch.
YouTube

"Genius is persistence, not brain power." - Me

"Insomnia is just a byproduct of, "It can't be done"" - LaVolpe