Jump to content

Go To Next Image.. Go Back Image


Recommended Posts

Hi there.. I'm trying to get autoit go through images, in order, and then I can go back images by pressing back, I tried it with arrays.. I don't know whats next, so i just did it the way i know..

heres the image.. it should be different colors for 1 through 5.. i uploaded it as bmp but imageshack made it a png image..

http://img148.imageshack.us/img148/6692/1image2dw.png

#include <GUIConstants.au3>
$Form1 = GUICreate("NextImage", 414, 305, 246, 194)
;~ Dim $Pick[5]
;~ $Pick[1]= GUICtrlCreatePic(@ScriptDir&"\1image.bmp", 8, 8, 393, 233)
;~ $Pick[2]= GUICtrlCreatePic(@ScriptDir&"\2image.bmp", 8, 8, 393, 233)
;~ $Pick[3]= GUICtrlCreatePic(@ScriptDir&"\3image.bmp", 8, 8, 393, 233)
;~ $Pick[3]= GUICtrlCreatePic(@ScriptDir&"\4image.bmp", 8, 8, 393, 233)

$Pick = GUICtrlCreatePic(@ScriptDir&"\1image.bmp", 8, 8, 393, 233)
$Back= GUICtrlCreateButton("Back", 160, 256, 97, 41)
$Next = GUICtrlCreateButton("Next", 264, 256, 97, 41)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Back
        GUICtrlCreatePic("1image.bmp", 8, 8, 393, 233)
        GUICtrlCreatePic("2image.bmp", 8, 8, 393, 233)
        GUICtrlCreatePic("3image.bmp", 8, 8, 393, 233)
    Case $msg = $Next
        GUICtrlCreatePic("2image.bmp", 8, 8, 393, 233)
        GUICtrlCreatePic("3image.bmp", 8, 8, 393, 233)
        GUICtrlCreatePic("4image.bmp", 8, 8, 393, 233)
    Case Else
    EndSelect
WEnd
Exit
Edited by slightly_abnormal
Link to comment
Share on other sites

1

make sure you fix this...

;~ $Pick[2]= GUICtrlCreatePic(@ScriptDir&"\2image.bmp", 8, 8, 393, 233)

;~ $Pick[3]= GUICtrlCreatePic(@ScriptDir&"\3image.bmp", 8, 8, 393, 233)

;~ $Pick[3]= GUICtrlCreatePic(@ScriptDir&"\4image.bmp", 8, 8, 393, 233)

2

use guictrlsetsate( control id, $GUI_HIDE)... and $GUI_SHOW in the loop

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I dont know what i'm doing :)

#include <GUIConstants.au3>
$Form1 = GUICreate("NextImage", 414, 305, 246, 194)
Dim $Pick[5]
$Pick[1]= GUICtrlCreatePic(@ScriptDir&"\1image.bmp", 8, 8, 393, 233)
$Pick[2]= GUICtrlCreatePic(@ScriptDir&"\2image.bmp", 8, 8, 393, 233)
$Pick[3]= GUICtrlCreatePic(@ScriptDir&"\3image.bmp", 8, 8, 393, 233)
$Pick[4]= GUICtrlCreatePic(@ScriptDir&"\4image.bmp", 8, 8, 393, 233)

$Pic = $Pick[1]
$Back= GUICtrlCreateButton("Back", 160, 256, 97, 41)
$Next = GUICtrlCreateButton("Next", 264, 256, 97, 41)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Back
        Guictrlsetstate($Pic,$Pick[1] -1)
    Case $msg = $Next
        Guictrlsetstate($Pic,$Pick[1] +1)
    Case Else
    EndSelect
WEnd
Exit
Link to comment
Share on other sites

:) Now it does the same thing?

#include <GUIConstants.au3>
$Form1 = GUICreate("NextImage", 414, 305, 246, 194)
;~ Dim $Pick[5]
;~ $Pick[1]= GUICtrlCreatePic(@ScriptDir&"\1image.bmp", 8, 8, 393, 233)
;~ $Pick[2]= GUICtrlCreatePic(@ScriptDir&"\2image.bmp", 8, 8, 393, 233)
;~ $Pick[3]= GUICtrlCreatePic(@ScriptDir&"\3image.bmp", 8, 8, 393, 233)
;~ $Pick[4]= GUICtrlCreatePic(@ScriptDir&"\4image.bmp", 8, 8, 393, 233)

$Pic = GUICtrlCreatePic(@ScriptDir&"\1image.bmp", 8, 8, 393, 233)
$Back= GUICtrlCreateButton("Back", 160, 256, 97, 41)
$Next = GUICtrlCreateButton("Next", 264, 256, 97, 41)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Back
        GUICtrlSetState($Pic, $GUI_HIDE)
        GUICtrlCreatePic(@ScriptDir&"\1image.bmp", 8, 8, 393, 233)
        GUICtrlSetState($Pic, $GUI_SHOW)
        
        GUICtrlSetState($Pic, $GUI_HIDE)
        GUICtrlCreatePic(@ScriptDir&"\2image.bmp", 8, 8, 393, 233)
        GUICtrlSetState($Pic, $GUI_SHOW)
        
        GUICtrlSetState($Pic, $GUI_HIDE)
        GUICtrlCreatePic(@ScriptDir&"\3image.bmp", 8, 8, 393, 233)
        GUICtrlSetState($Pic, $GUI_SHOW)
    Case $msg = $Next
        GUICtrlSetState($Pic, $GUI_HIDE)
        GUICtrlCreatePic(@ScriptDir&"\2image.bmp", 8, 8, 393, 233)
        GUICtrlSetState($Pic, $GUI_SHOW)
        
        GUICtrlSetState($Pic, $GUI_HIDE)
        GUICtrlCreatePic(@ScriptDir&"\3image.bmp", 8, 8, 393, 233)
        GUICtrlSetState($Pic, $GUI_SHOW)
        
        GUICtrlSetState($Pic, $GUI_HIDE)
        GUICtrlCreatePic(@ScriptDir&"\4image.bmp", 8, 8, 393, 233)
        GUICtrlSetState($Pic, $GUI_SHOW)
    Case Else
    EndSelect
WEnd
Exit
:(:D Edited by slightly_abnormal
Link to comment
Share on other sites

eh.. help? :)

ok... try this.......... EDIT - TESTED OK!!!

#include <GUIConstants.au3>

Dim $Pick[5], $pics = 4


$Form1 = GUICreate("NextImage", 414, 305, 246, 194)
$Pick[1]= GUICtrlCreatePic(@ScriptDir&"\1image.bmp", 8, 8, 393, 233)
$Pick[2]= GUICtrlCreatePic(@ScriptDir&"\2image.bmp", 8, 8, 393, 233)
GUICtrlSetState( -1, $GUI_HIDE)
$Pick[3]= GUICtrlCreatePic(@ScriptDir&"\3image.bmp", 8, 8, 393, 233)
GUICtrlSetState( -1, $GUI_HIDE)
$Pick[4]= GUICtrlCreatePic(@ScriptDir&"\4image.bmp", 8, 8, 393, 233)
GUICtrlSetState( -1, $GUI_HIDE)
$notice = GUICtrlCreateLabel("Picture #1", 20, 258, 100, 30)
GUICtrlSetFont( -1, 15, 700)
$Back= GUICtrlCreateButton("Back", 160, 256, 97, 41)
$Next = GUICtrlCreateButton("Next", 264, 256, 97, 41)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Back
        $set = -1
        get_pic($set)
        
    Case $msg = $Next
        $set = 1
        get_pic($set)
    Case Else
    EndSelect
WEnd
Exit


Func get_pic($t)
    For $x = 1 to $pics
        $State = GUICtrlGetState($pick[$x])
        If $State = 80 Then
        If $x = 1 And $t = -1 Then Return
        If $x = $pics And $t = 1 Then Return
        Guictrlsetstate($Pick[$x], $GUI_HIDE)
        Guictrlsetstate($Pick[$x + $set], $GUI_SHOW)
        GUICtrlSetData($notice, "Picture #" & $x + $set)
        Return
        EndIf
    Next
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

all pics in a folder

;********* USER INPUT **************
$Location = @ScriptDir & "\"
$Type = "*.bmp"   ; bmp, jpg ...whatever you want
;***********************************


#include <GUIConstants.au3>
#Include <File.au3>

$FileList=_FileListToArray($Location, $Type, 1) 
If (Not IsArray($FileList)) Or (@Error=1) Then
    MsgBox (0,"Sorry!","No Pictures Found.   ", 3)
    Exit
EndIf

$num = UBound($FileList) -1
Dim $Pick[$num + 1]

$Form1 = GUICreate("NextImage", 414, 305, 246, 194)
$Pick[1]= GUICtrlCreatePic($Location&$FileList[1], 8, 8, 393, 233)
for $x = 2 to $num
$Pick[$x]= GUICtrlCreatePic($Location&$FileList[$x], 8, 8, 393, 233)
GUICtrlSetState( -1, $GUI_HIDE)
Next
$notice = GUICtrlCreateLabel("Picture #1", 20, 258, 130, 30)
GUICtrlSetFont( -1, 15, 700)
$Back= GUICtrlCreateButton("Back", 160, 256, 97, 41)
$Next = GUICtrlCreateButton("Next", 264, 256, 97, 41)
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Back
        $set = -1
        get_pic($set)
        
    Case $msg = $Next
        $set = 1
        get_pic($set)
    Case Else
    EndSelect
WEnd
Exit


Func get_pic($t)
    For $x = 1 to $num
        $State = GUICtrlGetState($pick[$x])
        If $State = 80 Then
        If $x = 1 And $t = -1 Then Return
        If $x = $num And $t = 1 Then Return
        Guictrlsetstate($Pick[$x], $GUI_HIDE)
        Guictrlsetstate($Pick[$x + $set], $GUI_SHOW)
        GUICtrlSetData($notice, "Picture #" & $x + $set)
        Return
        EndIf
    Next
EndFunc

8)

Edited by Valuater

NEWHeader1.png

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