Hi,
hab ein kleines Problem mit folgendem Skript. Wenn ich es über den Skript Editor starte funktioniert er Einwand frei.
Sobald ich es in eine Exe kompiliere und ausführe stürzt es einfach nach Zeile 124 (dem DllCall) ohne Meldung ab.
Hoffe Ihr könnt mir helfen.
Spoiler anzeigen
#include <GUIConstants.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
#ce ----------------------------------------------------------------------------
Opt("TrayIconDebug", 1)
[/autoit] [autoit][/autoit] [autoit];=========================================================================================================================
;Kommandozeilenparameter prüfen und Variablen setzen
Global $v_GuiName = 'Outlook Start-Assistent'
$a_outlook_profiles = _ArrayCreate('')
$v_def_profile = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles', 'DefaultProfile')
$v_Outlook_Home = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE', 'Path')
For $i = 1 to 10
$var = RegEnumKey('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles', $i)
If @error <> 0 Then ExitLoop
If RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\' & $var & '\13dbb0c8aa05101a9bb000aa002fc45a', '001e6750') <> '' Then
If $var = $v_def_profile Then $var = $var & ' (Default)'
_ArrayAdd($a_outlook_profiles, $var)
EndIf
Next
;~ #################################################################################
;~ Gui1
$gui_high = 170
If UBound($a_outlook_profiles) > 2 Then $gui_high = $gui_high + (20 * (UBound($a_outlook_profiles) - 2 ))
If $gui_high > 600 Then $gui_high = 600
$Gui1 = GUICreate($v_GuiName, 260, $gui_high, -1, -1, -1)
$l_Gui1 = GUICtrlCreateLabel('Folgende Profile sind konfiguriert.' & @CRLF & 'Wählen Sie eine zum start von Outlook aus.', 30, 10)
Global $radio[UBound($a_outlook_profiles)]
Global $high = 30
For $i = 1 To UBound($a_outlook_profiles) - 1
$high = $high + 20
$radio[$i] = GUICtrlCreateRadio($a_outlook_profiles[$i], 30, $high, 120, 20)
If StringInStr($a_outlook_profiles[$i], ' (Default)') Then GUICtrlSetState($radio[$i], $GUI_CHECKED)
Next
$l_Parameter = GUICtrlCreateLabel('Parameter:', 10, $high + 33, 50, 20)
$ib_Parameter = GUICtrlCreateInput('', 65, $high + 30, 155, 20)
$b_Parameter_List = GUICtrlCreateButton('...', 225, $high + 30, 20, 20)
$b_outlook_start = GUICtrlCreateButton('Profil starten', 15, $high + 60, 230, 20)
[/autoit] [autoit][/autoit] [autoit]$schliessen = GUICtrlCreateButton("Schließen", 95, $high + 90, 70, 20)
[/autoit] [autoit][/autoit] [autoit]GUISetState(@SW_SHOW, $Gui1)
[/autoit] [autoit][/autoit] [autoit]While 1
$msg = GUIGetMsg()
Switch $msg
Case $b_Parameter_List
Run('notepad.exe ParameterAll.txt', @ScriptDir, @SW_SHOW)
Case $b_outlook_start
If ProcessExists('OUTLOOK.EXE') Then
SplashTextOn('Outlook', 'Outlook wird neu gestartet.' & @CRLF & 'Bitte warten...', 300, 50, -1, -1, 34, '', 11)
Else
SplashTextOn('Outlook', 'Outlook wird gestartet.' & @CRLF & 'Bitte warten...', 300, 50, -1, -1, 34, '', 11)
EndIf
ProcessQuit('OUTLOOK.EXE')
Sleep(3000)
While ProcessExists('OUTLOOK.EXE')
ProcessClose('OUTLOOK.EXE')
Sleep(2000)
WEnd
For $i = 1 To UBound($a_outlook_profiles) - 1
If GUICtrlRead($radio[$i]) = 1 Then $v_start_profile = $a_outlook_profiles[$i]
Next
MsgBox(0, '', $v_start_profile)
If StringInStr($v_start_profile, ' (Default)') Then
Run($v_Outlook_Home & 'OUTLOOK.EXE ' & GUICtrlRead($ib_Parameter))
Else
Run($v_Outlook_Home & 'OUTLOOK.EXE /Profile "' & $v_start_profile & '" ' & GUICtrlRead($ib_Parameter))
EndIf
SplashOff()
Case $GUI_EVENT_CLOSE, $schliessen
Exit
EndSwitch
WEnd
Func ProcessGetWindows($PId)
$PId = ProcessExists($PId)
If $PId = 0 Then
SetError(1)
Else
Local $WinList = WinList()
Local $WindowTitle[1][2]
Local $x = 0
For $i = 1 To $WinList[0][0]
If WinGetProcess($WinList[$i][1], "") = $PId And $WinList[$i][0] <> ""Then
ReDim $WindowTitle[$x+1][2]
$WindowTitle[$x][0] = $WinList[$i][0]
$WindowTitle[$x][1] = $WinList[$i][1]
$x += 1
EndIf
Next
Return $WindowTitle
EndIf
EndFunc
Func ProcessQuit($filename)
$Return=0
$a = ProcessList($filename)
For $i = 1 To UBound($a) - 1
$Return = ProcessGetWindows($a[$i][1])
Next
If($Return==0) Then
Return
EndIf
DllCall("User32.dll", "int", "PostMessageA", "hwnd", $Return[0][1], "int", $WM_QUIT, "int", "", "int", "")
EndFunc