Sign in to follow this  
Followers 0
Ryswick

Alt F4 with ControlSend

6 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Edited by boththose

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

Share this post


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

Share this post


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.

Share this post


Link to post
Share on other sites

My point was that you should try using ControlFocus.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Because

WinClose()
isn't good enough?

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


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
Sign in to follow this  
Followers 0