Jump to content

SendKeepActive does not properly send keystrokes?


Recommended Posts

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?

Link to comment
Share on other sites

  • 2 months later...

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.”

 

Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...