Jump to content

Alt F4 with ControlSend


Recommended Posts

Hello everyone,

I searched for this topic, but didn't find anything.

I am using ControlSend to send commands to a window, and it works great until I ask it to Alt F4 out of the window.

It looks something like this:

ControlSend("COM2", "", "", "!+{F4}")

Instead of sending the Alt F4 command to the COM2 window, it sends it to the active window instead.

Is there an argument or flag I need to specify?

Link to post
Share on other sites

Opt("WinTitleMatchMode", 2)
 
winactivate("Window that contains COM2")
 
winwaitactive("Window that contains COM2")
 
send ("!{F4}")

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to post
Share on other sites

ControlSend("COM2", "", "", "!+{F4}")

!+{F4} is Alt + Shift + F4, not Alt + F4.

Does ControlFocus help?

The same behavior you described is exhibited in the following example without it.

Run('notepad')
Run('explorer /root,')
WinWaitActive('Untitled')
WinWaitActive('Computer')
ControlFocus('Untitled', '', 'Edit1') 
ControlSend('Untitled', '', 'Edit1', '!{F4}')
Exit
Link to post
Share on other sites

My error on the !+{F4}. I should have realized it was incorrect. It still did its job though.

So I take it alt commands don't work with CommandSend? Is focusing the window and then sending the alt f4 command a work-around or the only way?

Thanks for the replies though, you two.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...