Jump to content

Forcing two applications to open side by side


Recommended Posts

At my workplace, employees are neglecting one or the other chat messenger when they are too familiar with the other one. Both are important, because one is a live chat application for guests and one is a voip/sms apication.

I basically want to force both applications to open side by side when one or the other is being focused.

1 idea: One way i thought was to to do a check and if one program is focused/active then execute it to open the other program and have them both at a xy size on xy position. 

2 idea: Another way was to change my live chat application into one that can send sms conversations to our current numbers. That way employees can just answer them like normal sms texts...

Is there another alternative way for me to execute this and whats everyones else thought

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

well it's hard to have ideas when you don't know which or how the apps working..

your 2nd idea is a much bigger project i would say if i get you right there.

i guess we / i would need more information about it. :P 

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Link to comment
Share on other sites

  • 2 weeks later...

I had an issue with Teams where I wouldn't notice a notification - and hours would go by until eventually I get a visit at my desk. This is how I found out someone sent me a message hours ago. Teams' method for notifying you of a message is just terrible.

Not sure if this would help - but this ensures that a notification can't be missed; can be midifed for other apps hopefully. Works for my use cases.

Teams, specifically, creates a bunch of notifications windows at program start, then just hides and shows them with new params each time it wants to tell you something. Saves creating a whole mini GUI every time I guess.

Using this knowledge, I just check for existence of certain text in a tray icon.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Teams.ico
#AutoIt3Wrapper_Outfile=TeamsNotify.exe
#AutoIt3Wrapper_Res_Comment=Sam Coates
#AutoIt3Wrapper_Res_Description=Microsoft Teams Notifier
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_ProductName=Microsoft Teams Notifier
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <WindowsConstants.au3>
#include <WinAPISysWin.au3>
#include <GuiToolbar.au3>
#include <Misc.au3>

If _Singleton("TeamsNotify.exe", 1) = 0 Then
    TraySetState(2)
    MsgBox(0, "Warning", "TeamsNotify" & " is already running.")
    Exit
EndIf

Global $iExit = TrayCreateItem("Exit")
Opt("TrayMenuMode", 1)
Opt("TrayIconDebug", 1)

;#NoTrayIcon
Global $iBrightness = 50
Global $aGui = _NotificationGuiCreate()
Global $aColours = _ColourSet()
Global $iColours = UBound($aColours) - 1
Global $sTeamsAlive = "Microsoft Teams - Available"
Global $sTeamsWaiting = "Microsoft Teams - New activity"
$hTray = TraySearch($sTeamsAlive)
ConsoleWrite($hTray & @CRLF)

Main()

Func Main()

    Local $hWnd
    Local $nMsg

    While 1

        $nMsg = TrayGetMsg()
        Switch $nMsg
            Case $iExit
                Exit
        EndSwitch

        ;$hWnd = WinGetHandle("Microsoft Teams Notification")
        ;$sText = _GUICtrlToolbar_GetButtonText($hTray, $iTrayTeamsIndex)
        If TraySearch($sTeamsWaiting) <> -1 Then
            Do
                Sleep(250)
                If TrayGetMsg() = $iExit Then ExitLoop
                _ScreenFlash($aGui)
            Until TraySearch($sTeamsWaiting) = -1

        EndIf
    WEnd

EndFunc



Func TraySearch($sSearch)
    Local $hSysTray_Handle
    For $i = 1 To 99
        ; Find systray handles
        $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:' & $i & ']')
        If @error Then
            ;MsgBox(16, "Error", "System tray not found")
            ExitLoop
        EndIf

        ; Get systray item count
        Local $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
        If $iSysTray_ButCount = 0 Then
            ;MsgBox(16, "Error", "No items found in system tray")
            ContinueLoop
        EndIf

        Local $aSysTray_ButtonText[$iSysTray_ButCount]

        ; Look for wanted tooltip
        For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1
            If $sSearch = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber) Then _
                    Return SetError(0, $i, $iSysTray_ButtonNumber)
        Next
    Next
    Return SetError(1, -1, -1)

EndFunc   ;==>Get_SysTray_IconText

Func _WindowCheck($hWnd)

    If BitAND(WinGetState($hWnd), 16) <> 0 Or _
        BitAND(WinGetState($hWnd), 8) = 0 Or _
        BitAND(WinGetState($hWnd), 2) = 0 Or _
        BitAND(WinGetState($hWnd), 4) = 0 Then
        Return(SetError(-1, 0, -1))
    Else
        Return(1)
    EndIf

EndFunc

Func _NotificationGuiCreate()

    Local $aArrayGui[4]

    $aArrayGui[1] = GUICreate("", @DesktopWidth, @DesktopHeight - 40, 0, 0, $ws_popup, BitOR($ws_ex_transparent, $ws_ex_layered, $ws_ex_topmost), WinGetHandle("Program Manager"))
    WinSetOnTop($aArrayGui[1], "", 1)
    GUISetState(@SW_DISABLE, $aArrayGui[1])
    _WinAPI_SetLayeredWindowAttributes($aArrayGui[1], 0, $iBrightness)
    $aArrayGui[2] = GUICreate("", @DesktopWidth, @DesktopHeight - 40, 1920, 0, $ws_popup, BitOR($ws_ex_transparent, $ws_ex_layered, $ws_ex_topmost), WinGetHandle("Program Manager"))
    WinSetOnTop($aArrayGui[2], "", 1)
    GUISetState(@SW_DISABLE, $aArrayGui[2])
    _WinAPI_SetLayeredWindowAttributes($aArrayGui[2], 0, $iBrightness)
    $aArrayGui[3] = GUICreate("", @DesktopWidth, @DesktopHeight - 40, 1920 + 1920, 0, $ws_popup, BitOR($ws_ex_transparent, $ws_ex_layered, $ws_ex_topmost), WinGetHandle("Program Manager"))
    WinSetOnTop($aArrayGui[3], "", 1)
    GUISetState(@SW_DISABLE, $aArrayGui[3])
    _WinAPI_SetLayeredWindowAttributes($aArrayGui[3], 0, $iBrightness)

    Return($aArrayGui)

EndFunc

Func _ScreenFlash($aArrayGui)

    Local $i

    For $i = 1 To UBound($aArrayGui) - 1
        GUISetBkColor($aColours[Random(1, $iColours, 1)], $aArrayGui[$i])
        WinSetOnTop($aArrayGui[$i], "", 1)
        GUISetState(@SW_SHOWNOACTIVATE, $aArrayGui[$i])
    Next

    Sleep(150)

    For $i = 1 To UBound($aArrayGui) - 1
        GUISetState(@SW_HIDE, $aArrayGui[$i])
    Next

    Return (1)
EndFunc

Func _ColourSet()

    Local $aColours[15]

    $aColours[1] = '255'
    $aColours[2] = '45824'
    $aColours[3] = '16711680'
    $aColours[4] = '8421504'
    $aColours[5] = '0'
    $aColours[6] = '16711935'
    $aColours[7] = '65535'
    $aColours[8] = '16776960'
    $aColours[9] = '16711830'
    $aColours[10] = '2588671'
    $aColours[11] = '16711935'
    $aColours[12] = '15527148'
    $aColours[13] = '1905237'
    $aColours[14] = '9699540'

    Return($aColours)
EndFunc   ;==>_RichEditColourSet

Quick script for testing:

$bAlive = True
$iChange = TrayCreateItem("Test")
$iExit = TrayCreateItem("Exit")
Opt("TrayMenuMode", 1)
$nMsg = 0
While 1
    $nMsg = TrayGetMsg()
    Switch $nMsg
        Case $iChange
            If $bAlive = True Then
                TraySetToolTip("Microsoft Teams - New activity")
                $bAlive = False
            Else
                TraySetToolTip("Microsoft Teams - Available")
                $bAlive = True
            EndIf
        Case $iExit
            Exit
    EndSwitch
WEnd

 

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