Jump to content

Unknonw error !


logmein
 Share

Recommended Posts

This is my script :

#NoTrayIcon
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GDIplus.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <Process.au3>
;form start
$title = "Image Converter 1.0 - logmein"
$dir1 = IniRead (@systemdir & "ImageConverter.ini","Settings","Dir1","")
$dir2 = IniRead (@systemdir & "ImageConverter.ini","Settings","Dir2",@DesktopDir)
#Region
$Form = GUICreate($title, 462, 125, -1, -1)
GUISetIcon (@ScriptDir & 'imagekonverter.ico','',-1)
GUICtrlCreateGroup("Options", 8, 0, 449, 137-46)
$Label1 = GUICtrlCreateLabel("Source :", 16, 24, 45, 18)
$s = GUICtrlCreateInput('', 80, 24, 313, 22)
GUICtrlSetData (-1,$dir1)
$sb = GUICtrlCreateButton("...", 400, 23, 51, 23, 0)
$Label2 = GUICtrlCreateLabel("Destination :", 16, 64, 63, 18)
$d = GUICtrlCreateInput("", 80, 60, 313, 22)
GUICtrlSetData (-1,$dir2)
$db = GUICtrlCreateButton("...", 400, 59, 51, 23, 0)
;
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Ok = GUICtrlCreateButton("Convert !", 184, 144-46, 115, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetFont(-1, 10, 800, 0, "ABC Sans Serif")
$web = GUICtrlCreateLabel ('Home',430,100,50,25)
GUICtrlSetFont (-1,8.5,400,4)
GUICtrlSetColor (-1,0x0000ff)
GUICtrlSetCursor (-1,0)
GUISetState(@SW_SHOW)
#EndRegion
;===================================================================================================



=======

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $sb
            $z1 = FileOpenDialog("Browse for image file", GUICtrlRead($s),'Image (*.BMP;*.DIB;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.PNG;*.TIF;*.TIFF;*.JIF)', 1, "", $Form)
            If Not @error Then
                GUICtrlSetData($s, $z1)
            EndIf
        Case $db
            $z2 = FileSaveDialog ("Browse for destination file",GUICtrlRead ($d),'Image (*.BMP;*.DIB;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.PNG;*.TIF;*.TIFF;*.JIF)',"","",$form)
            If Not @error Then
                GUICtrlSetData($d, $z2)
            EndIf

        Case $GUI_EVENT_CLOSE
            _exit ()
            
        Case $ok
            convert ()
            
        Case $web
            _RunDos("start http://sites.google.com/site/imagekonverter/Home")
EndSwitch

;tranfer ()
WEnd


Func _exit ()
    IniWrite(@SystemDir & "ImageConverter.ini", "Settings", "Dir1", GUICtrlRead($s))
    IniWrite(@SystemDir & "ImageConverter.ini", "Settings", "Dir2", GUICtrlRead($d))
    Exit
EndFunc

if i run the script, it show a open file dialog box? I can't find the bug! Where's it? :-(

removed convert func from last edit!

Edited by logmein
Link to comment
Share on other sites

For one thing, you're missing some "\" characters...

$dir1 = IniRead (@systemdir & "\ImageConverter.ini","Settings","Dir1","")
$dir2 = IniRead (@systemdir & "\ImageConverter.ini","Settings","Dir2",@DesktopDir)

IniWrite(@SystemDir & "\ImageConverter.ini", "Settings", "Dir1", GUICtrlRead($s))
IniWrite(@SystemDir & "\ImageConverter.ini", "Settings", "Dir2", GUICtrlRead($d))

GUISetIcon (@ScriptDir & '\imagekonverter.ico','',-1)

EDIT: Is probably the bad pathname in GUISetIcon causing your main troubles...

EDIT2: On second glance, your GUISetIcon statement is all messed up, I think you just want:

GUISetIcon (@ScriptDir & '\imagekonverter.ico')
Edited by Spiff59
Link to comment
Share on other sites

As has been said your problem lies mostly with where you use @ScriptDir,

Remember that it doesn't not give the returned path a \, so you always need to add one with files :)

See the following too:

#NoTrayIcon
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GDIplus.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <Process.au3>
;form start
$title = "Image Converter 1.0 - logmein"
$dir1 = IniRead(@SystemDir & "\ImageConverter.ini", "Settings", "Dir1", "")
$dir2 = IniRead(@SystemDir & "\ImageConverter.ini", "Settings", "Dir2", @DesktopDir)
#Region
$Form = GUICreate($title, 462, 125, -1, -1)
GUISetIcon(@ScriptDir & 'imagekonverter.ico', '', -1)
GUICtrlCreateGroup("Options", 8, 0, 449, 137 - 46)
$Label1 = GUICtrlCreateLabel("Source :", 16, 24, 45, 18)
$s = GUICtrlCreateInput('', 80, 24, 313, 22)
GUICtrlSetData(-1, $dir1)
$sb = GUICtrlCreateButton("...", 400, 23, 51, 23, 0)
$Label2 = GUICtrlCreateLabel("Destination :", 16, 64, 63, 18)
$d = GUICtrlCreateInput("", 80, 60, 313, 22)
GUICtrlSetData(-1, $dir2)
$db = GUICtrlCreateButton("...", 400, 59, 51, 23, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Ok = GUICtrlCreateButton("Convert !", 184, 144 - 46, 115, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetFont(-1, 10, 800, 0, "ABC Sans Serif")
$web = GUICtrlCreateLabel('Home', 430, 100, 50, 25)
GUICtrlSetFont(-1, 8.5, 400, 4)
GUICtrlSetColor(-1, 0x0000ff)
GUICtrlSetCursor(-1, 0)
GUISetState(@SW_SHOW)
#EndRegion
;===================================================================================================

==

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $sb
            $z1 = FileOpenDialog("Browse for image file", GUICtrlRead($s), 'Image (*.BMP;*.DIB;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.PNG;*.TIF;*.TIFF;*.JIF)', 1, "", $Form)
            If Not @error Then
                GUICtrlSetData($s, $z1)
            EndIf
        Case $db
            $z2 = FileSaveDialog("Browse for destination file", GUICtrlRead($d), 'Image (*.BMP;*.DIB;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.PNG;*.TIF;*.TIFF;*.JIF)', "", "", $Form)
            If Not @error Then
                GUICtrlSetData($d, $z2)
            EndIf
        Case $Ok
        ;convert()
        Case $web
            ShellExecute("http://sites.google.com/site/imagekonverter/Home");This will open in default browser.
    EndSwitch

;tranfer ()
WEnd


Func OnAutoItExit()
    IniWrite(@SystemDir & "\ImageConverter.ini", "Settings", "Dir1", GUICtrlRead($s))
    IniWrite(@SystemDir & "\ImageConverter.ini", "Settings", "Dir2", GUICtrlRead($d))
EndFunc  ;==>OnAutoItExit

If I changed anything, I usually used a comment... :)

Link to comment
Share on other sites

i have detect the bug : GuiSetIcon

if i delete it the script run without any problems

i can understand how GUISETICON cause to my script?

Link to comment
Share on other sites

  • Moderators

logmein,

You are using the wrong parameters with GUISetIcon. You have coded GUISetIcon (@ScriptDir & 'imagekonverter.ico','',-1). From the Help file:

GUISetIcon ( iconfile [, iconID [, winhandle]] )

Parameters

iconfile used to display the icon in the title area.

iconID [optional] The ID of the icon in the iconfile. (Default is -1).

winhandle [optional] Windows handle as returned by GUICreate (default is the previously used window).

So passing '' as a parameter is causing a crash as AutoIt tries to cope with what should be a number. As you are using GUISetIcon immediately after creating the GUI, there is no need to include the winhandle parameter either. So you should find that:

GUISetIcon (@ScriptDir & 'imagekonverter.ico')

will work for you. It does for me!

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...