Jump to content

FileSaveDialog


Recommended Posts

$savepath = FileSaveDialog("Save Screenshot", @HomeDrive, "(*.bmp)|(*.gif)|(*.jpg)|(*.png)|(*.tif)", 18, "", $hGui)

I only need this part of the code, and I just don't get one thing... When I select .gif for example, and I give the file a name "Test" for example, it doesn't add .gif automaticly on the file... it just names it "Test" and it's no kind of file...

Is there any way to fix this?

Reinn

Link to comment
Share on other sites

$savepath = FileSaveDialog("Save Screenshot", @HomeDrive, "(*.bmp)|(*.gif)|(*.jpg)|(*.png)|(*.tif)", 18, "", $hGui)

I only need this part of the code, and I just don't get one thing... When I select .gif for example, and I give the file a name "Test" for example, it doesn't add .gif automaticly on the file... it just names it "Test" and it's no kind of file...

Is there any way to fix this?

Reinn

I do not know how to do this using FileSaveDialog(), but look here, may be can help.
Link to comment
Share on other sites

$savepath = FileSaveDialog("Save Screenshot", @HomeDrive, "(*.bmp)|(*.gif)|(*.jpg)|(*.png)|(*.tif)", 18, "", $hGui)

I only need this part of the code, and I just don't get one thing... When I select .gif for example, and I give the file a name "Test" for example, it doesn't add .gif automaticly on the file... it just names it "Test" and it's no kind of file...

Is there any way to fix this?

Reinn

I did one simple way here, though it could be improved, and I've seen better solutions so searching should find something.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

There is a better method shown to me by manadar. It is exctly the same except sorts that out for you!

Func Save ($sTitle, $sInitDir, $sFilter = 'All (*.*)', $iOpt = 0, $sDefaultFile = "", $sDefaultExt = "", $mainGUI = 0)
   Local $iFileLen = 65536
   Local $iFlag = BitOR(BitShift(BitAND($iOpt, 2), -10), BitShift(BitAND($iOpt, 16), 3))
   Local $asFLines = StringSplit($sFilter, '|'), $asFilter[$asFLines[0] * 2 + 1]
   Local $i, $iStart, $iFinal, $suFilter = '', $ret
      
   $asFilter[0] = $asFLines[0] * 2
   For $i = 1 To $asFLines[0]
      $iStart = StringInStr($asFLines[$i], '(', 0, 1)
      $iFinal = StringInStr($asFLines[$i], ')', 0, -1)
      $asFilter[$i * 2 - 1] = StringStripWS(StringLeft($asFLines[$i], $iStart - 1), 3)
      $asFilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asFLines[$i], $iStart), StringLen($asFLines[$i]) - $iFinal + 1), 3)
      $suFilter = $suFilter & 'byte[' & StringLen($asFilter[$i * 2 - 1]) + 1 & '];byte[' & StringLen($asFilter[$i * 2]) + 1 & '];'
   Next
   Local $uOFN = DllStructCreate('dword;int;int;ptr;ptr;dword;dword;ptr;dword' & ';ptr;int;ptr;ptr;dword;short;short;ptr;ptr;ptr;ptr;ptr;dword;dword')
   Local $usTitle = DllStructCreate('byte[' & StringLen($sTitle) + 1 & ']')
   Local $usInitDir = DllStructCreate('byte[' & StringLen($sInitDir) + 1 & ']')
   Local $usFilter = DllStructCreate($suFilter & 'byte')
   Local $usFile = DllStructCreate('char[' & $iFileLen & ']')
   Local $usExtn = DllStructCreate('byte[' & StringLen($sDefaultExt) + 1 & ']')
   For $i = 1 To $asFilter[0]
      DllStructSetData($usFilter, $i, $asFilter[$i])
   Next
   DllStructSetData($usTitle, 1, $sTitle)
   DllStructSetData($usInitDir, 1, $sInitDir)
   DllStructSetData($usFile, 1, $sDefaultFile)
   DllStructSetData($usExtn, 1, $sDefaultExt)
   DllStructSetData($uOFN, 1, DllStructGetSize($uOFN))
   DllStructSetData($uOFN, 2, $mainGUI)
   DllStructSetData($uOFN, 4, DllStructGetPtr($usFilter))
   DllStructSetData($uOFN, 7, 1)
   DllStructSetData($uOFN, 8, DllStructGetPtr($usFile))
   DllStructSetData($uOFN, 9, $iFileLen)
   DllStructSetData($uOFN, 12, DllStructGetPtr($usInitDir))
   DllStructSetData($uOFN, 13, DllStructGetPtr($usTitle))
   DllStructSetData($uOFN, 14, $iFlag)
   DllStructSetData($uOFN, 17, DllStructGetPtr($usExtn))
   DllStructSetData($uOFN, 23, BitShift(BitAND($iOpt, 32), 5))
   $ret = DllCall('comdlg32.dll', 'int', 'GetSaveFileName', 'ptr', DllStructGetPtr($uOFN))
      If $ret[0] Then
         Return StringStripWS(DllStructGetData($usFile, 1), 3)
      Else
         SetError(1)
         Return ""
      EndIf

EndFunc ;==>Save

MDiesel

This is actually my prefered function, I added it to my File.au3 include.

Edited by mdiesel
Link to comment
Share on other sites

Try:

#include <WinAPI.au3>
$savepath = _WinAPI_GetSaveFileName("Save Screenshot", "Bitmap (*.bmp)|Graphics Interchange Format (*.gif)|JPEG Image (*.jpg)|Portable Network Graphics (*.png)|Tagged Image File Format (*.tif)", @HomeDrive, "")

MsgBox(0, "", $savepath[0] & @CRLF & $savepath[1] & @CRLF & $savepath[2])

Cheers,

Brett

Link to comment
Share on other sites

Lol, I somehow couldn't edit my post...

Well anyway, I couldn't get it working...

Maybe it'll be easier if you guys see my code:

;//////////////////////////////////////////////
;Reinn's Screen capture software
;v.1.0
;Developed & brought to you by Fleud.com
;//////////////////////////////////////////////
;Functions:
;Takes a screenshot of the chosen window
;//////////////////////////////////////////////
;Information
;This is still a BETA, New versions will come!
;//////////////////////////////////////////////

#include <GUIConstants.au3>
#include <GUIListView.au3>
#include <ScreenCapture.au3>

HotKeySet('^s', 'Stop')

main()

Func main()
    Local $name = "Reinn's Screenshot Tool"
    Dim $handles[50], $titles[50]
    Local $main, $listview, $desktop, $winpid, $winpath, $capture, $msg, $index, $handle
    $main = GUICreate($name, 295, 210)
    $listview = GUICtrlCreateListView("Window Title", 10, 10, 275, 155, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
    $desktop = _WinAPI_GetDesktopWindow ()
    $windows = WinList()
    GUICtrlCreateListViewItem("Desktop", $listview)
    GUICtrlSetImage(-1, "shell32.dll", 35)
    $x = 1
    For $i = 1 To $windows[0][0]
        $winpid = WinGetProcess($windows[$i][0], "")
        If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) Then
            $winpath = _ProcessGetPath($winpid)
            GUICtrlCreateListViewItem($windows[$i][0], $listview)
            GUICtrlSetImage(-1, "shell32.dll", 3)
            GUICtrlSetImage(-1, $winpath, 1)
            $handles[$x] = $windows[$i][1]
            $titles[$x] = $windows[$i][0]
            $x = $x + 1
        EndIf
    Next
    _GUICtrlListView_SetColumnWidth ($listview, 0, $LVSCW_AUTOSIZE)
    $capture = GUICtrlCreateButton("Capture", 110, 175, 75, 25)
    GUISetState()
    Do
        $msg = GUIGetMsg()
        
        If $msg = $capture Then
            $index = _GuiCtrlListView_GetSelectedIndices ($listview)
            If $index = 0 Then
                $handle = $desktop
                $title = "Desktop"
            Else
                $handle = $handles[$index]
                $title = $titles[$index]
            EndIf
            _Capture($main, $handle, $title)
        EndIf
    Until $msg = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc;==>main

Func _Capture($hGui, $hWnd, $sTitle)
    WinMinimizeAll()
    WinActivate($sTitle)
    Local $savepath, $image, $errorcheck, $open
    $savepath = FileSaveDialog("Save Screenshot", @HomeDrive, "(*.bmp)|(*.gif)|(*.jpg)|(*.png)|(*.tif)", 18, "", $hGui)
;EXTRA IF I DONT GET THE OTHER ONE TO WORK   $savepath = FileSaveDialog("Save Screenshot", @HomeDrive, "All (*.*)", 18, "", $hGui)
    If @error <> 1 Then
        GUISetState(@SW_HIDE, $hGui)
        If $sTitle <> "Desktop" Then
            WinSetState($sTitle, "", @SW_SHOW)
            WinSetState($sTitle, "", @SW_RESTORE)
        EndIf
        $image = _ScreenCapture_CaptureWnd ("", $hWnd, 0, 0, -1, -1, False)
        $errorcheck = _ScreenCapture_SaveImage ($savepath, $image, True)
        GUISetState(@SW_SHOW, $hGui)
        If $errorcheck = False Then
            _WinAPI_DeleteObject ($image)
        Else
            $open = MsgBox(36, "Open Image?", "Would you like to open the image?")
            If $open = 6 Then
                ShellExecute($savepath)
        Else
            EndIf
        EndIf
    Else
    EndIf
EndFunc;==>_Capture

Visit()

Func Visit()
        $Visit = MsgBox(0x44, "Reinn's Screenshot Tool", "Would you like to go to Fleud.com now?")
            If ( $Visit == 6 ) Then
                ShellExecute("http://www.Fleud.com/")
            Else
            EndIf
EndFunc

Func _ProcessGetPath($pid)
    If IsString($pid) Then $pid = ProcessExists($pid)
    $Path = DllStructCreate("char[1000]")
    $dll = DllOpen("Kernel32.dll")
    $handle = DllCall($dll, "int", "OpenProcess", "dword", 0x0400 + 0x0010, "int", 0, "dword", $pid)
    $ret = DllCall("Psapi.dll", "long", "GetModuleFileNameEx", "long", $handle[0], "int", 0, "ptr", DllStructGetPtr($Path), "long", DllStructGetSize($Path))
    $ret = DllCall($dll, "int", "CloseHandle", "hwnd", $handle[0])
    DllClose($dll)
    Return DllStructGetData($Path, 1)
EndFunc;==>_ProcessGetPath

Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc;==>IsVisible

Func Stop()
    Exit
EndFunc
Edited by Reinn
Link to comment
Share on other sites

CODE
#include <GUIConstants.au3>

#include <GUIListView.au3>

#include <ScreenCapture.au3>

HotKeySet('^s', 'Stop')

main()

Func main()

Local $name = "Reinn's Screenshot Tool"

Dim $handles[50], $titles[50]

Local $main, $listview, $desktop, $winpid, $winpath, $capture, $msg, $index, $handle

$main = GUICreate($name, 295, 210)

$listview = GUICtrlCreateListView("Window Title", 10, 10, 275, 155, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))

$desktop = _WinAPI_GetDesktopWindow ()

$windows = WinList()

GUICtrlCreateListViewItem("Desktop", $listview)

GUICtrlSetImage(-1, "shell32.dll", 35)

$x = 1

For $i = 1 To $windows[0][0]

$winpid = WinGetProcess($windows[$i][0], "")

If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) Then

$winpath = _ProcessGetPath($winpid)

GUICtrlCreateListViewItem($windows[$i][0], $listview)

GUICtrlSetImage(-1, "shell32.dll", 3)

GUICtrlSetImage(-1, $winpath, 1)

$handles[$x] = $windows[$i][1]

$titles[$x] = $windows[$i][0]

$x = $x + 1

EndIf

Next

_GUICtrlListView_SetColumnWidth ($listview, 0, $LVSCW_AUTOSIZE)

$capture = GUICtrlCreateButton("Capture", 110, 175, 75, 25)

GUISetState()

Do

$msg = GUIGetMsg()

If $msg = $capture Then

$index = _GuiCtrlListView_GetSelectedIndices ($listview)

If $index = 0 Then

$handle = $desktop

$title = "Desktop"

Else

$handle = $handles[$index]

$title = $titles[$index]

EndIf

_Capture($main, $handle, $title)

EndIf

Until $msg = $GUI_EVENT_CLOSE

GUIDelete()

EndFunc ;==>main

Func _Capture($hGui, $hWnd, $sTitle)

WinMinimizeAll()

WinActivate($sTitle)

Local $savepath, $image, $errorcheck, $open

$savepath = _FileSaveDialog("Save Screenshot", @HomeDrive, "Bitmap (*.bmp)|Gif image (*.gif)|JPEG (*.jpg)| Png Image (*.png)| tif file(*.tif)", 18, "", ".bmp", $hGui)

If @error <> 1 Then

GUISetState(@SW_HIDE, $hGui)

If $sTitle <> "Desktop" Then

WinSetState($sTitle, "", @SW_SHOW)

WinSetState($sTitle, "", @SW_RESTORE)

EndIf

$image = _ScreenCapture_CaptureWnd ("", $hWnd, 0, 0, -1, -1, False)

$errorcheck = _ScreenCapture_SaveImage ($savepath, $image, True)

GUISetState(@SW_SHOW, $hGui)

If $errorcheck = False Then

_WinAPI_DeleteObject ($image)

Else

$open = MsgBox(36, "Open Image?", "Would you like to open the image?")

If $open = 6 Then

ShellExecute($savepath)

Else

EndIf

EndIf

Else

EndIf

EndFunc ;==>_Capture

Visit()

Func Visit()

$Visit = MsgBox(0x44, "Reinn's Screenshot Tool", "Would you like to go to Fleud.com now?")

If ( $Visit == 6 ) Then

ShellExecute("http://www.Fleud.com/")

Else

EndIf

EndFunc

Func _ProcessGetPath($pid)

If IsString($pid) Then $pid = ProcessExists($pid)

$Path = DllStructCreate("char[1000]")

$dll = DllOpen("Kernel32.dll")

$handle = DllCall($dll, "int", "OpenProcess", "dword", 0x0400 + 0x0010, "int", 0, "dword", $pid)

$ret = DllCall("Psapi.dll", "long", "GetModuleFileNameEx", "long", $handle[0], "int", 0, "ptr", DllStructGetPtr($Path), "long", DllStructGetSize($Path))

$ret = DllCall($dll, "int", "CloseHandle", "hwnd", $handle[0])

DllClose($dll)

Return DllStructGetData($Path, 1)

EndFunc ;==>_ProcessGetPath

Func IsVisible($handle)

If BitAND(WinGetState($handle), 2) Then

Return 1

Else

Return 0

EndIf

EndFunc ;==>IsVisible

Func Stop()

Exit

EndFunc

Func _FileSaveDialog ($sTitle, $sInitDir, $sFilter = 'All (*.*)', $iOpt = 0, $sDefaultFile = "", $sDefaultExt = "", $mainGUI = 0)

Local $iFileLen = 65536

Local $iFlag = BitOR(BitShift(BitAND($iOpt, 2), -10), BitShift(BitAND($iOpt, 16), 3))

Local $asFLines = StringSplit($sFilter, '|'), $asFilter[$asFLines[0] * 2 + 1]

Local $i, $iStart, $iFinal, $suFilter = '', $ret

$asFilter[0] = $asFLines[0] * 2

For $i = 1 To $asFLines[0]

$iStart = StringInStr($asFLines[$i], '(', 0, 1)

$iFinal = StringInStr($asFLines[$i], ')', 0, -1)

$asFilter[$i * 2 - 1] = StringStripWS(StringLeft($asFLines[$i], $iStart - 1), 3)

$asFilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asFLines[$i], $iStart), StringLen($asFLines[$i]) - $iFinal + 1), 3)

$suFilter = $suFilter & 'byte[' & StringLen($asFilter[$i * 2 - 1]) + 1 & '];byte[' & StringLen($asFilter[$i * 2]) + 1 & '];'

Next

Local $uOFN = DllStructCreate('dword;int;int;ptr;ptr;dword;dword;ptr;dword' & ';ptr;int;ptr;ptr;dword;short;short;ptr;ptr;ptr;ptr;ptr;dword;dword')

Local $usTitle = DllStructCreate('byte[' & StringLen($sTitle) + 1 & ']')

Local $usInitDir = DllStructCreate('byte[' & StringLen($sInitDir) + 1 & ']')

Local $usFilter = DllStructCreate($suFilter & 'byte')

Local $usFile = DllStructCreate('char[' & $iFileLen & ']')

Local $usExtn = DllStructCreate('byte[' & StringLen($sDefaultExt) + 1 & ']')

For $i = 1 To $asFilter[0]

DllStructSetData($usFilter, $i, $asFilter[$i])

Next

DllStructSetData($usTitle, 1, $sTitle)

DllStructSetData($usInitDir, 1, $sInitDir)

DllStructSetData($usFile, 1, $sDefaultFile)

DllStructSetData($usExtn, 1, $sDefaultExt)

DllStructSetData($uOFN, 1, DllStructGetSize($uOFN))

DllStructSetData($uOFN, 2, $mainGUI)

DllStructSetData($uOFN, 4, DllStructGetPtr($usFilter))

DllStructSetData($uOFN, 7, 1)

DllStructSetData($uOFN, 8, DllStructGetPtr($usFile))

DllStructSetData($uOFN, 9, $iFileLen)

DllStructSetData($uOFN, 12, DllStructGetPtr($usInitDir))

DllStructSetData($uOFN, 13, DllStructGetPtr($usTitle))

DllStructSetData($uOFN, 14, $iFlag)

DllStructSetData($uOFN, 17, DllStructGetPtr($usExtn))

DllStructSetData($uOFN, 23, BitShift(BitAND($iOpt, 32), 5))

$ret = DllCall('comdlg32.dll', 'int', 'GetSaveFileName', 'ptr', DllStructGetPtr($uOFN))

If $ret[0] Then

Return StringStripWS(DllStructGetData($usFile, 1), 3)

Else

SetError(1)

Return ""

EndIf

EndFunc ;==>Save

Works a treat! except it doesn't restore windows properly after capturing them!

MDiesel

Link to comment
Share on other sites

CODE
#include <GUIConstants.au3>

#include <GUIListView.au3>

#include <ScreenCapture.au3>

HotKeySet('^s', 'Stop')

main()

Func main()

Local $name = "Reinn's Screenshot Tool"

Dim $handles[50], $titles[50]

Local $main, $listview, $desktop, $winpid, $winpath, $capture, $msg, $index, $handle

$main = GUICreate($name, 295, 210)

$listview = GUICtrlCreateListView("Window Title", 10, 10, 275, 155, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))

$desktop = _WinAPI_GetDesktopWindow ()

$windows = WinList()

GUICtrlCreateListViewItem("Desktop", $listview)

GUICtrlSetImage(-1, "shell32.dll", 35)

$x = 1

For $i = 1 To $windows[0][0]

$winpid = WinGetProcess($windows[$i][0], "")

If $windows[$i][0] <> "" And IsVisible($windows[$i][1]) Then

$winpath = _ProcessGetPath($winpid)

GUICtrlCreateListViewItem($windows[$i][0], $listview)

GUICtrlSetImage(-1, "shell32.dll", 3)

GUICtrlSetImage(-1, $winpath, 1)

$handles[$x] = $windows[$i][1]

$titles[$x] = $windows[$i][0]

$x = $x + 1

EndIf

Next

_GUICtrlListView_SetColumnWidth ($listview, 0, $LVSCW_AUTOSIZE)

$capture = GUICtrlCreateButton("Capture", 110, 175, 75, 25)

GUISetState()

Do

$msg = GUIGetMsg()

If $msg = $capture Then

$index = _GuiCtrlListView_GetSelectedIndices ($listview)

If $index = 0 Then

$handle = $desktop

$title = "Desktop"

Else

$handle = $handles[$index]

$title = $titles[$index]

EndIf

_Capture($main, $handle, $title)

EndIf

Until $msg = $GUI_EVENT_CLOSE

GUIDelete()

EndFunc ;==>main

Func _Capture($hGui, $hWnd, $sTitle)

WinMinimizeAll()

WinActivate($sTitle)

Local $savepath, $image, $errorcheck, $open

$savepath = _FileSaveDialog("Save Screenshot", @HomeDrive, "Bitmap (*.bmp)|Gif image (*.gif)|JPEG (*.jpg)| Png Image (*.png)| tif file(*.tif)", 18, "", ".bmp", $hGui)

If @error <> 1 Then

GUISetState(@SW_HIDE, $hGui)

If $sTitle <> "Desktop" Then

WinSetState($sTitle, "", @SW_SHOW)

WinSetState($sTitle, "", @SW_RESTORE)

EndIf

$image = _ScreenCapture_CaptureWnd ("", $hWnd, 0, 0, -1, -1, False)

$errorcheck = _ScreenCapture_SaveImage ($savepath, $image, True)

GUISetState(@SW_SHOW, $hGui)

If $errorcheck = False Then

_WinAPI_DeleteObject ($image)

Else

$open = MsgBox(36, "Open Image?", "Would you like to open the image?")

If $open = 6 Then

ShellExecute($savepath)

Else

EndIf

EndIf

Else

EndIf

EndFunc ;==>_Capture

Visit()

Func Visit()

$Visit = MsgBox(0x44, "Reinn's Screenshot Tool", "Would you like to go to Fleud.com now?")

If ( $Visit == 6 ) Then

ShellExecute("http://www.Fleud.com/")

Else

EndIf

EndFunc

Func _ProcessGetPath($pid)

If IsString($pid) Then $pid = ProcessExists($pid)

$Path = DllStructCreate("char[1000]")

$dll = DllOpen("Kernel32.dll")

$handle = DllCall($dll, "int", "OpenProcess", "dword", 0x0400 + 0x0010, "int", 0, "dword", $pid)

$ret = DllCall("Psapi.dll", "long", "GetModuleFileNameEx", "long", $handle[0], "int", 0, "ptr", DllStructGetPtr($Path), "long", DllStructGetSize($Path))

$ret = DllCall($dll, "int", "CloseHandle", "hwnd", $handle[0])

DllClose($dll)

Return DllStructGetData($Path, 1)

EndFunc ;==>_ProcessGetPath

Func IsVisible($handle)

If BitAND(WinGetState($handle), 2) Then

Return 1

Else

Return 0

EndIf

EndFunc ;==>IsVisible

Func Stop()

Exit

EndFunc

Func _FileSaveDialog ($sTitle, $sInitDir, $sFilter = 'All (*.*)', $iOpt = 0, $sDefaultFile = "", $sDefaultExt = "", $mainGUI = 0)

Local $iFileLen = 65536

Local $iFlag = BitOR(BitShift(BitAND($iOpt, 2), -10), BitShift(BitAND($iOpt, 16), 3))

Local $asFLines = StringSplit($sFilter, '|'), $asFilter[$asFLines[0] * 2 + 1]

Local $i, $iStart, $iFinal, $suFilter = '', $ret

$asFilter[0] = $asFLines[0] * 2

For $i = 1 To $asFLines[0]

$iStart = StringInStr($asFLines[$i], '(', 0, 1)

$iFinal = StringInStr($asFLines[$i], ')', 0, -1)

$asFilter[$i * 2 - 1] = StringStripWS(StringLeft($asFLines[$i], $iStart - 1), 3)

$asFilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asFLines[$i], $iStart), StringLen($asFLines[$i]) - $iFinal + 1), 3)

$suFilter = $suFilter & 'byte[' & StringLen($asFilter[$i * 2 - 1]) + 1 & '];byte[' & StringLen($asFilter[$i * 2]) + 1 & '];'

Next

Local $uOFN = DllStructCreate('dword;int;int;ptr;ptr;dword;dword;ptr;dword' & ';ptr;int;ptr;ptr;dword;short;short;ptr;ptr;ptr;ptr;ptr;dword;dword')

Local $usTitle = DllStructCreate('byte[' & StringLen($sTitle) + 1 & ']')

Local $usInitDir = DllStructCreate('byte[' & StringLen($sInitDir) + 1 & ']')

Local $usFilter = DllStructCreate($suFilter & 'byte')

Local $usFile = DllStructCreate('char[' & $iFileLen & ']')

Local $usExtn = DllStructCreate('byte[' & StringLen($sDefaultExt) + 1 & ']')

For $i = 1 To $asFilter[0]

DllStructSetData($usFilter, $i, $asFilter[$i])

Next

DllStructSetData($usTitle, 1, $sTitle)

DllStructSetData($usInitDir, 1, $sInitDir)

DllStructSetData($usFile, 1, $sDefaultFile)

DllStructSetData($usExtn, 1, $sDefaultExt)

DllStructSetData($uOFN, 1, DllStructGetSize($uOFN))

DllStructSetData($uOFN, 2, $mainGUI)

DllStructSetData($uOFN, 4, DllStructGetPtr($usFilter))

DllStructSetData($uOFN, 7, 1)

DllStructSetData($uOFN, 8, DllStructGetPtr($usFile))

DllStructSetData($uOFN, 9, $iFileLen)

DllStructSetData($uOFN, 12, DllStructGetPtr($usInitDir))

DllStructSetData($uOFN, 13, DllStructGetPtr($usTitle))

DllStructSetData($uOFN, 14, $iFlag)

DllStructSetData($uOFN, 17, DllStructGetPtr($usExtn))

DllStructSetData($uOFN, 23, BitShift(BitAND($iOpt, 32), 5))

$ret = DllCall('comdlg32.dll', 'int', 'GetSaveFileName', 'ptr', DllStructGetPtr($uOFN))

If $ret[0] Then

Return StringStripWS(DllStructGetData($usFile, 1), 3)

Else

SetError(1)

Return ""

EndIf

EndFunc ;==>Save

Works a treat! except it doesn't restore windows properly after capturing them!

MDiesel

Works, thanks! :)
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...