Search the Community
Showing results for tags 'window activation'.
-
Hello together, I am searching for hours in the web and this forum too but no articles helps really. Issue: In the background Thunderbird is running and receives mails and fax (as PDF mails). If a specific mail will be received and the rules detect this mail an external program will be executed. The external program is the AutoIt script. Execution will be okay but the result is not okay: If the button $btnShowMailProg is pressed: The Thunderbird should appear to show the important mail. ==> This is the problem. I have tried several times and different code examples but Thunderbird will not be shown in the front. Who can help me or show a code example which shows an already in background running program active again in the foreground? Thanks in advance for your help. Matthias Sorry, the GUI is for a german office usage and therefore the text messages are in german. But this doesn't matter for the asked issue. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> $Form1_1 = GUICreate("BENACHRICHTIGUNG: Wichiges FAX eingegangen", 422, 220, -1, -1,$WS_EX_TOPMOST) $Label1 = GUICtrlCreateLabel("Diese Benachrichtigung wird angezeigt, weil die Filter-Regeln", 24, 18, 390, 17) GUICtrlSetFont(-1, 10, 400 , 0, "Arial") $Label2 = GUICtrlCreateLabel("im Email-Programm den Eingang eines wichtigen FAX oder", 24, 38, 390, 17) GUICtrlSetFont(-1, 10, 400 , 0, "Arial") $Label3 = GUICtrlCreateLabel("einer wichtigen EMAIL festgestellt haben.", 24, 58, 390, 17) GUICtrlSetFont(-1, 10, 400 , 0, "Arial") $btnShowMailProg = GUICtrlCreateButton("Email-Programm in den Vordergrund bringen", 24, 92, 355, 33, 0) GUICtrlSetFont(-1, 10, 700 , 0, "Arial") $btnClose = GUICtrlCreateButton("Dieses Fenster schließen", 24, 135, 203, 41, 0) GUISetState(@SW_SHOW) $hWnd = WinGetHandle("[ACTIVE]") WinSetOnTop($hWnd, "", $WINDOWS_ONTOP) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnClose Exit case $btnShowMailProg if ProcessExists("thunderbird.exe") Then $hWnd2 = ProcessExists("thunderbird.exe") WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP ) GUISetState(@SW_HIDE) $return0 = WinActivate($hWnd2) $return1 = WinSetState($hWnd2, "", @SW_MAXIMIZE) $return2 = WinSetState($hWnd2, "", @SW_SHOW) MsgBox (0, "DEBUG-Info", "$hWnd2=" & $hWnd2 & @CRLF & "$return0=" & $return0 & @CRLF & "$return1=" & $return1 & @CRLF & "$return2=" & $return2 ) If Not WinActive($hWnd2) Then MsgBox (0, "DEBUG-Info", "Thunderbird manuell öffnen!" ) Run("thunderbird.exe") WinActivate($hWnd2) WinSetState($hWnd2, "", @SW_MAXIMIZE) WinSetState($hWnd2, "", @SW_SHOW) EndIf MsgBox (0,"INFO","Programm wird beendet.") Else MsgBox (0, "DEBUG-Info", "Thunderbird manuell öffnen!" ) EndIf Exit EndSwitch WEnd Exit