;-Begin-----------------------------------------------------------------
;-Directives----------------------------------------------------------
AutoItSetOption ("MustDeclareVars" , 1)
;-Includes------------------------------------------------------------
#Include "C:\Language\AutoIt\Include\SendMessage.au3"
#Include "C:\Language\AutoIt\Include\WinAPI.au3"
#Include "C:\Language\AutoIt\Include\WinAPISys.au3"
#Include "C:\Language\AutoIt\Include\WindowsConstants.au3"
#Include "C:\Language\AutoIt\Include\MsgBoxConstants.au3"
#Include "C:\Language\AutoIt\Include\GuiButton.au3"
#Include "C:\Language\AutoIt\Include\Array.au3"
#Include "C:\Language\AutoIt\Include\GuiEdit.au3"
;-Function _WinAPI_FindWindowEx---------------------------------------
Func _WinAPI_FindWindowEx($hWndParent, $hWndChildAfter, _
$sClassName, $sWindowName)
Local $aResult = DllCall("user32.dll", "hwnd", "FindWindowExW", _
"hWnd", $hWndParent, "hWnd", $hWndChildAfter, _
"wstr", $sClassName, "wstr", $sWindowName)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[0]
EndFunc
;-Sub Auto_SaveAs_SAP-------------------------------------------------
;
; Function checked with SAP 7.31 SP 4 and Dialog Box in SE80 to save
; source code as local file on a German version of Windows 7 with
; AutoIt 3.3.14.2
;
; Important hint: FindWindowEx works not in any case, so it is
; possible to use instead EnumChildWindows
;
;---------------------------------------------------------------------
Func Auto_SaveAs_SAP($FileName)
;-Variables-------------------------------------------------------
Local $i
;Get the handle of the Save As Dialog Box
Local $hWin = _WinAPI_FindWindow ("#32770", "Speichern unter")
If $hWin = 0 Then
MsgBox($MB_OK, "", "Save As Window Not Found")
Return
EndIf
;Get the handle of ComboBoxEx32
Local $hChildRet = _WinAPI_FindWindowEx($hWin, 0, "ComboBoxEx32", "")
If $hChildRet = 0 Then
MsgBox($MB_OK, "", "ComboBoxEx32 Not Found")
Return
EndIf
;Get the handle of the Main ComboBox
$hChildRet = _WinAPI_FindWindowEx($hChildRet, 0, "ComboBox", "")
If $hChildRet = 0 Then
MsgBox($MB_OK, "", "ComboBox Window Not Found")
Return
EndIf
;Get the handle of the Edit
Local $hChildArray = _WinAPI_EnumChildWindows($hChildRet)
$hChildRet = $hChildArray[1][0]
If $hChildRet = 0 Then
MsgBox($MB_OK, "", "Edit Window Not Found")
Return
EndIf
_WinAPI_SetForegroundWindow($hWin)
_WinAPI_BringWindowToTop($hWin)
;fillin FileName in 'Save As' Edit
_GUICtrlEdit_SetText($hChildRet, $FileName)
;Get the handle of the Save Button in the Save As Dialog Box
$hChildArray = _WinAPI_EnumChildWindows($hWin)
For $i = 0 To UBound($hChildArray, $UBOUND_ROWS) - 1
If $hChildArray[$i][1] = "Button" Then
;The Save Button gets as Window Text Open - Crazy
If _GUICtrlButton_GetText($hChildArray[$i][0]) = "Ö&ffnen" Then
$hChildRet = $hChildArray[$i][0]
EndIf
EndIf
Next
;Check if we found it or not
If $hChildRet = 0 Then
MsgBox($MB_OK, "", "Save Button in Save As Window Not Found")
Return
EndIf
;Press Save-button
_SendMessage($hChildRet, $BM_CLICK, 0, 0)
EndFunc
;-Sub Main------------------------------------------------------------
Func Main()
Auto_SaveAs_SAP("Test.txt")
EndFunc
;-Main----------------------------------------------------------------
Main()
;-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |