Sign in to follow this  
Followers 0
tgould

Window activated when it should not be.

7 posts in this topic

#1 ·  Posted (edited)

Hello,

I am new to the forum.

I have a script that will activate a drop down list box in an application, move down to the proper selection and hit enter when 1 of 6 function keys is pressed. The script does nothing else. This is working well. However, I do not want the window of said application to be activated before I hit a function key (while the application is sleeping in a loop.)

When an event occurs in said application AND I am not runnning any AutoIt script, the application is not activated and any window I am currently on stays in the front. However, if I run my script, or any AutoIt Script for that matter, an event in the application brings the window to the front and makes it active even though I have not hit any keys. This only happens when I run an AutoIt Script. I need to be able to stop this behavior.

Thank you for any suggestions or help.

;
; AutoIt Version: 3.0
; Language:    English
; Platform:    WinXP/7
;
; Script Function:
;   Runs int he background an monitors for F5 through F11 key presses.
;   Will automatically activate the VCC Agnet application, then set
; the corresponding disposition.  F5 = First dispo to F11 = 7th dispo.
;
; Press Esc to terminate script, Pause/Break to "pause"
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d
HotKeySet("{F5}", "DispoF5")
HotKeySet("{F6}", "DispoF6")
HotKeySet("{F7}", "DispoF7")
HotKeySet("{F8}", "DispoF8")
;HotKeySet("{F9}", "DispoF9")
;HotKeySet("{F10}", "DispoF10")
;HotKeySet("{F11}", "DispoF11")

;;;; Body of program is just a loop to run in the background;
While 1
    Sleep(100)
WEnd
;;;;

; Pause Function: Pressing Pause will pause the script and function key presses will have no effect.
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

; Terminate Function: Pressing Escape with end the script.
Func Terminate()
    Exit 0
EndFunc

; ShowMessage Function: Pressing Shift-Alt-d will show information about the script.
Func ShowMessage()
    MsgBox(4096,"","VCCSetDispo")
EndFunc

; SetDispo Function: will activate VCC Agent and set passed disposition number.
Func SetDispo($dispoNum)
; Get the Current VCC Agent Window Name
$vccWnd = WinGetHandle("VCC Agent")
; Activate the VCC Agent window
WinActivate($vccWnd)
; Set dispositon based on the number passed to the function.
$downNum = "{DOWN " & $dispoNum & "}"
Send("^d")
Send($downNum)
Send("{ENTER}")

; Get the Current Echo Window Name
$echoWnd = WinGetHandle("Reflect")
; Activate the Echo Window
WinActivate($echoWnd)
EndFunc

; The following 7 functions are needed since a key press can not send parameters to a function.
Func DispoF5()
SetDispo("4")
EndFunc
Func DispoF6()
SetDispo("1")
EndFunc
Func DispoF7()
SetDispo("3")
EndFunc
Func DispoF8()
SetDispo("2")
EndFunc
Func DispoF9()
SetDispo("5")
EndFunc
Func DispoF10()
SetDispo("6")
EndFunc
Func DispoF11()
SetDispo("7")
EndFunc
; Finished!
Edited by tgould

Share this post


Link to post
Share on other sites



The WinActivate command brings the application to the front. I you want to send keys to the application without bringing it to the front, then use the "AutoIt Window Info" tool to identify the control that is accepting the input, and use ControlSend to send the keys.

Share this post


Link to post
Share on other sites

Thanks for the quick reply.

The WinActivate command is only called from inside a function that is only called when I hit a defined HotKeyPress. Therefore unless I hit one of those keys it should never be called. I am saying that the window gets activated when there is no key pressed, meaning that the script is in the while 1 sleep loop above.

Are you saying that there is some known behavior I should be aware of?

Many Thanks.

Share this post


Link to post
Share on other sites

Sorry, I was unclear on the situation described. What window is coming to the front?

Are there any other applications or scripts running that might be generating the captured key presses?

Share this post


Link to post
Share on other sites

The application (VCC Agent) that I am manipulating with AutoIt is coming to the front without hitting any keys. I am 99% sure there is no application that could be generating the function key presses. I can create a screencast of this behavior if you like so you can see what it is doing.

The VCC Agent is a Call Center Agent Application that recieves calls. When a call is delivered, I have the application set to not activate the window. This works perfectly when AutoIt is not running, When I run ANY AutoIt script (even one with just a loop in it) the VCC Agent will come to the front when a call is delivered. I am wondering if AutoIT and VCC Agent make use of some similar windows or Java dll and this is causing the behavior.

Thanks,

Todd

Share this post


Link to post
Share on other sites

You say "When a call is delivered, I have the application set to not activate the window."

Are there any settings within the application which you do set the window to activate?

Yes. The VCC Agent application has setting to bring the application to the front upon call delivery. This is unchecked.

I have tested this all possible ways.

1 bring the application to the front upon call delivery Checked (On) and no AutoIt script running on the machine. Result upon call delivery: VCC Agent is brought to the front when a call is delivered. (Correct behavoir)

2 bring the application to the front upon call delivery Unchecked (Off) and no AutoIt script running on the machine. Result upon call delivery: VCC Agent is NOT brought to the front when a call is delivered. (Correct behavoir)

3 bring the application to the front upon call delivery Checked (On) and ANY AutoIt script running on the machine. Result upon call delivery: VCC Agent is brought to the front when a call is delivered. (Correct behavoir)

4 bring the application to the front upon call delivery Unchecked (Off) and ANY AutoIt script running on the machine. Result upon call delivery: VCC Agent is brought to the front when a call is delivered. (Incorrect behavoir)

I have not seen any other software that causes the same issue in VCC Agent. The issue may be in AutoIt or it may be in the way VCC Agent implements that feature. Any Ideas?

Thanks,

Todd

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