Sign in to follow this  
Followers 0
RichE

Guildwars Screenshot convertor

1 post in this topic

#1 ·  Posted (edited)

Guildwars churns out its screenshots in .bmp format, so as you can guess their hugh, so I wrote this util to allow you to do the following:Preview your .bmp format screenshots

Convert images to .jpgs (much smaller size for uploading to the web)

Resize the screenshot at time of conversion

Open the screenshots dir

thumbnail creator added

delete original BMP files to recycle bin

it uses a third party cmd line program to do the conversion/resizing called imageconsole, it does have other functions, and I may add them at a later date.

two files are needed to compile the code, imageconsole.exe and blank.jpg, both of these can be downloaded by getting the previous version of GWSSC from the link at the bottom.

this could be a frame work for someone looking to do a similar thing with images/screenshot so I hope it helps someone. :P

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.1.1.0
 Author:         Riche

 Script Function:
    GW Screenshot conversion util.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

;variables start
$ver = 1.2
$EXEpath = regread("HKLM\SOFTWARE\ArenaNet\Guild Wars", "Path")

if not fileexists($exepath) Then
    msgbox(48, "Guildwars", "The guildwars executable has not been detected", 5)
    Exit
EndIf

fileinstall("imageconsole.exe", "c:\GWSSC\", 1)
fileinstall("blank.jpg", "c:\GWSSC\", 1)

$path = StringtrimRight($exepath, 6) & "screens\"
Dim  $PICLIST
;variables end
#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>
#include <file.au3>


Opt("GUIOnEventMode", 1)

;gui start
GuiCreate("GWSSC", 660, 429,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")

GuiCtrlCreateGroup("Guildwars Screenshots Convertor V" & $ver, 10, 10, 640, 410)

GuiCtrlCreateGroup("Screenshots", 20, 30, 200, 80)
$piccombo = GuiCtrlCreateCombo("Please Select Image", 30, 50, 180, 21)
$Preview = GuiCtrlCreateButton("Preview", 30, 80, 50, 20)
GUICtrlSetOnEvent(-1, "Preview")

$Delete = GuiCtrlCreateButton("Delete", 160, 80, 50, 20)
GUICtrlSetOnEvent(-1, "delete")

$Convert = GuiCtrlCreateButton("Convert", 90, 80, 60, 20)
GUICtrlSetOnEvent(-1, "Convert")

GuiCtrlCreateGroup("Preview Window", 230, 30, 410, 380)
$Image = GUICtrlCreatePic("blank.jpg", 240, 45, 390, 360)


GuiCtrlCreateGroup("Resize Options", 20, 120, 200, 80)
$resize = guictrlcreatecombo("Resize options", 30, 140, 180, 20)
guictrlsetdata($resize, "640x480|800x600|1024x768|1280x768|1280x1024", "")
$resize_yn = GUICtrlCreateCheckbox("Resize Image", 35, 170, 180, 20)
guictrlsetstate($resize_yn, $GUI_UNCHECKED)

GuiCtrlCreateGroup("Thumbnail option", 20, 200, 200, 40)
$thumb = GUICtrlCreateCheckbox("Create thumbnail", 35, 215, 180, 20)
guictrlsetstate($resize_yn, $GUI_UNCHECKED)


GUICtrlCreateButton("Open Guildwars Screens Dir", 20, 390, 200, 20)
GUICtrlSetOnEvent(-1, "Open")

;search for BMP files in guildwars dir
$search = FileFindFirstFile($path & "*.bmp")

While 1
$file = FileFindNextFile($search)
        If @error Then ExitLoop
    If $file = "." Then
    ElseIf $file = ".." Then
    sleep(10)
    Else
        guictrlsetdata($piccombo, $file & "|")
    EndIf
WEnd

FileClose($search)

;functions
func open()
; opens screenshots dir
    Run(@ComSpec & " /c " & 'explorer.exe ' & $path, $path, @SW_HIDE)
EndFunc

func preview()
    #cs
     check to see if an image is selected, if not then msg the user
     else read the image name and set it as the preview image
    #ce
    
    if Guictrlread($piccombo) = "Please Select Image" Then
        msgbox(64, "Information", "No BMP file selected", 3)
    Else
        $pic = $path & GUICtrlRead($piccombo)
        guictrlsetimage($Image, $pic)
    EndIf
EndFunc

func convert()
    #cs
     check to see if the checkbox is tick or untick,
     if not then check for image selection, if none selected then msg the user
     else read in the image name and path, and trim the last 4 characters from the right and replace with jpg
     then convert the image using imageconsole.exe and msg the output file to the user.
    #ce
    
    if guictrlread($resize_yn) = 4  Then
        if Guictrlread($piccombo) = "Please Select Image" Then
            msgbox(64, "Information", "No BMP file selected", 3)
        Else
            if guictrlread($thumb) = 4 Then
                $pic = """" & $path & GUICtrlRead($piccombo) & """"
                $convert = StringTrimRight($pic, 5)
                $jpg = $convert & ".jpg" & """"
                Run("imageconsole /convert " & $pic & " " & $jpg , "", @SW_hide)
                $output = stringtrimright(GUICtrlRead($piccombo), 3)
                msgbox(64, "conversion complete", GUICtrlRead($piccombo) & " has been converted to " & $output & "jpg", 5)
            Else
                $pic = """" & $path & GUICtrlRead($piccombo) & """"
                $convert = StringTrimRight($pic, 5)
                $jpg = $convert & ".jpg" & """"
                $tjpg = $convert & "_thumb.jpg" & """"
                Run("imageconsole /convert " & $pic & " " & $jpg , "", @SW_hide)
                Run("imageconsole /thumb /thumbwidth:150 /thumbheight:150 /red:255 /green:255 /blue:255 " & $pic & " " & $tjpg , "", @SW_hide)
                $output = stringtrimright(GUICtrlRead($piccombo), 3)
                $thumbout = stringtrimright(GUICtrlRead($piccombo), 4) & "_thumb.jpg"
                msgbox(64, "conversion complete", GUICtrlRead($piccombo) & " has been converted " & @CR & "and thumbnail created called " & $thumbout, 5)
            EndIf
        EndIf
    Else

    #cs
     if ticked then check for image selection, if none selected then msg the user
     read in the image name and path, and trim the last 4 characters from the right and replace with jpg
     check the resize option/s is selected, if not msg the user
     then convert and resize the image using imageconsole.exe and msg the output file to the user.
    #ce
    
        if Guictrlread($resize_yn) = 1 Then
            if guictrlread($resize) = "Resize options" Then
                msgbox(48, "Warning!", "Incorrect resize options selcted", 3)
            Else
                if Guictrlread($piccombo) = "Please Select Image" Then
                    msgbox(64, "Information", "No BMP file selected", 3)
                Else
                    if guictrlread($thumb) = 4 Then
                        $pic = """" & $path & GUICtrlRead($piccombo) & """"
                        $convert = StringTrimRight($pic, 5)
                        $jpg = $convert & ".jpg" & """"
                        $size = stringsplit(guictrlread($resize), "x", 0)
                        Run("imageconsole /resize /width:" & $size[1] & " /height:" & $size[2] & " " & $pic & " " & $jpg , "", @SW_hide)
                        $output = stringtrimright(GUICtrlRead($piccombo), 3)
                        msgbox(64, "conversion complete", GUICtrlRead($piccombo) & " has been converted and resized(" & guictrlread($resize) & ") to " & $output & "jpg", 5)
                    Else
                        $pic = """" & $path & GUICtrlRead($piccombo) & """"
                        $convert = StringTrimRight($pic, 4)
                        $jpg = $convert & "jpg" & """"
                        $size = stringsplit(guictrlread($resize), "x", 0)
                        Run("imageconsole /resize /width:" & $size[1] & " /height:" & $size[2] & " " & $pic & " " & $jpg , "", @SW_hide)
                        Run("imageconsole /thumb /thumbwidth:150 /thumbheight:150 /red:255 /green:255 /blue:255 " & $pic & " " & $tjpg , "", @SW_hide)
                        $output = stringtrimright(GUICtrlRead($piccombo), 3) & "jpg"
                        $thumbout = stringtrimright(GUICtrlRead($piccombo), 4) & "_thumb.jpg"
                        msgbox(64, "conversion complete", GUICtrlRead($piccombo) & " has been converted " & @CR & "and resized(" & guictrlread($resize) & ") to " & $output & @CR & "and thumbnail created called " & $thumbout, 5)
                    EndIf
                EndIf

            EndIf
        EndIf
    EndIf
EndFunc

func delete()
    #cs
     check to see if an image is selected, if not then msg the user
     read in path and image name and move file to recycle bin
     msg user that filename has been moved to recycle bin
    #ce
    
    if Guictrlread($piccombo) = "Please Select Image" Then
        msgbox(64, "Information", "No BMP file selected", 3)
    Else
        $file = $path & GUICtrlRead($piccombo)
        filerecycle($file)
        msgbox(48, "Image deleted", GUICtrlRead($piccombo) & " has been moved to the recycle bin", 5)
    EndIf
EndFunc


Func SpecialEvents()
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            Exit
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
        EndSelect
EndFunc

GuiSetState()
While 1
    Sleep(200)
WEnd
Exit

GWSSC v1.2 can be downloaded here

Edited by l15ard

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

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