Sign in to follow this  
Followers 0
olegsomphane

SendKeepActive does not properly send keystrokes?

4 posts in this topic

I am having a problem with SendKeepActive where it does not properly send keystrokes. The problem is with GIMP: when the program loads, the script attempts to create a new image file with ctrl+n:

SendKeepActive("GNU Image","")

Send("{CTRLDOWN}n{CTRLUP}")

I can observe that when these lines execute, the Gimp window blinks (focused state, non-focused state, focused state) and I do not see a new image window.

When GIMP is started, the focus is on the GNU Image ... (main GIMP window), but the mouse is hovering over the GIMP tools window and is displaying the text tooltip.

If I go over these steps by hand, the new image window does show up.

If I also comment out the SendKeepActive line, the script also works correctly.

If I change Send("{CTRLDOWN}n{CTRLUP}") to Send("^n"), the script also works correctly.

If I move the mouse away from the tools window when those lines execute, the script also works correctly.

My SendKeyDelay is set to 100.

Does anyone know what the problem is?

Share this post


Link to post
Share on other sites



I fail with Send() when I type latin letters, but it works good when I use Cyrillic. So I think it depends on the Windows language or keyboard set

Share this post


Link to post
Share on other sites

i know this is dated, but if removing SendKeepActive() allows your Send() to work, then the window that you are declaring in SendKeepActive() may not be correct. Many times window titles will change based on what file is accessible (i.e. "GNU Image - C:UsersuserDesktopimage.pst").

Put

Opt("WinTitleMatchMode", 2)
in the beginning of your code to do a sort of String-In-String search for the window title, basically it does a partial match of the title. So as long as "GNU Image" exists somewhere in the window title, it will be targeted. Just make sure there are no other windows that will be open at the same time with the same title substring.

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

I would suggest trying either ControlSend or WinMenuSelectItem, rather than Send, for more stable results. Then you don't have to worry about SendKeepActive.


√-1 2^3 ∑ π, and it was delicious!

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