Sign in to follow this  
Followers 0
gte

Problems with controlsend and minimized or non active windows

2 posts in this topic

I cannot get controlsend to properly send a command/key combo to a program that is not the active window. It half works.

If I put the program in the foreground in my second monitor, but have another window as the active window, I can see controlsend try and send the keystroke "!p" because the menu items flash very quickly, especially if I have it loop, but it does not work properly and expand the menu downward then wait for the next keystroke, like when I have it in the foreground/active.

When it is in the active window, the options menu drops down and holds steady like it should (see screen capture), until I hit another key or click somewhere. If I hit the "r" key at this point, it refreshes the softwares screen.

Any ideas why this is happening?

Posted Image

This is the way that should work

#include <GUIConstantsEx.au3>
#include <Timers.au3>

Opt("WinTitleMatchMode", 1)
Opt("SendKeyDelay", 50)

While 1

If ProcessExists('scguiw32.exe') Then


    
    If _Timer_GetIdleTime () <= "5000" Then
        Sleep(2000)
        
    Else
    
    
    ControlSend("ServiceCenter ", "", "xSC4550child05", "!P")
    
    ControlSend("ServiceCenter ", "Incident Queue: ", "xSC4550child05", "r")
    Sleep(5000)

    
    
    EndIf


    


Else
    
    Sleep(15000)
    
EndIf

This way works because I restore/minimize it

#include <GUIConstantsEx.au3>
#include <Timers.au3>

Opt("WinTitleMatchMode", 1)
Opt("SendKeyDelay", 50)

While 1

If ProcessExists('scguiw32.exe') Then


    
    If _Timer_GetIdleTime () <= "5000" Then
        Sleep(2000)
        
    Else
    
    WinActivate("ServiceCenter", "Incident Queue:") 
    WinWaitActive("ServiceCenter ")

    
    ControlSend("ServiceCenter ", "", "xSC4550child05", "!P")
    
    ControlSend("ServiceCenter ", "Incident Queue: ", "xSC4550child05", "r")
    Sleep(5000)
    WinSetState("ServiceCenter - ","",@SW_MINIMIZE)
    Sleep(1000)
    

    
    
    EndIf


    


Else
    
    Sleep(15000)
    
EndIf

WEnd

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