Sign in to follow this  
Followers 0
Tom42

Simple front end script, not working

3 posts in this topic

I'm piecing together scripts from the forum to make a simple frontend, if working it should copy two files and launch a batch file with 2 variables. One variable from the radio buttons and one variable from the input text. As it stands now it looks nice but does not function to well. Can someone help me out?

#include <GUIConstants.au3>

; Setting variables
Global $ahIcons[30], $ahLabels[30] 
Global $iStartIndex = 0, $iCntRow, $iCntCol, $iCurIndex
Global $sFilename = @SystemDir & "\shell32.dll"; Default file is "shell32.dll"
Global $sFilename2 = @SystemDir & "\shell32.dll"; Default file is "shell32.dll"
Global $ptype
; Creating GUI and controls
GUICreate("Portrait maker", 385, 265, @DesktopWidth/2 - 192, _
@DesktopHeight/2 - 235, -1, $WS_EX_ACCEPTFILES)
GUICtrlCreateGroup("Main Image", 5, 1, 375, 40)
GUICtrlCreateGroup("ALPHA Image", 5, 50, 375, 40)

$hFile = GUICtrlCreateEdit($sFilename, 12,  15, 325, 16, $ES_READONLY, $WS_EX_STATICEDGE)
GUICtrlSetCursor(-1, 2) 
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetTip(-1, "You can drop files from shell here...")
$hFileSel = GUICtrlCreateButton("...", 345,  14, 26, 18)

$hFile2 = GUICtrlCreateEdit($sFilename2, 12,  64, 325, 16, $ES_READONLY, $WS_EX_STATICEDGE)
GUICtrlSetCursor(-1, 2) 
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetTip(-1, "You can drop files from shell here...")
$hFileSel2 = GUICtrlCreateButton("...", 345,  63, 26, 18)

GUICtrlCreateGroup("Player ID #", 5, 100, 375, 40)
$playerid = GUICtrlCreateInput("", 15, 114, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

GUICtrlCreateGroup("Portrait Size", 5, 150, 375, 70)
$1x = GUICtrlCreateRadio("128x128", 20, 170, 100, 20)
GUICtrlSetState($1x, $GUI_CHECKED)
$2x = GUICtrlCreateRadio("256x256", 20, 190, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$makeportrait = GUICtrlCreateButton("&DO IT", 140, 230, 100)
GUISetState()

While 1
    $iMsg = GUIGetMsg()
  ; Code below will check if the file is dropped (or selected)
    $sCurFilename = GUICtrlRead($hFile) 
    If $sCurFilename <> $sFilename Then
        $iStartIndex = 0
        $sFilename = $sCurFilename
        _GUIUpdate()
    Endif
    
    $sCurFilename2 = GUICtrlRead($hFile2) 
    If $sCurFilename2 <> $sFilename2 Then
        $iStartIndex2 = 0
        $sFilename2 = $sCurFilename2
        _GUIUpdate2()
    Endif
    
    
  ; Main "Select" statement that handles other events
    Select
        Case $iMsg = $hFileSel
            $sTmpFile = FileOpenDialog("Select Main Image:", "\", "Main Image (*.bmp)")

            If @error Then ContinueLoop
            GUICtrlSetData($hFile, $sTmpFile); GUI will be updated at next iteration
        
        Case $iMsg = $GUI_EVENT_CLOSE
            Exit
    
        Case $iMsg = $hFileSel2
            $sTmpFile2 = FileOpenDialog("Select Main Image:", "\", "Alpha Image (*.bmp)")

            If @error Then ContinueLoop
            GUICtrlSetData($hFile2, $sTmpFile2); GUI will be updated at next iteration
        
        Case $iMsg = $GUI_EVENT_CLOSE
            Exit
    
Case $iMsg = $makeportrait
    GUICtrlRead($1x)
    GUICtrlRead($2x)
    GUICtrlRead($playerid)
    GUICtrlRead($hFileSel2)
    GUICtrlRead($hFileSel)
            If $1x = $GUI_CHECKED then $ptype = "1"
            If $2x = $GUI_CHECKED then $ptype = "2"
            DirCreate ( "temp")
            FileCopy ($hFileSel, "temp\0000.bmp")
            FileCopy ($hFileSel2, "temp\0000-a.bmp")
            RunWait( 'makeme.bat' & ' ' & $ptype & ' ' & $playerid & ' ' & 'dog')
            
        Case $iMsg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    
Wend
    



Func _GUIUpdate() 
    For $iCntRow = 0 to 4
        For $iCntCol = 0 to 5
            $iCurIndex = $iCntRow * 6 + $iCntCol
            GUICtrlSetImage($ahIcons[$iCurIndex], $sFilename, $iCurIndex + $iStartIndex)
            GUICtrlSetData($ahLabels[$iCurIndex], $iCurIndex + $iStartIndex)
        Next
    Next

    
EndFunc

Func _GUIUpdate2() 
    For $iCntRow = 0 to 4
        For $iCntCol = 0 to 5
            $iCurIndex = $iCntRow * 6 + $iCntCol
            GUICtrlSetImage($ahIcons[$iCurIndex], $sFilename2, $iCurIndex + $iStartIndex)
            GUICtrlSetData($ahLabels[$iCurIndex], $iCurIndex + $iStartIndex)
        Next
    Next

    
EndFunc

Share this post


Link to post
Share on other sites



Case $iMsg = $makeportrait
            If GUICtrlRead($1x) = $GUI_CHECKED Then $ptype = "1"
            If GUICtrlRead($2x) = $GUI_CHECKED Then $ptype = "2"
            DirCreate("temp")
            FileCopy(GUICtrlRead($hFile), "temp\0000.bmp")
            FileCopy(GUICtrlRead($hFile2), "temp\0000-a.bmp")
            RunWait( 'makeme.bat' & ' ' & $ptype & ' ' & GUICtrlRead($playerid) & ' ' & 'dog')

didn't look over the whole thing, but try changing the case statement with the above.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks alot for the help

incase this helps anyone else here is the complete working script

#include <GUIConstants.au3>
#NoTrayIcon

; Setting variables
FileInstall ( "makeme.exe", @ScriptDir & "\makeme.exe"  )
Global $sFilename = @SystemDir & "\shell32.dll"; Default file is "shell32.dll"
Global $sFilename2 = @SystemDir & "\shell32.dll"; Default file is "shell32.dll"
Global $ptype, $sTmpFile2, $sTmpFile, $hFile2, $hFile, $hFileSel2, $hFileSel, $sCurFilename, $sCurFilename2
; Creating GUI and controls
GUICreate("Portrait Maker - Krawhitham", 385, 265, @DesktopWidth/2 - 192, _
@DesktopHeight/2 - 235, -1, $WS_EX_ACCEPTFILES)
GUISetIcon ("favicon.ico")
GUICtrlCreateGroup("Main Image", 5, 1, 375, 40)
GUICtrlCreateGroup("Alpha Image", 5, 50, 375, 40)

$hFile = GUICtrlCreateEdit($sFilename, 12,  15, 325, 16, $ES_READONLY, $WS_EX_STATICEDGE)
$hFileSel = GUICtrlCreateButton("...", 345,  14, 26, 18)

$hFile2 = GUICtrlCreateEdit($sFilename2, 12,  64, 325, 16, $ES_READONLY, $WS_EX_STATICEDGE)
$hFileSel2 = GUICtrlCreateButton("...", 345,  63, 26, 18)

GUICtrlCreateGroup("Player ID #", 5, 100, 375, 40)
$playerid = GUICtrlCreateInput("", 15, 114, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

GUICtrlCreateGroup("Portrait Size", 5, 150, 375, 70)
$1x = GUICtrlCreateRadio("128x128", 20, 170, 100, 20)
GUICtrlSetState($1x, $GUI_CHECKED)
$2x = GUICtrlCreateRadio("256x256", 20, 190, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$makeportrait = GUICtrlCreateButton("&DO IT", 140, 230, 100)
GUISetState()

While 1
    $iMsg = GUIGetMsg()
  ; Code below will check if the file is dropped (or selected)
    $sCurFilename = GUICtrlRead($hFile) 
    If $sCurFilename <> $sFilename Then
        $sFilename = $sCurFilename
    Endif
    
    $sCurFilename2 = GUICtrlRead($hFile2) 
    If $sCurFilename2 <> $sFilename2 Then
        $sFilename2 = $sCurFilename2
    Endif
    
    
  ; Main "Select" statement that handles other events
    Select
        Case $iMsg = $hFileSel
            $sTmpFile = FileOpenDialog("Select Main Image:", "\", "Main Image (*.bmp)")
            If @error Then ContinueLoop
            GUICtrlSetData($hFile, $sTmpFile); GUI will be updated at next iteration
        
    Case $iMsg = $GUI_EVENT_CLOSE
        FileDelete (@ScriptDir & "\makeme.exe"  )
            Exit
    
        Case $iMsg = $hFileSel2
            $sTmpFile2 = FileOpenDialog("Select Alpha Image:", "\", "Alpha Image (*.bmp)")
            If @error Then ContinueLoop
            GUICtrlSetData($hFile2, $sTmpFile2); GUI will be updated at next iteration
        
    Case $iMsg = $GUI_EVENT_CLOSE
        FileDelete (@ScriptDir & "\makeme.exe"  )
            Exit
    
Case $iMsg = $makeportrait
            If GUICtrlRead($1x) = $GUI_CHECKED Then $ptype = "1x"
            If GUICtrlRead($2x) = $GUI_CHECKED Then $ptype = "2x"
            DirCreate(@ScriptDir & "\temp")
            FileCopy(GUICtrlRead($hFile), @ScriptDir & "\temp\0000.BMP")
            FileCopy(GUICtrlRead($hFile2), @ScriptDir & "\temp\0000-a.BMP")
            RunWait( 'makeme.exe ' & $ptype & ' ' & GUICtrlRead($playerid), @ScriptDir , @SW_HIDE)
            DirCreate(@ScriptDir & "\portraits")
            FileMove(@ScriptDir & "\" & GUICtrlRead($playerid) &".fsh", @ScriptDir & "\portraits\" & GUICtrlRead($playerid) &".fsh")
            GUICtrlSetData ( $playerid, "")
            GUICtrlSetData ( $hFile, @SystemDir & "\shell32.dll")
            GUICtrlSetData ( $hFile2, @SystemDir & "\shell32.dll")
            GUICtrlSetState($1x, $GUI_CHECKED)
            Case $iMsg = $GUI_EVENT_CLOSE
            FileDelete (@ScriptDir & "\makeme.exe"  )
            Exit
    EndSelect
    
Wend
    FileDelete (@ScriptDir & "\makeme.exe"  )
Edited by krawhitham

Share this post


Link to post
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
Sign in to follow this  
Followers 0