Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two windows open and not minimized (Autoit help and RelianceNetconnect). And the current focus is with a Notepad file. This is my Autoit script :

DIM $s=WinActivate("AutoIt Help")
MsgBox(0,"Check",$s)

This works and the autoit jelp window come to focus. The Message Box prints this 0x00046ce.

This is my second Autoit Script:

DIM $s=WinActivate("Reliance Netconnect")
MsgBox(0,"Check",$s)

This does not work, i.e the reliance netconnect window does not come to focus. The MessageBos Prints 0x002C01DC.
This link says that WinActivate either returns the handle to the window requested if successful or returns 0 if failed.
In my second case it returns a non zero value. Then why is the window not getting focused?

share|improve this question
    
I'd only like to mention that 2C01DC is the handle. –  Colyn1337 Oct 11 '13 at 17:46
add comment

1 Answer

up vote 2 down vote accepted

The problem was that "Reliance Netconnect" was a System tray Application i.e it resided in the system tray. You cannot use WinActivate to get their focus. they have to be redrawn. This worked for me

#Include <GuiToolBar.au3>
#include "SysTray_UDF.au3"
WinSetState("Reliance Netconnect" ,"",@SW_RESTORE)
DIM $index=_SysTrayIconIndex("Reliance Netconnect", 1)
;MsgBox(1,"index",$index)
_GUICtrlToolbar_ClickIndex(ControlGetHandle('[CLASS:Shell_TrayWnd]','','ToolbarWindow321'), $index, "left",False,2)
WinActivate("Reliance Netconnect")
WinWaitActive("Reliance Netconnect")
send("{ENTER}")
send("!c")
WinSetState("Reliance Netconnect" ,"",@SW_MINIMIZE)

You can download SYSTRAY_UDF from here . If you get previously declared as a 'Const' errors change SysTray_UDF.au3 first lines to :

;~ Const $TB_DELETEBUTTON = 1046
;~ Const $TB_GETBUTTON = 1047
;~ Const $TB_BUTTONCOUNT = 1048
Const $TB_GETBUTTONTEXT = 1099
Const $TB_GETBUTTONINFO = 1089
;~ Const $TB_HIDEBUTTON = 1028 ; WM_USER +4
;~ Const $TB_GETITEMRECT = 1053
;~ Const $TB_MOVEBUTTON = 1106 ; WM_USER +82
Const $WM_GETTEXT = 13 ; Included in GUIConstants
;~ Const $PROCESS_ALL_ACCESS = 2035711
Const $NO_TITLE = "---No title---" ; text that is used when icon window has no title
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.