0
votes

Here is what I'm trying to do and would greatly appreciate any help here.

I am trying to automate maximizing the live conversation window in skype with an Autohotkey script. I'm trying to make it so I can call into a remote machine using skype and have it auto answer (this is native in skype)...once I have a live conversation window I would like to maximize the live conversation window to fill the screen.

I've given this a shot but somehow don't think that I have the correct ahk_class for the live conversation window but there may be something else I am missing. I've placed a the code I've tried using below...any help would be great.

#NoEnv  ; Recommended for performance and compatibility with future     AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#Persistent

IfWinExist, TLiveConversationWindow ;
{
WinActivate
WinMaximize
send !{Enter};When using skype normally this Alt+Enter will maximize the window
return
}

I also tried to use this code to determine the proper class for the live conversation window...but has not helped as of yet.

Alt & Enter::
IfWinExist, TLiveConversationWindow
WinActivate
ControlFocus, ClassNN TLiveConversation1
ControlClick, ClassNN TLiveConversation1, , , , 2, 
MouseClick, left, , , 2
send !{Enter}
; now we get the ID & CLASS
WinGet, Active_Window_ID, ID, A
WinGetClass, Active_Window_Class, A
MsgBox, The active window's class is "%Active_Window_class%" and ID is %Active_Window_ID%

Was able to get a simplified version of the code to work with a hotkey to initiate but have not been able to get the WinWait function to work as per @Schneyer.

Functioning Code activated by hotkey

#NoEnv
#Warn
#Persistent
SendMode Input
SetWorkingDir %A_ScriptDir%

; Skype Maximizer initiating functions
^!p::
;WinWait ahk_class TLiveConversation1
;WinWait ahk_class TConversationForm
;WinWait ahk_class TLiveConversationWindow
;WinMaximize ahk_class TLiveConversation1

;functioning code
;Activate tSkMainForm.
WinActivate ahk_class tSkMainForm

;Send Alt Enter Input to maximize.
SendInput !{Enter}

;TLiveConversationWindow Always On Top
WinSet, AlwaysOnTop,,ahk_class TLiveConversationWindow

;Minimize main form
WinMinimize ahk_class tSkMainForm

Return

When swapping the ^!p:: with any of the WinWait Functions nothing seems to happen. The WinWait seems like it should be the proper method, any thoughts on why it won't work?

2
WHAT is it that isn't working? to which line can you narrow down the problem?phil294
As far as I can tell the part that is not working is the recognition of the proper class for the LiveConversationWindow. I've tried the following ahk_class LiveConversationWindow ahk_class TLiveConversation1 (which shows up as a ClassNN of the ahk_class tSkMainForm from the inspector) I've done this using the code given by @Schneyer below and shown following his comment below.Chardho

2 Answers

0
votes

Problems

#persistent lets the script run, but your code still gets executed only once when you start the script. After that it stays active but does nothing. Use a WinWait to wait for the window to appear (wrap it in a Loop if you want it to run more than once).

Use ahk_class to to search for a window class instead of the window title

Working code

You can use the Window Spy tool which is included in AHK. Use the tray icon menu of a running AHK script to start it.

I use TConversationForm in the code, but it works with every window class.

#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%

WinWait ahk_class TConversationForm
WinActivate
WinMaximize
0
votes

Scanning through AHK forums I was able to find a post that led me to the answer for this little problem. Check the below link for further information.

https://autohotkey.com/board/topic/96491-detect-when-a-classnn-window-exists/

The problem with using ahk_class to identify when a skype call was active is that the "active call window" identified as classNN TLiveConversation1 in the inspector was actually a Control within the window of ahk_class tSkMainForm rather than a Window. This made the WinWait function ineffective at identifying it when the call initiated.

In order to identify the Control it is necessary to loop through the controls (using WinGet) in ahk_class tSkMainForm until the TLiveConversation exists and then kick off any subroutines needed. For me that was to maximize the live conversation window.

You'll see the code to do this starting with the WinGet function. All of this is wrapped in a while loop so that it will run persistently allowing it to be called over and over. In essence this code will do the following:

  1. Create a list (SkypeControlList) of controls existing in ahk_class tSkMainForm.
  2. Continually Loop Through SkypeControlList
  3. When a new Live Conversation is initiated a control TLiveConversation1 will exist
  4. Once TLiveConversation1 esists run necessary code
#NoEnv 
#Warn 
#Persistent
SendMode Event
SetWorkingDir %A_ScriptDir%

DetectHiddenWindows, on

stop = 0
Loop
{

While stop = 0
{

    WinGet, SkypeControlList, ControlList, ahk_class tSkMainForm
    Loop, Parse,SkypeControlList, `n
    {
        ;Loop to search for control TLiveConversation1
        if (A_LoopField = "TLiveConversation1")
        {

        ;Deactivate active screensaver
        PostMessage, 0x0112, 0x0F060, 0,, A
        ;RegWrite REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, ScreenSaveActive, 0
        ;SetKeyDelay, 500
        Send {Esc}


        ;Activate tSkMainForm.
        WinActivate ahk_class tSkMainForm


        ;Send Alt Enter Input to maximize.
        Send !{Enter}

        ;TLiveConversationWindow Always On Top
        WinSet, AlwaysOnTop,,ahk_class TLiveConversationWindow


        stop = 1
        sleep, 100
        }           
    }
}

IfWinExist ahk_class TLiveConversationWindow
    {
    stop = 1
    sleep, 1000
    }
IfWinNotExist ahk_class TLiveConversationWindow
    {
    ;Minimize all windows by win+D show desktop
    send #d
    sleep,1000


    ; is that call quality feedback window up?  kill it.
    SetTitleMatchMode, Regex
    WinClose, ^Skype.*Call quality feedback$

    stop = 0
    }
sleep 1000


}
Return

The above code works great as long as there is no screen saver active on the machine being called. If there is an active screen saver the call will answer but the screen saver will not go away. You can see remnants of code trying to wake the computer from a screen saver (This does not currently work).

I've also added a few bits of code to clean up the experience such as removing the call quality popup window that skype throws up after a call as well as clearing the desktop after the call ends.

Thanks to @Blauhirn and @Schneyer for their input in trying to get this solved.