Jump to content

FileOpenDialog


 Share

Recommended Posts

When i open the 2nd FileOpenDialog in this script sometimes it will crash without an error other then "!>18:12:18 AutoIT3.exe ended.rc:-1073741819", what could be causing it?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("GIF to JPG", 373, 65, 191, 124)
$GIF_InputBox = GUICtrlCreateInput("", 8, 8, 297, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$JPG_InputBox = GUICtrlCreateInput("", 8, 36, 297, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$GIF_Button = GUICtrlCreateButton(".GIF", 315, 8, 49, 21, 0)
$JPG_Button = GUICtrlCreateButton(".JPG", 315, 36, 49, 21, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GIF_Button
            $GIF_Location = FileOpenDialog("Select .GIF",@DesktopDir, "GIF Files (*.GIF)",1)
            GUICtrlSetData($GIF_InputBox,$GIF_Location)
        Case $JPG_Button
            $JPG_Location = FileOpenDialog("Select .JPG",@DesktopDir, "JPG Files (*.JPG)",1)
            GUICtrlSetData($JPG_InputBox,$JPG_Location)
    EndSwitch
WEnd
Edited by Dead_Man
Link to comment
Share on other sites

Try this - NOT TESTED

$g = 0
$j = 0
$Form1 = GUICreate("GIF to JPG", 373, 65, 191, 124)
$GIF_InputBox = GUICtrlCreateInput("", 8, 8, 297, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$JPG_InputBox = GUICtrlCreateInput("", 8, 36, 297, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$GIF_Button = GUICtrlCreateButton(".GIF", 315, 8, 49, 21, 0)
$JPG_Button = GUICtrlCreateButton(".JPG", 315, 36, 49, 21, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GIF_Button
            $j = 1
            if $g = 0 then 
                $GIF_Location = FileOpenDialog("Select .GIF",@DesktopDir, "GIF Files (*.GIF)",1)
                GUICtrlSetData($GIF_InputBox,$GIF_Location)
            endif
            $j = 0
        Case $JPG_Button
            $g = 1
            if $j = 0 then 
                $JPG_Location = FileOpenDialog("Select .JPG",@DesktopDir, "JPG Files (*.JPG)",1)
                GUICtrlSetData($JPG_InputBox,$JPG_Location)
            EndIf
            $g = 0
    EndSwitch
WEnd
Link to comment
Share on other sites

OK, my last attempt sucked. try this. I tested it and it works fine:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

dim $JPG_Location
dim $GIF_Location
$Form1 = GUICreate("GIF to JPG", 373, 65, 191, 124)
$GIF_InputBox = GUICtrlCreateInput("", 8, 8, 297, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$JPG_InputBox = GUICtrlCreateInput("", 8, 36, 297, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$GIF_Button = GUICtrlCreateButton(".GIF", 315, 8, 49, 21, 0)
$JPG_Button = GUICtrlCreateButton(".JPG", 315, 36, 49, 21, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    select 
        Case $nMsg =$GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $GIF_Button 
            GUICtrlSetState($GIF_Button, $GUI_DISABLE)
            GUICtrlSetState($JPG_Button, $GUI_DISABLE)
            $GIF_Location = FileOpenDialog("Select .GIF",@DesktopDir, "GIF Files (*.GIF)",1)
            GUICtrlSetData($GIF_InputBox,$GIF_Location)
            GUICtrlSetState($JPG_Button, $GUI_ENABLE)
            GUICtrlSetState($GIF_Button, $GUI_ENABLE)
        Case $nMsg = $JPG_Button
            GUICtrlSetState($GIF_Button, $GUI_DISABLE)
            GUICtrlSetState($JPG_Button, $GUI_DISABLE)
            $JPG_Location = FileOpenDialog("Select .JPG",@DesktopDir, "JPG Files (*.JPG)",1)
            GUICtrlSetData($JPG_InputBox,$JPG_Location)
            GUICtrlSetState($JPG_Button, $GUI_ENABLE)
            GUICtrlSetState($GIF_Button, $GUI_ENABLE)
        case Else
            ;;;
    EndSelect
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...