Jump to content

SendKeepActive loses focus


trbn
 Share

Recommended Posts

Hello,

when using Autoit function "SendKeepActive" in combination with repated single character Send, AutoIt loses focus if I click on the desktop or another window.

Can anyone reproduce this behaviour? Or is this a bug? I'm on "Win Server 2008 R2 Standard". Example Code is attached. Function "_SingleCharRepeat_Fails" produces the failure. Function "_NO_SingleCharRepeat_Works" works as expected.

 

Thank You

 

SendKeepActive_loses_focus.au3

Link to comment
Share on other sites

4 minutes ago, trbn said:

Hello,

when using Autoit function "SendKeepActive" in combination with repated single character Send, AutoIt loses focus if I click on the desktop or another window.

Can anyone reproduce this behaviour? Or is this a bug? I'm on "Win Server 2008 R2 Standard". Example Code is attached. Function "_SingleCharRepeat_Fails" produces the failure. Function "_NO_SingleCharRepeat_Works" works as expected.

Thank You

SendKeepActive_loses_focus.au3

Quote

 

...
If (SendKeepActive("[CLASS:Notepad]")) Then
        $OldDelay = Opt("SendKeyDelay", 50)
        Send("{a 50}")                          ; <--- Fails, when I click on desktop or another window while script runs
        Opt("SendKeyDelay", $OldDelay)
EndIf

______________________________________


If (SendKeepActive("[CLASS:Notepad]")) Then
    $OldDelay = Opt("SendKeyDelay", 50)
    Send("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")   ; Works as expected, even if I click on the desktop while script runs
    Opt("SendKeyDelay", $OldDelay)
EndIf

 

Link to comment
Share on other sites

why did you quote yourself?

why the "if" with sendkeepactive?

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Sorry,  I quoted myself by mistake.

 

Why not "if" with sendkeepactive? But thanks to your question, I noticed my given code example wasn't complete.

 

It should have look like this:

If (SendKeepActive("[CLASS:Notepad]")) Then
    $OldDelay = Opt("SendKeyDelay", 50)
    Send("{a 50}")
    Opt("SendKeyDelay", $OldDelay)
    SendKeepActive("")
Else
    ; Sum-Ting WenWong
EndIf

 

But it still loses focus (when I click on the Desktop or elsewhere).

 

Even if I do this:

 

SendKeepActive("[CLASS:Notepad]")
$OldDelay = Opt("SendKeyDelay", 50)
Send("{a 50}")
Opt("SendKeyDelay", $OldDelay)
SendKeepActive("")

It loses focus (when I click on the Desktop or elsewhere).

 

When I change this line

Send("{a 50}")

to

Send("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

Then it works.

 

Can you repdroduce this behaviour.

 

Thank you for taking the time

Link to comment
Share on other sites

Nope, it works here with both the provided codes

As for the:

If (SendKeepActive("[CLASS:Notepad]")) Then

I just never seen that function coupled with an If, but it works yes

You could use a winactivate with the rest of the code and see how it goes.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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