Jump to content

Variables changing on their own?


Recommended Posts

Hi, I'm writing a very simple script, but I'm having some trouble.

In this script, I have a "Browse..." box to set two variables.

They set fine, and are used correctly the first time they are brought up in the script.

However, the second time I use these variables, the first one goes from a file location to "10" and the second one goes from a file location to "11"

I have nothing in the script that would make this happen, so what's causing this?

It works fine while in the "doex ()" function, but not while in the "dodel ()" function.

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <GUIListBox.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>

Global Const $winstate = @SW_HIDE

Func cleanup()
FileRecycle("C:\MergeTemp")
EndFunc

;Func main()

    $xSpacing = 5
    $ySpacing = 50
    $xWidth = 445
    
    cleanup()
    DirCreate("C:\MergeTemp")

    $maingui=GUICreate("AetherMaster's File-Picture Merger", 431, 251)
    $mergebutton = GUICtrlCreateButton("Merge!", 120, 215, 160)
    $archivebutton = GUICtrlCreateButton("Browse...", 360, 44, 60)
    $imagebutton = GUICtrlCreateButton("Browse...", 360, 125, 60)
    GUICtrlCreateLabel("Archive:", 5, 50)
    GUICtrlCreateLabel("Image:", 5, 129)
    GUICtrlCreateLabel("RAR, Zip, or 7z", 66, 72)
    GUICtrlCreateLabel("PNG, BMP, JPG, JPEG, GIF, TIFF, TIF, or TGA", 66, 151)
    $archive = GUICtrlCreateInput("", 59, 46, 285)
    $image = GUICtrlCreateInput("", 59, 127, 285)
    $delete = GUICtrlCreateCheckbox("Delete original files after merging? (Broken at the moment)", 59, 189)
    GUISetState(@SW_SHOW)
    While 1

        $msg = GUIGetMsg()

        Select
        Case $msg = $GUI_EVENT_CLOSE
                cleanup ()
                ExitLoop
            Case $msg = $mergebutton
                doex ($archive, $image)
            Case $msg = $archivebutton
                GUICtrlSetData($archive, FileOpenDialog("Choose Archive", @WorkingDir, "Archives (*.rar; *.zip; *.7z)", 1))
            Case $msg = $imagebutton
                GUICtrlSetData($image, FileOpenDialog("Choose Image", @WorkingDir, "Images (*.png; *.bmp; *.jpg; *.jpeg; *.gif; *.tiff; *.tif; *.tga)", 1))
        EndSelect
    WEnd 
;EndFunc

Func doex ()
    FileChangeDir("C:\Windows\System32")
    Run("cmd.exe")
    Sleep(500)
    Send("copy /b{SPACE}")
    Send('"')
    Send(GUICtrlRead($image))
    Send('"')
    Send("{SPACE}{+}{SPACE}")
    Send('"')
    Send(GUICtrlRead($archive))
    Send('"')
    Send("{SPACE}")
    Send("C:\MergeTemp\Output.img")
    Send("{ENTER}")
    Sleep(500)
    Send("exit")
    Send("{ENTER}")
    doend ()
EndFunc

Func doend ()
    FileMove("C:\MergeTemp\Output.img", FileSaveDialog("Save Merged Image With Old Image's Extention", @DesktopDir, "Images (*.png; *.bmp; *.jpg; *.jpeg; *.gif; *.tiff; *.tif; *.tga)", 16))
    Sleep(500)
    FileDelete("C:\MergeTemp\Output.img")
    If GUICtrlRead($delete) = $GUI_CHECKED Then
        Assign("delval", "1")
    Else
        Assign("delval", "0")
    EndIf
    FileChangeDir(@ScriptDir)
    If StringRight($delval, 1) == "1" Then
        dodel ()
    Else
        FileChangeDir(@ScriptDir)
    EndIf
    cleanup ()
    Exit
EndFunc

Func dodel ()
    FileDelete($image)
    FileDelete($archive)
    cleanup ()
EndFunc

Is anyone able to please help me? thanks.

Link to comment
Share on other sites

In the second function, you forgot to use guictrlread($var).

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

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