Sign in to follow this  
Followers 0
J0ker

Decode Image filepath

6 posts in this topic

#1 ·  Posted (edited)

I made a gui with 99 images. The user can change/delete/replace each images. When he click the button "Done", I want to make a function that will read each images, get the filepath and then create 99 variables based on what the filepath of the image is.

ex:

#Read $Label_1

If the filepath is @ScriptDir & "\Images\8.bmp" then $Label_1 = $ImgA

Here's my script so far:

#include <GuiConstants.au3>


GuiCreate("GRID", 515, 500,-1, -1, BitOR($WS_SYSMENU, $WS_CAPTION))


$Button_1 = GuiCtrlCreateButton("", 350, 30, 35, 35, $BS_BITMAP)
$Button_2 = GuiCtrlCreateButton("", 387, 30, 35, 35, $BS_BITMAP)
$Button_3 = GuiCtrlCreateButton("", 424, 30, 35, 35, $BS_BITMAP)
$Button_4 = GuiCtrlCreateButton("", 461, 30, 35, 35, $BS_BITMAP)
$Button_5 = GuiCtrlCreateButton("", 369, 67, 35, 35, $BS_BITMAP)
$Button_6 = GuiCtrlCreateButton("", 406, 67, 35, 35, $BS_BITMAP)
$Button_7 = GuiCtrlCreateButton("", 443, 67, 35, 35, $BS_BITMAP)

GUICtrlSetImage($Button_1, @ScriptDir & "\Images\1.bmp")
GUICtrlSetImage($Button_2, @ScriptDir & "\Images\2.bmp")
GUICtrlSetImage($Button_3, @ScriptDir & "\Images\3.bmp")
GUICtrlSetImage($Button_4, @ScriptDir & "\Images\4.bmp")
GUICtrlSetImage($Button_5, @ScriptDir & "\Images\5.bmp")
GUICtrlSetImage($Button_6, @ScriptDir & "\Images\6.bmp")
GUICtrlSetImage($Button_7, @ScriptDir & "\Images\7.bmp")


$Button_8 = GuiCtrlCreateButton("", 350, 130, 35, 35, $BS_BITMAP)
$Button_9 = GuiCtrlCreateButton("", 387, 130, 35, 35, $BS_BITMAP)
$Button_10 = GuiCtrlCreateButton("", 424, 130, 35, 35, $BS_BITMAP)
$Button_11 = GuiCtrlCreateButton("", 461, 130, 35, 35, $BS_BITMAP)
$Button_12 = GuiCtrlCreateButton("", 369, 167, 35, 35, $BS_BITMAP)
$Button_13 = GuiCtrlCreateButton("", 406, 167, 35, 35, $BS_BITMAP)
$Button_14 = GuiCtrlCreateButton("", 443, 167, 35, 35, $BS_BITMAP)

GUICtrlSetImage($Button_8, @ScriptDir & "\Images\8.bmp")
GUICtrlSetImage($Button_9, @ScriptDir & "\Images\9.bmp")
GUICtrlSetImage($Button_10, @ScriptDir & "\Images\10.bmp")
GUICtrlSetImage($Button_11, @ScriptDir & "\Images\11.bmp")
GUICtrlSetImage($Button_12, @ScriptDir & "\Images\12.bmp")
GUICtrlSetImage($Button_13, @ScriptDir & "\Images\13.bmp")
GUICtrlSetImage($Button_14, @ScriptDir & "\Images\14.bmp")

$Button_15 = GuiCtrlCreateButton("", 350, 230, 35, 35, $BS_BITMAP)
$Button_16 = GuiCtrlCreateButton("", 387, 230, 35, 35, $BS_BITMAP)
$Button_17 = GuiCtrlCreateButton("", 424, 230, 35, 35, $BS_BITMAP)
$Button_18 = GuiCtrlCreateButton("", 461, 230, 35, 35, $BS_BITMAP)
$Button_19 = GuiCtrlCreateButton("", 369, 267, 35, 35, $BS_BITMAP)
$Button_20 = GuiCtrlCreateButton("", 406, 267, 35, 35, $BS_BITMAP)
$Button_21 = GuiCtrlCreateButton("", 443, 267, 35, 35, $BS_BITMAP)

GUICtrlSetImage($Button_15, @ScriptDir & "\Images\15.bmp")
GUICtrlSetImage($Button_16, @ScriptDir & "\Images\16.bmp")
GUICtrlSetImage($Button_17, @ScriptDir & "\Images\17.bmp")
GUICtrlSetImage($Button_18, @ScriptDir & "\Images\18.bmp")
GUICtrlSetImage($Button_19, @ScriptDir & "\Images\19.bmp")
GUICtrlSetImage($Button_20, @ScriptDir & "\Images\20.bmp")
GUICtrlSetImage($Button_21, @ScriptDir & "\Images\21.bmp")

$Button_22 = GuiCtrlCreateButton("", 369, 330, 35, 35, $BS_BITMAP)
$Button_23 = GuiCtrlCreateButton("", 406, 330, 35, 35, $BS_BITMAP)
$Button_24 = GuiCtrlCreateButton("", 443, 330, 35, 35, $BS_BITMAP)

GUICtrlSetImage($Button_22, @ScriptDir & "\Images\22.bmp")
GUICtrlSetImage($Button_23, @ScriptDir & "\Images\23.bmp")
GUICtrlSetImage($Button_24, @ScriptDir & "\Images\24.bmp")

$Button_25 = GuiCtrlCreateButton("", 369, 393, 35, 35, $BS_BITMAP)
$Button_26 = GuiCtrlCreateButton("", 406, 393, 35, 35, $BS_BITMAP)
$Button_27 = GuiCtrlCreateButton("", 443, 393, 35, 35, $BS_BITMAP)

GUICtrlSetImage($Button_25, @ScriptDir & "\Images\25.bmp")
GUICtrlSetImage($Button_26, @ScriptDir & "\Images\26.bmp")
GUICtrlSetImage($Button_27, @ScriptDir & "\Images\27.bmp")

$Button_DONE = GuiCtrlCreateButton("DONE", 374, 470, 98, 26, $BS_BITMAP)
GUICtrlSetImage($Button_DONE, @ScriptDir & "\Images\Done.bmp")

$File1 = @ScriptDir & "\Images\blank.bmp"

;Images ( I have only putted 7 images but there's 99)
$Label_1 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 9, 110, 35, 35)
$Label_2 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 43, 110, 35, 35)
$Label_3 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 77, 110, 35, 35)
$Label_4 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 111, 110, 35, 35)
$Label_5 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 145, 110, 35, 35)
$Label_6 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 179, 110, 35, 35)
$Label_7 = GuiCtrlCreatePic(@ScriptDir & "\Images\blank.bmp", 213, 110, 35, 35)

GuiSetState()

While 1
    
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        $File1 = @ScriptDir & "\Images\1.bmp"
    Case $msg = $Button_2
        $File1 = @ScriptDir & "\Images\2.bmp"
    Case $msg = $Button_3
        $File1 = @ScriptDir & "\Images\3.bmp"
    Case $msg = $Button_4
        $File1 = @ScriptDir & "\Images\4.bmp"
    Case $msg = $Button_5
        $File1 = @ScriptDir & "\Images\5.bmp"
    Case $msg = $Button_6
        $File1 = @ScriptDir & "\Images\6.bmp"
    Case $msg = $Button_7
        $File1 = @ScriptDir & "\Images\7.bmp"
    Case $msg = $Button_8
        $File1 = @ScriptDir & "\Images\8.bmp"
    Case $msg = $Button_9
        $File1 = @ScriptDir & "\Images\9.bmp"
    Case $msg = $Button_10
        $File1 = @ScriptDir & "\Images\10.bmp"
    Case $msg = $Button_11
        $File1 = @ScriptDir & "\Images\11.bmp"      
    Case $msg = $Button_12
        $File1 = @ScriptDir & "\Images\12.bmp"
    Case $msg = $Button_13
        $File1 = @ScriptDir & "\Images\13.bmp"
    Case $msg = $Button_14
        $File1 = @ScriptDir & "\Images\14.bmp"
    Case $msg = $Button_15
        $File1 = @ScriptDir & "\Images\15.bmp"
    Case $msg = $Button_16
        $File1 = @ScriptDir & "\Images\16.bmp"
    Case $msg = $Button_17
        $File1 = @ScriptDir & "\Images\17.bmp"
    Case $msg = $Button_18
        $File1 = @ScriptDir & "\Images\18.bmp"
    Case $msg = $Button_19
        $File1 = @ScriptDir & "\Images\19.bmp"      
    Case $msg = $Button_20
        $File1 = @ScriptDir & "\Images\20.bmp"
    Case $msg = $Button_21
        $File1 = @ScriptDir & "\Images\21.bmp"
    Case $msg = $Button_22
        $File1 = @ScriptDir & "\Images\22.bmp"
    Case $msg = $Button_23
        $File1 = @ScriptDir & "\Images\23.bmp"
    Case $msg = $Button_24
        $File1 = @ScriptDir & "\Images\24.bmp"
    Case $msg = $Button_25
        $File1 = @ScriptDir & "\Images\25.bmp"
    Case $msg = $Button_26
        $File1 = @ScriptDir & "\Images\26.bmp"      
    Case $msg = $Button_27
        $File1 = @ScriptDir & "\Images\27.bmp"
    Case $msg = $Label_1
        GuiCtrlSetImage($Label_1, $File1)
    Case $msg = $Label_2
        GuiCtrlSetImage($Label_2, $File1)
    Case $msg = $Label_3
        GuiCtrlSetImage($Label_3, $File1)
    Case $msg = $Label_4
        GuiCtrlSetImage($Label_4, $File1)
    Case $msg = $Label_5
        GuiCtrlSetImage($Label_5, $File1)
    Case $msg = $Label_6
        GuiCtrlSetImage($Label_6, $File1)
    Case $msg = $Label_7
        GuiCtrlSetImage($Label_7, $File1)


    Case $msg = $Button_DONE
        ;Function will go here

    EndSelect
WEnd
Exit

Wich command should I use to read the values of an image?

Edited by J0ker

Share this post


Link to post
Share on other sites



Nobody?

Share this post


Link to post
Share on other sites

:shocked:

If we understood what you were asking for it would probably help..:(

Do you want to know how to keep track of the images you have loaded?

Share this post


Link to post
Share on other sites

You could keep the file path and write all 99 of them into a textfile


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Your right, I wasnt very clear...

Yes I want to know how to keep track of an images that the user have loaded. The user can modify the image and I have to know to wich image he changed it to. It's why I want to keep track of the filepath(filename) so that way I can know he changed the image to what.

Is there a way to get the filepath from an image modified with GuiCtrlSetImage ?

You could keep the file path and write all 99 of them into a textfile

Yes I could do that but It would made an extra ini file and the lesser, the better. But If I want to do that, I need to find a way to keep track of this image.

Hmm.. I could make an invisible ini file that will be deleted when the action will be over.

Edited by J0ker

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

K fine I will use Iniwrite.

Case $msg = $Label_1
        GuiCtrlSetImage($Label_1, $File1)
IniWrite(@SCRIPTDIR & "\Config.ini", "Grid", "1", $File1)

How can I set the ini file to be an hidden file?

Edited by J0ker

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