A few questions...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

A few questions...

Post by Hellbent » 01 Aug 2021, 18:31

I have this image selector prototype that I'm working on, I'm almost done with the prototype and just have a few questions about a few things to move to the next phase.

Question 1:

I am looking for a good way to make scrolling the dropdownlist with the mouse wheel a bit faster. My backup plan atm is to look at how long has passed since the last time the wheel is moved and if under some amount, increase the increment used for scrolling. Anyone have any other ideas about how to do it?

Temp (1).gif
Temp (1).gif (464.84 KiB) Viewed 555 times
Relevant code:

Code: Select all

WM_MOUSEWHEEL( wparam ) {
	static lastTime 
	;~ ToolTip, % wparam
	MouseGetPos,,, win
	if( win != Master.Gui2.Hwnd )
		return
	
	if( Master.DDL.Active ){
		
		if( wparam < 0 ){
			Master.Index++
			if( Master.Index > ( Master.FullPath.Length() - 10 ) + 1 ){
				Master.Index := ( Master.FullPath.Length() - 10 ) + 1
				return
			}
			;~ SoundBeep, 500
			Master.Gui2.ClearWindow()
			Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
			Master.Gui2.UpdateWindow()
			Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
			SetImageList( Master )
			_UpdateGraphics( Master )
			;~ Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
			;~ Master.Gui3.UpdateWindow()
			SetDisplayWindow()
		}else if( wparam > 0 ){
			Master.Index--
			if( Master.Index < 1 ){
				Master.Index := 1
				return
			}
			;~ SoundBeep, 500
			Master.Gui2.ClearWindow()
			Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
			Master.Gui2.UpdateWindow()
			Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
			SetImageList( Master )
			_UpdateGraphics( Master )
			;~ Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
			;~ Master.Gui3.UpdateWindow()
			SetDisplayWindow()
		}
		
	}
}




Question 2:
There are a number of optimizations that I will be making once I am done prototyping, one of which is to improve is the image loading and display.
It works fine with small images but once you get into ones that are 3000px x 4000px things can become a bit more sluggish. I had heard about using a thumbnail, but the closest thing I found was about taking a bitmap of a image, resizing it and saving it to a new bitmap. This might work but I'm not sure. Thoughts?

As it is now, I get a bitmap of a image, resize it and display it.

Code: Select all

SetImageList( obj ){
    static ft := 1
    x := 180
    if( ft && !ft := !ft ){
        obj.Bitmaps := [] , obj.MaxSize := 66 , obj.ImageBoxSize := 70
        obj.Index := 1
		
    }
    
    Loop, % obj.FullPath.Length()  {
		if( obj.BitMaps[ A_Index ].Bitmap )
			Gdip_DisposeImage(  obj.BitMaps[ A_Index ].Bitmap )
		else
			obj.BitMaps[ A_Index ] := {}
        
        obj.BitMaps[ A_Index ].Bitmap := Gdip_CreateBitmapFromFile( obj.FullPath[ A_Index + obj.Index - 1 ] )
        ResizeIt( obj.BitMaps[ A_Index ].Bitmap , Width , Height , obj.MaxSize )
        obj.BitMaps[ A_Index ].X := x + ( obj.ImageBoxSize - Width ) / 2
        obj.BitMaps[ A_Index ].Y := 4 + ( obj.ImageBoxSize - Height ) / 2
        obj.BitMaps[ A_Index ].Width := Width
        obj.BitMaps[ A_index ].Height := Height
        obj.BitMaps[ A_index ].ActualFilePosition := A_Index + obj.Index - 1
        if( A_Index = 10 )
            break
        x += obj.ImageBoxSize    
    }

}

Question 3:
I don't work with files all that often, what would be a good way to get this to use any image type?

Code: Select all

_LoadImageList( obj , loadit := 0 ){
    local index := 0 , Fileinput := ""
    IniRead Fileinput , % A_ScriptFullPath , MyPath , Path , ""
    if( !Fileinput || loadit ){
        Gui, 1:+OwnDialogs
        FileSelectFolder, Fileinput 
		if( !Fileinput )
			return
        IniWrite, % Fileinput , % A_ScriptFullPath , MyPath, path
    }
	obj.FullPath := []
    obj.Index := 1
    Loop, % Fileinput "\*.png"
        obj.FullPath[ ++Index ] := A_LoopFileFullPath
    SetImageList( obj )
}
Thanks.

Full Script (*Windows 8+)

Code: Select all

/*
    [MyPath]
    path=
*/
;***************************************************************************************************
#Include <My Altered Gdip Lib>   ;Replace with your path to the Gdip.ahk lib
;***************************************************************************************************
;~ #Include <PopUpWindow Class> ;I have included this class at the bottom of the script
;***************************************************************************************************
#SingleInstance force
#NoEnv
SetBatchLines, -1
GDIP_StartUp()

global Master := _CreateControlObjects()

_LoadImageList( Master )
_CreateWindows( Master )
_AddControls( Master )
_CreateDisplayWindow( Master )

OnMessage( 0x200 , "WatchMouse" )
OnMessage( 0x201 , "WatchClick" )
OnMessage(0x020A, "WM_MOUSEWHEEL")

Gui, 1:Show

Return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

Numpad3::
    PopUpWindow.Helper()
    Return

WM_MOUSEWHEEL( wparam ) {
	static lastTime 
	;~ ToolTip, % wparam
	MouseGetPos,,, win
	if( win != Master.Gui2.Hwnd )
		return
	
	if( Master.DDL.Active ){
		
		if( wparam < 0 ){
			Master.Index++
			if( Master.Index > ( Master.FullPath.Length() - 10 ) + 1 ){
				Master.Index := ( Master.FullPath.Length() - 10 ) + 1
				return
			}
			;~ SoundBeep, 500
			Master.Gui2.ClearWindow()
			Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
			Master.Gui2.UpdateWindow()
			Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
			SetImageList( Master )
			_UpdateGraphics( Master )
			;~ Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
			;~ Master.Gui3.UpdateWindow()
			SetDisplayWindow()
		}else if( wparam > 0 ){
			Master.Index--
			if( Master.Index < 1 ){
				Master.Index := 1
				return
			}
			;~ SoundBeep, 500
			Master.Gui2.ClearWindow()
			Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
			Master.Gui2.UpdateWindow()
			Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
			SetImageList( Master )
			_UpdateGraphics( Master )
			;~ Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
			;~ Master.Gui3.UpdateWindow()
			SetDisplayWindow()
		}
		
	}
}

_CreateDisplayWindow( obj ){
	obj.Gui3 := New PopUpWindow( { WindowName: "3" , WindowOptions: " -DPIScale +AlwaysOnTop +Owner1 " , WindowSmoothing: 2 , X: obj.Gui1.X + 120 , Y: obj.Gui1.Y - 310 , W: 900 , H: 310 } )
    obj.Gui3.ShowWindow()
    ;~ obj.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
    ;~ obj.Gui3.UpdateWindow()
}

_CreateDDLWindow(){
	
	if( Master.Gui2 ){
		Master.Gui2.DeleteWindow()
	}
	
	Master.Gui2 := New PopUpWindow( { WindowName: "2" , WindowOptions: " -DPIScale +AlwaysOnTop +Owner1" , WindowSmoothing: 2 , X: Master.Gui1.X + 21 , Y: Master.Gui1.Y + 10 , W: 330 , H: 280 } )
	Master.Gui2.ShowWindow()
	Master.Gui2.ClearWindow()
	;~ Master.Gui2.PaintBackground( color := "0xFF000000" )
	Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
	Master.Gui2.UpdateWindow()
	
	;~ ToolTip, % "here`n" Master.Gui2.Hwnd "`n" ctrl
	
	Master.DDL.Handles := []
	Master.DDL.ListStartPosition := Master.Index
	Master.DDL.Active := 1
	Master.DDL.HoverActive := 0
	
	Master.DDL.SliderButtonY := 7
	
	y := 5
	loop, % 13	{
		Gui, 2:Add, Text, % "x" 5 " y" y " w" 290 " h" 20 " hwndhwnd gSelectDDLItem" 
		
		Master.DDL.Handles[ hwnd ] := A_Index
	
		y += 21
		
	}
	
	Gui, 2:Add, Text, % "x" 300 " y" 5 " w" 25 " h" 230 " gAdjustDDLSlider" 
	
	Gui, 2:Add, Text, % "x" 300 " y" 239 " w" 25 " h" 36 " gDDLClose" 
}

DDLClose(){
	Master.DDL.Active := 0
	Master.Gui2.DeleteWindow()
}

_AdjustSlider(){
    local x, lx
    CoordMode, Mouse, Client
    SetBatchLines, 20ms
	Master.SliderMoving := 1
    While( GetKeyState( "LButton" ) ){
        MouseGetPos, x
        x -= 7
        ( x < 240 ) ? ( x := 240 ) : ( ( x > 806 ) ? ( x := 806 ) )
        Master.SliderButtonX := x
        if( x != lx ){
            lx := x
            Master.Index := floor( ( x - 240 ) / ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) ) + 1
            SetImageList( Master )
            _UpdateGraphics( Master )
            
        }
		sleep, 30
    }
    SetBatchLines, -1
	Master.SliderMoving := 0
}

AdjustDDLSlider(){
	local y, ly
	Master.DDL.MovingSlider := 1
	CoordMode, Mouse, Client
	While( GetKeyState( "LButton" ) ){
        MouseGetPos,, y
        y -= 45  ; button / 2 offset
        ( y < 7 ) ? ( y := 7 ) : ( ( y > 140  ) ? ( y := 140  ) )
        Master.DDL.SliderButtonY := y
        if( y != ly ){
            ly := y
            Master.Index := floor( ( y - 7 ) / ( ( 140 - 7 ) / ( Master.FullPath.Length() - 10 ) ) ) + 1
            Master.Gui2.ClearWindow()
			Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
			Master.Gui2.UpdateWindow()
			;~ sleep, 30
			;~ SetTimer, DrawRoutine, -10
        }
		sleep, 30
    }
	SetImageList( Master )
	SetTimer, DrawRoutine, -10
	Master.DDL.MovingSlider := 0
}

SelectDDLItem:
	;~ soundbeep, 500
	MouseGetPos,,,, ctrl, 2
	;~ ToolTip, % Master.DDL.Handles[ ctrl ] + Master.SelectedImage - 1
	;~ Master.SelectedImage := Master.DDL.Handles[ ctrl ] + Master.DDL.ListStartPosition - 1
	Master.SelectedImage := Master.DDL.Handles[ ctrl ] + Master.Index - 1
	( Master.SelectedImage > Master.FullPath.Length() ) ? ( Master.SelectedImage := Master.FullPath.Length() )
	if( Master.DDL.Handles[ ctrl ] > 10 && Master.SelectedImage != Master.FullPath.Length())
		Master.Index += Master.DDL.Handles[ ctrl ] - 10 
	Master.Gui2.ClearWindow()
	Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
	Master.Gui2.UpdateWindow()
	
	SetImageList( Master )
	SetTimer, DrawRoutine, -10
	;~ ToolTip, % Master.SelectedImage "`n" Master.Index
	return

WatchMouse(){
    if( Master.Moving )
        return
    MouseGetPos,,,, ctrl, 2
	if( !Master.DDL.Active ){
		if( Master.Handles[ctrl] && !Master.Active && Master.Controls[ Master.Handles[ ctrl ] ].Name && !Master.SliderMoving ){
			Master.Active := Master.Handles[ctrl]
			SetTimer, DrawRoutine, -10
			SetTimer, WatchButtonLeave, -30
		}else if( Master.Controls[ Master.Handles[ ctrl ] ].Position && ! Master.Display.Hover && !Master.SliderMoving ){
			;~ soundbeep, 500
			Master.Display.Hover := Master.Controls[ Master.Handles[ ctrl ] ].Position
			SetDisplayWindow()
			sleep, 30
			SetTimer, WatchLeaveDisplay, 60
		}
	}else if( Master.DDL.Active && !Master.DDL.MovingSlider ){
		if( Master.DDL.Handles[ctrl] && !Master.DDL.HoverActive ){
			Master.DDL.HoverActive := Master.DDL.Handles[ctrl]
			Master.Gui2.ClearWindow()
			Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
			Master.Gui2.UpdateWindow()
			Master.Display.Hover := Master.DDL.HoverActive
			SetDisplayWindow()
			SetTimer, WatchListLeave, 60
		}
	}
}

WatchLeaveDisplay:
	MouseGetPos,,,, ctrl, 2
	if( Master.Controls[ Master.Handles[ ctrl ] ].Position != Master.Display.Hover ){
		if( Master.Controls[ Master.Handles[ ctrl ] ].Position ){
			Master.Display.Hover := Master.Controls[ Master.Handles[ ctrl ] ].Position
			SetDisplayWindow()
			
		}else	{
			SetTimer, WatchLeaveDisplay, Off
			Master.Gui3.ClearWindow()
			Master.Gui3.UpdateWindow()
			Sleep, 30
			Master.Display.Hover := 0
		}
	}
	return

SetDisplayWindow(){
	local pBitmap
	Master.Gui3.ClearWindow()
	Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
	
	;~ Master.Gui3.DrawBitmap( pBitmap := "" , { X: "" , Y: "" , W: "" , H: "" } , dispose := 1 )
	;~ Master.Gui3.DrawBitmap( pBitmap := "" , { X: "" , Y: "" , W: "" , H: "" } , dispose := 1 )
	;~ Master.Gui3.UpdateWindow()
	
	;left side
	 
	pBitmap := Gdip_CreateBitmapFromFile( Master.FullPath[ Master.Display.Hover + Master.Index - 2 ] )
	ResizeIt( pBitmap , Width , Height , 200 )
	x := 10 + ( 200 - Width ) / 2
	y := 100 + ( 200 - Height ) / 2
	Master.Gui3.DrawBitmap( pBitmap , { X: x , Y: y , W: Width , H: Height } , dispose := 1 )
	
	pBitmap := Gdip_CreateBitmapFromFile( Master.FullPath[ Master.Display.Hover + Master.Index - 1 ] )
	ResizeIt( pBitmap , Width , Height , 300 )
	x := 223 + ( 300 - Width ) / 2
	y := 5 + ( 300 - Height ) / 2
	Master.Gui3.DrawBitmap( pBitmap , { X: x , Y: y , W: Width , H: Height } , dispose := 1 )
	
	pBitmap := Gdip_CreateBitmapFromFile( Master.FullPath[ Master.Display.Hover + Master.Index ] )
	ResizeIt( pBitmap , Width , Height , 200 )
	x := 540 + ( 200 - Width ) / 2
	y := 100 + ( 200 - Height ) / 2
	Master.Gui3.DrawBitmap( pBitmap , { X: x , Y: y , W: Width , H: Height } , dispose := 1 )
	
    Master.Gui3.UpdateWindow()  
;~ ToolTip, % "here`n" Height	
}


WatchClick(){
	if( Master.DDL.Active && WinActive() != Master.Gui2.Hwnd ){
		Master.DDL.Active := 0
		Master.Gui2.DeleteWindow()
	}
}

DrawRoutine:
    _UpdateGraphics( Master )
    return

WatchListLeave:
	MouseGetPos,,,, ctrl, 2
    if( Master.DDL.HoverActive && Master.DDL.Handles[ctrl] != Master.DDL.HoverActive ){
		if( Master.DDL.Handles[ctrl] ){
			Master.DDL.HoverActive := Master.DDL.Handles[ctrl]
			Master.Gui2.ClearWindow()
			Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
			Master.Gui2.UpdateWindow()
			Master.Display.Hover := Master.DDL.HoverActive
			SetDisplayWindow()
		}else{
		
			Master.Gui2.ClearWindow()
			Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
			Master.Gui2.UpdateWindow()
			
			Master.Gui3.ClearWindow()
			Master.Gui3.UpdateWindow()
			Master.Display.Hover := 0
			SetTimer, WatchButtonLeave, Off
			sleep, 30
			Master.DDL.HoverActive := 0
		}
    }
	return

WatchButtonLeave:
    MouseGetPos,,,, ctrl, 2
    if( Master.Active && Master.Handles[ctrl] != Master.Active ){
        Master.Active := 0
        SetTimer, DrawRoutine, -0
        SetTimer, WatchButtonLeave, Off
    }else{
        SetTimer, WatchButtonLeave, -30
    }
    return

_MoveWindow(){
    Master.Moving := 1
    PostMessage, 0xA1, 2
    While(GetKeyState("LButton"))
        sleep, 30
    WinGetPos, x, y,,, % "ahk_id " Master.Gui1.Hwnd
    Master.Gui1.SetWindowProperties( { X: x , Y: y } )
	Master.Gui3.SetWindowProperties( { X: x + 120 , Y: y - 310 } )
    Master.Moving := 0
	
}

_ExpandDropDownList(){
   _CreateDDLWindow()
}

_SwitchFolders(){
    _LoadImageList( Master , 1 )
    SetTimer, DrawRoutine, -10
}

_UseImage(){
    SoundBeep, 700
}

_CloseImageViewer(){
    SoundBeep, 800
    ExitApp
}

_CycleImages(){
    local change
    MouseGetPos,,,, ctrl, 2
    if( Master.Handles[ ctrl ] = 6 )
        ( --Master.Index < 1 ) ? ( Master.Index := 1 ) : ( change := 1 )
    else if( Master.Handles[ ctrl ] = 7 )
        ( ( Master.Index -= 10 ) < 1 ) ? ( Master.Index := 1 , change := 1 ) : ( change := 1 )  
    else if( Master.Handles[ ctrl ] = 8 )
        ;~ ( ++Master.Index > ( Master.FullPath.Length() - 10 ) ) ? ( Master.Index := ( Master.FullPath.Length() - 10 ) ) : ( change := 1 )
        ( ++Master.Index > ( Master.FullPath.Length() - 9 ) ) ? ( Master.Index := ( Master.FullPath.Length() - 9 ) ) : ( change := 1 )
    else if( Master.Handles[ ctrl ] = 9 )
        ;~ ( ( Master.Index += 10 ) > ( Master.FullPath.Length() - 10 ) ) ? ( Master.Index := ( Master.FullPath.Length() - 10 ) , change := 1 ) : ( change := 1 )
        ( ( Master.Index += 10 ) > ( Master.FullPath.Length() - 9 ) ) ? ( Master.Index := ( Master.FullPath.Length() - 9 ) , change := 1 ) : ( change := 1 )
    if( change ){
        SetImageList( Master )
        ;~ Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 11 ) ) ) + 240
        Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
        SetTimer, DrawRoutine, -10
    }    
}

_SelectImage(){
	local index
	MouseGetPos,,,, ctrl, 2
	index := Master.Handles[ ctrl ] 
	
    
	;~ Master.SelectedImage := Master.Controls[ index ].Position + Master.Index - 1
	Master.SelectedImage := Master.Controls[ index ].Position + Master.Index - 1
	Master.SelectedPosition := Master.Controls[ index ].Position
	;~ tooltip, % "Here`n" Master.Controls[ index ].Position "`n" Master.SelectedImage
	SetTimer, DrawRoutine, -10
}

_UpdateGraphics( obj ){
    obj.Gui1.ClearWindow()
    obj.Gui1.DrawBitmap( ImageViewerMain( obj ) , { X: 0 , Y: 0 , W: 900 , H: 100 } , dispose := 1 )
    ; Loop, % obj.BitMaps.Length()
    Loop, % 10
        obj.Gui1.DrawBitmap( obj.BitMaps[ A_Index ].Bitmap , { X: obj.BitMaps[ A_Index ].X , Y: obj.BitMaps[ A_Index ].Y  , W: obj.BitMaps[ A_Index ].Width , H: obj.BitMaps[ A_Index ].Height } , dispose := 0 )
    obj.Gui1.UpdateWindow()

}

_AddControls( obj := "" ){
    local hwnd, bd, Method
    Loop, % obj.Controls.Length()   {
        Gui, % obj.WindowName ":Add", Text, % "x" obj.Controls[ A_Index ].X " y" obj.Controls[ A_Index ].Y " w" obj.Controls[ A_Index ].W " h" obj.Controls[ A_Index ].H " hwndhwnd"
        obj.Handles[ hwnd ] := A_Index
        obj.Controls[ A_Index ].Hwnd := hwnd
        Method := obj.Controls[ A_Index ].Method
        bd := Func( obj.Controls[ A_Index ].Method ).Bind( obj )
        GuiControl, % obj.WindowName ":+G", % hwnd, % bd
    }
}

_CreateControlObjects(){
    local Master := {} , Index := 0
    Master.Controls := [] , Master.Handles := [] , Master.WindowName := 1 , Master.Index := 1 

    Master.Active := ""
    Master.LastActive := Master.Active
    Master.DropDownActive := 0

    Master.SliderButtonMinX := 240
    Master.SliderButtonMaxX := 240 + 584
    Master.SliderButtonX := 240
    Master.SliderValue := 1
    Master.SliderInterval := 0
	Master.SliderMoving := 0
    Master.SelectedImage := 5
	
	Master.DotX := 200
	
	
	Master.DDL := {}
	Master.DDL.ListStartPosition := 1
	
	Master.Display := {}
	Master.Display.Hover := 0
	Master.Display.Bitmaps := {}

    ;1: Move Window ; 5 , 33 , 22 , 58
    Master.Controls[++Index] := {   X:              5
                                ,   Y:              33
                                ,   W:              22
                                ,   H:              58
                                ,   Hwnd:           ""
                                ,   Name:           Index
                                ,   Method:         "_MoveWindow"   }

    ;2: Drop Down List ; 21 , 10 , 150 , 20
    Master.Controls[++Index] := {   X:              21
                                ,   Y:              10
                                ,   W:              150
                                ,   H:              20
                                ,   Hwnd:           ""
                                ,   Method:         "_ExpandDropDownList"   }
    ;3: Change Folder ; 31 , 33 , 130 , 19
    Master.Controls[++Index] := {   X:              31
                                ,   Y:              33
                                ,   W:              130
                                ,   H:              19
                                ,   Hwnd:           ""
                                ,   Name:           Index
                                ,   Method:         "_SwitchFolders"   }
    ;4: Use Selected Image ; 31 , 56 , 130 , 19
    Master.Controls[++Index] := {   X:              31
                                ,   Y:              56
                                ,   W:              130
                                ,   H:              19
                                ,   Hwnd:           ""
                                ,   Name:           Index
                                ,   Method:         "_UseImage"   }
    ;5: Close ; 885 , 11 , 10 , 57
    Master.Controls[++Index] := {   X:              885
                                ,   Y:              11
                                ,   W:              10
                                ,   H:              57
                                ,   Hwnd:           ""
                                ,   Name:           Index
                                ,   Method:         "_CloseImageViewer"   } 
    ;6: Left Single ; 175 , 78 , 20 , 20
    Master.Controls[++Index] := {   X:              175
                                ,   Y:              78
                                ,   W:              20
                                ,   H:              20
                                ,   Hwnd:           ""
                                ,   Name:           Index
                                ,   Method:         "_CycleImages"   
                                ,   Value:          -1   }
    ;7: Left 10 ; 198 , 78 , 30 , 20
    Master.Controls[++Index] := {   X:              198
                                ,   Y:              78
                                ,   W:              30
                                ,   H:              20
                                ,   Hwnd:           ""
                                ,   Name:           Index
                                ,   Method:         "_CycleImages"
                                ,   Value:          -10   } 
    ;8: Right Single ; 869 , 78 , 20 , 20
    Master.Controls[++Index] := {   X:              869
                                ,   Y:              78
                                ,   W:              20
                                ,   H:              20
                                ,   Hwnd:           ""
                                ,   Name:           Index
                                ,   Method:         "_CycleImages"
                                ,   Value:          +1   } 
    ;9: Right 10 ; 836 , 78 , 30 , 20
    Master.Controls[++Index] := {   X:              836
                                ,   Y:              78
                                ,   W:              30
                                ,   H:              20
                                ,   Hwnd:           ""
                                ,   Name:           Index
                                ,   Method:         "_CycleImages"
                                ,   Value:          +10   } 
    ;10: Adjust Slider ; 230 , 76 , 600 , 20
    Master.Controls[++Index] := {   X:              230
                                ,   Y:              76
                                ,   W:              600
                                ,   H:              20
                                ,   Hwnd:           ""
                                ,   Method:         "_AdjustSlider"   } 

    ;********************************************************************

    ;Image Panel Triggers ; 180 , 250 , 320 , 390 ...
    x := 110
    Loop, % 10  {
        Master.Controls[++Index] := {   X:              x += 70
                                    ,   Y:              2
                                    ,   W:              70
                                    ,   H:              70
                                    ,   Hwnd:           ""
									,	Position:		A_Index
                                    ,   Method:         "_SelectImage"   }

    }

    return Master

}

SetImageList( obj ){
    static ft := 1
    x := 180
    if( ft && !ft := !ft ){
        obj.Bitmaps := [] , obj.MaxSize := 66 , obj.ImageBoxSize := 70
        obj.Index := 1
		
    }
    
    Loop, % obj.FullPath.Length()  {
		if( obj.BitMaps[ A_Index ].Bitmap )
			Gdip_DisposeImage(  obj.BitMaps[ A_Index ].Bitmap )
		else
			obj.BitMaps[ A_Index ] := {}
        
        obj.BitMaps[ A_Index ].Bitmap := Gdip_CreateBitmapFromFile( obj.FullPath[ A_Index + obj.Index - 1 ] )
        ResizeIt( obj.BitMaps[ A_Index ].Bitmap , Width , Height , obj.MaxSize )
        obj.BitMaps[ A_Index ].X := x + ( obj.ImageBoxSize - Width ) / 2
        obj.BitMaps[ A_Index ].Y := 4 + ( obj.ImageBoxSize - Height ) / 2
        obj.BitMaps[ A_Index ].Width := Width
        obj.BitMaps[ A_index ].Height := Height
        obj.BitMaps[ A_index ].ActualFilePosition := A_Index + obj.Index - 1
        if( A_Index = 10 )
            break
        x += obj.ImageBoxSize    
    }

}

_LoadImageList( obj , loadit := 0 ){
    local index := 0 , Fileinput := ""
    
    IniRead Fileinput , % A_ScriptFullPath , MyPath , Path , ""
    if( !Fileinput || loadit ){
        Gui, 1:+OwnDialogs
        FileSelectFolder, Fileinput 
		if( !Fileinput )
			return
        IniWrite, % Fileinput , % A_ScriptFullPath , MyPath, path
    }
	obj.FullPath := []
    obj.Index := 1
    Loop, % Fileinput "\*.png"
        obj.FullPath[ ++Index ] := A_LoopFileFullPath
    SetImageList( obj )
}

ImageViewerMain( obj ){
	;Bitmap Created Using: HB Bitmap Maker
    ; tooltip, % "Here`n" obj.FullPath[1]
	pBitmap := Gdip_CreateBitmap( 900 , 100 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	; Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_FillRectangle( G , Brush , -2 , -2 , 940 , 210 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 3 , 2 , 898 , 151 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 1 , 1 , 898 , 98 , 15 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF22262A" ) , Gdip_FillRectangle( G , Brush , 180 , 2 , 700 , 70 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 1 , 2 , 903 , 158 , "0xaaF0F0F0" , "0xaa000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 1 , 1 , 898 , 98 , 15 ) , Gdip_DeletePen( Pen )
	
    ;Image Display Areas
	
	( Master.SelectedImage >= Master.Index && Master.SelectedImage <= Master.Index + 10 ) ? ( selpos := ( Master.SelectedImage - Master.Index + 1 ) , x := 110  ) : ( selpos := "" , x := 110 )
    Brush1 := Gdip_CreateLineBrushFromRect( 0 , 2 , 70 , 70 , "0xFF336699" , "0xff3399ff" , 1 , 1 ) , Brush2 := Gdip_BrushCreateSolid( "0xFF333333" )
   

    Loop, % 10  
		Gdip_FillRectangle( G , ( selpos = A_Index ) ? ( Brush1 ) : ( Brush2 ) , x += 70 , 2 , 70 , 70 ) 
	
    Gdip_DeleteBrush( Brush1 ) , Gdip_DeleteBrush( Brush1 )
    
	;Selected item
	;~ if( Master.SelectedImage >= Master.Index && Master.SelectedImage <= Master.Index + 9 ){
	if( Master.SelectedImage >= Master.Index && Master.SelectedImage <= Master.Index + 10 ){
		posx := ( Master.SelectedImage - Master.Index ) * 70 + 180 
		;~ Pen := Gdip_CreatePen( "0xFF3399FF" , 1 ) , Gdip_DrawRectangle( G , Pen , posx , 2 , 70 , 70 ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( "0xFF000000" , 1 ) , Gdip_DrawRectangle( G , Pen , posx , 2 , 70 , 70 ) , Gdip_DeletePen( Pen )
	}

    ;Slider Background
    Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRoundedRectangle( G , Brush , 230 , 76 , 600 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 232 , 76 , 596 , 18 , "0x66F0F0F0" , "0x66000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 231 , 77 , 598 , 18 , 5 ) , Gdip_DeleteBrush( Brush )
	
    
     ;Slider Image Position ( DOT )
	;~ Master.DotX := floor( ( x - 240 ) / ( ( 806 - 240 ) / ( Master.FullPath.Length() - 11 ) ) ) + 1
	Master.DotX := ( ( 806 - 240 ) / ( Master.FullPath.Length() ) ) * Master.SelectedImage + 240
	;~ ToolTip, % "here`n" Master.DotX 
    ;~ Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_FillEllipse( G , Brush , 320 , 78 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
    ;~ Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_FillEllipse( G , Brush , Master.DotX , 78 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
    Brush := Gdip_CreateLineBrushFromRect( Master.DotX , 80 , 4 , 12 , "0xFF336699" , "0xFF3399ff" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , Master.DotX , 80 , 4 , 12 ) , Gdip_DeleteBrush( Brush )

    
    ;Slider Track
    Brush := Gdip_BrushCreateSolid( "0xFF22262A" ) , Gdip_FillRectangle( G , Brush , 238 , 84 , 584 , 4 ) , Gdip_DeleteBrush( Brush )
	
    
    
    ;Slider Button
    ;****************************************************
    ; Brush := Gdip_CreateLineBrushFromRect( 239 , 78 , 16 , 15 , "0xFF000000" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 240 , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
	; Brush := Gdip_CreateLineBrushFromRect( 239 , 78 , 16 , 15 , "0x33000000" , "0x33000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 241 , 80 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
	; Brush := Gdip_CreateLineBrushFromRect( 239 , 78 , 16 , 15 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 240 , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
	; Brush := Gdip_CreateLineBrushFromRect( 244 , 81 , 10 , 10 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 241 , 80 , 12 , 12 ) , Gdip_DeleteBrush( Brush )
	;****************************************************
    Brush := Gdip_CreateLineBrushFromRect( obj.SliderButtonX , 78 , 16 , 15 , "0xFF000000" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , obj.SliderButtonX , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( obj.SliderButtonX , 78 , 16 , 15 , "0x33000000" , "0x33000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , obj.SliderButtonX + 1 , 80 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( obj.SliderButtonX , 78 , 16 , 15 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , obj.SliderButtonX , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( obj.SliderButtonX + 5 , 81 , 10 , 10 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , obj.SliderButtonX + 1 , 80 , 12 , 12 ) , Gdip_DeleteBrush( Brush )
	


    
    ;Left side slider Button 1
	Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillEllipse( G , Brush , 175 , 78 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
	
    Brush := Gdip_CreateLineBrushFromRect( 169 , 75 , 22 , 20 , "0xffF0F0F0"   , "0xff000000"  , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 173 , 76 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
    ; Brush := Gdip_CreateLineBrushFromRect( 169 , 75 , 22 , 20 , "0xffF0F0F0"   , ( Master.Active = 6 ) ? ( "0xFF3399FF" ) : ( "0xff000000" ) , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 173 , 76 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
	
    Brush := Gdip_BrushCreateSolid( ( Master.Active = 6 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) ) , Gdip_FillEllipse( G , Brush , 175 , 78 , 16 , 16 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 178 , 81 , 12 , 12 , "0xff777777" , "0xff222222" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 176 , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 6 ) ? ( "0xFF3399FF" ) : ( "0xFF000000" ) ) , Gdip_TextToGraphics( G , "3" , "s12 Center vCenter Bold c" Brush " x174 y78" , "webdings" , 20 , 20 ) , Gdip_DeleteBrush( Brush )
	
    ;left side slider button 2
	Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillRoundedRectangle( G , Brush , 198 , 78 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 200 , 77 , 26 , 19 , "0xffF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 196 , 76 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	; Brush := Gdip_CreateLineBrushFromRect( 200 , 77 , 26 , 19 , "0xffF0F0F0" , ( Master.Active = 7 ) ? ( "0xFF3399FF" ) : ( "0xff000000" ) , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 196 , 76 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 7 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) ) , Gdip_FillRoundedRectangle( G , Brush , 198 , 78 , 26 , 16 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 198 , 80 , 25 , 15 , "0xff777777" , "0xFF222222" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 199 , 79 , 24 , 14 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 7 ) ? ( "0xFF3399FF" ) : ( "0xFF000000" ) ) , Gdip_TextToGraphics( G , "7" , "s12 Center vCenter Bold c" Brush " x201 y78" , "webdings" , 20 , 20 ) , Gdip_DeleteBrush( Brush )
	
    ;Right Side Slider button 1
	Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillEllipse( G , Brush , 869 , 78 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 868 , 76 , 17 , 18 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 867 , 76 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 8 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) ) , Gdip_FillEllipse( G , Brush , 869 , 78 , 16 , 16 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 870 , 81 , 13 , 11 , "0xFF777777" , "0xFF222222" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 870 , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 8 ) ? ( "0xFF3399FF" ) : ( "0xFF000000" ) ) , Gdip_TextToGraphics( G , "4" , "s12 Center vCenter Bold c" Brush " x868 y78" , "webdings" , 20 , 20 ) , Gdip_DeleteBrush( Brush )
	
    ;Right side slider button 2
	Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillRoundedRectangle( G , Brush , 836 , 78 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 835 , 78 , 29 , 20 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 834 , 76 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 9 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) ) , Gdip_FillRoundedRectangle( G , Brush , 836 , 78 , 26 , 16 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 838 , 81 , 23 , 13 , "0xFF777777" , "0xFF222222" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 837 , 79 , 24 , 14 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 9 ) ? ( "0xFF3399FF" ) : ( "0xFF000000" ) ) , Gdip_TextToGraphics( G , "8" , "s12 Center vCenter Bold c" Brush " x840 y78" , "webdings" , 20 , 20 ) , Gdip_DeleteBrush( Brush )
	

    ;DDL
	Brush := Gdip_BrushCreateSolid( "0xFF999999" ) , Gdip_FillRoundedRectangle( G , Brush , 21 , 10 , 150 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( "0x66222222" , 1 ) , Gdip_DrawRoundedRectangle( G , Pen , 21 , 10 , 150 , 20 , 5 ) , Gdip_DeletePen( Pen )
	
	SplitPath, % Master.FullPath[ Master.SelectedImage ] ,,,, name
	;~ path := Master.FullPath[ Master.SelectedImage ]
	;~ Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Picture 123456" , "s12 Center vCenter Bold c" Brush " x11 y11" , "Segoe ui" , 130 , 20 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , name , "s12  nowrap vCenter Bold c" Brush " x25 y11" , "Segoe ui" , 110 , 20 ) , Gdip_DeleteBrush( Brush )
	
	
	Brush := Gdip_CreateLineBrushFromRect( 146 , 16 , 20 , 12 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 145 , 13 , 22 , 14 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF222222" ) , Gdip_TextToGraphics( G , "6" , "s12 Center vCenter Bold c" Brush " x146 y14" , "Webdings" , 22 , 14 ) , Gdip_DeleteBrush( Brush )
	
    ;Button 1
	Brush := Gdip_CreateLineBrushFromRect( 21 , 33 , 153 , 12 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 31 , 33 , 130 , 19 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 22 , 32 , 149 , 20 , "0xFF777777" , ( Master.Active = 3 ) ? ("0xFF3399FF"):( "0xFF000000") , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 31 , 33 , 130 , 19 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 3 ) ? ("0x663399FF" ) : ( "0x66F0F0F0" ) ) , Gdip_FillEllipse( G , Brush , 50 , 35 , 90 , 7 ) , Gdip_DeleteBrush( Brush )
	
    if( Master.Active = 3 )
        Brush := Gdip_BrushCreateSolid( "0xFF3399FF" )
    Else
        Brush := Gdip_BrushCreateSolid( "0xFFDDDDDD" ) 

        Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x20 y33" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x21 y33" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x22 y34" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x22 y35" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x21 y35" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x20 y35" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x20 y34" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x22 y33" , "Segoe ui" , 150 , 19 )
    
    Gdip_DeleteBrush( Brush )
    Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x21 y34" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( ( Master.Active = 3 ) ? ("0xFF3399FF" ) : ( "0xFFF0F0F0" ) , 1 ) , Gdip_DrawLine( G , Pen , 33 , 35 , 158 , 35 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( ( Master.Active = 3 ) ? ("0xFF3399FF" ) : ( "0xFF222222" ) , 1 ) , Gdip_DrawLine( G , Pen , 43 , 50 , 148 , 50 ) , Gdip_DeletePen( Pen )
	
    ;Button 2
	Brush := Gdip_CreateLineBrushFromRect( 30 , 56 , 131 , 12 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 31 , 56 , 130 , 19 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 21 , 50 , 150 , 18 , "0xFF777777" , ( Master.Active = 4 ) ? ("0xFF3399FF"):( "0xFF000000") , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 31 , 56 , 130 , 19 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 4 ) ? ("0x663399FF" ) : ( "0x66F0F0F0" ) ) , Gdip_FillEllipse( G , Brush , 50 , 58 , 90 , 7 ) , Gdip_DeleteBrush( Brush )
	
    if( Master.Active = 4 )
        Brush := Gdip_BrushCreateSolid( "0xFF3399FF" )
    Else
        Brush := Gdip_BrushCreateSolid( "0xFFDDDDDD" )

        Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x20 y56" , "Segoe ui" , 150 , 19 ) 
        Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x22 y57" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x22 y58" , "Segoe ui" , 150 , 19 ) 
        Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x21 y58" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x20 y58" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x20 y57" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x22 y56" , "Segoe ui" , 150 , 19 )
        Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x21 y56" , "Segoe ui" , 150 , 19 )
    Gdip_DeleteBrush( Brush )
    Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x21 y57" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( ( Master.Active = 4 ) ? ( "0xFF3399FF" ) : ( "0xFFF0F0F0" ) , 1 ) , Gdip_DrawLine( G , Pen , 33 , 58 , 158 , 58 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( ( Master.Active = 4 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) , 1 ) , Gdip_DrawLine( G , Pen , 43 , 73 , 148 , 73 ) , Gdip_DeletePen( Pen )
	
    
    ;files
	Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" )
	;files , Gdip_TextToGraphics( G , "104 / 165" , "s16 Center vCenter Bold c" Brush " x20 y80" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
    ; Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "104 / 165" , "s16 Center vCenter Bold c" Brush " x21 y81" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
    Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , obj.Index " / " obj.FullPath.Length() , "s16 Center vCenter Bold c" Brush " x22 y82" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
    Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_TextToGraphics( G , obj.Index " / " obj.FullPath.Length() , "s16 Center vCenter Bold c" Brush " x21 y81" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
	
    ;Move Window
    Brush := Gdip_BrushCreateSolid( ( Master.Active = 1 ) ? ( "0x663399FF" ):( "0x66000000" ) ) , Gdip_FillEllipse( G , Brush , 5 , 33 , 22 , 58 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 1 ) ? ( "0xFF000000" ) : ( "0xFFF0F0F0" ) ) , Gdip_TextToGraphics( G , "8" , "s18 Center vCenter c" Brush " x6 y37" , "Wingdings" , 20 , 58 ) , Gdip_DeleteBrush( Brush )
	
    ;close button
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 5 ) ? ( "0x663399FF" ) : ( "0x66000000" ) ) , Gdip_FillRoundedRectangle( G , Brush , 885 , 11 , 10 , 57 , 3 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( ( Master.Active = 5 ) ? ( "0xFF000000" ) : ( "0xFFF0F0F0" )  ) , Gdip_TextToGraphics( G , "CLOSE" , "s8 Center vCenter Bold c" Brush " x885 y11" , "Segoe ui" , 10 , 57 ) , Gdip_DeleteBrush( Brush )
	

	Gdip_DeleteGraphics( G )
	return pBitmap
}

ImageViewerDisplayPanel(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 900 , 310 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	;left panel
	Brush := Gdip_CreateLineBrushFromRect( 1 , 88 , 220 , 220 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 1 , 88 , 220 , 220 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 1 , 88 , 220 , 220 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 1 , 88 , 220 , 220 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( 2 , -1 , 897 , 310 , "0x993399FF" , "0x33000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 , 95 , 210 , 210 , 5 ) , Gdip_DeleteBrush( Brush )
	;Active Panel
	Brush := Gdip_CreateLineBrushFromRect( 222 , 1 , 307 , 307 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 222 , 1 , 307 , 307 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 222 , 1 , 307 , 307 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 222 , 1 , 307 , 307 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( -1 , 0 , 899 , 308 , "0x993399FF" , "0x33000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 223 , 3 , 304 , 304 , 5 ) , Gdip_DeleteBrush( Brush )
	;right panel
	Brush := Gdip_CreateLineBrushFromRect( 530 , 88 , 220 , 220 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 530 , 88 , 220 , 220 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 530 , 88 , 220 , 220 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 530 , 88 , 220 , 220 , 5 ) , Gdip_DeletePen( Pen )
	Brush := Gdip_CreateLineBrushFromRect( -1 , 0 , 900 , 310 , "0x993399FF" , "0x33000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 535 , 95 , 210 , 210 , 5 ) , Gdip_DeleteBrush( Brush )
	Gdip_DeleteGraphics( G )
	return pBitmap
}

DDLGraphics(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 330 , 280 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Brush := Gdip_BrushCreateSolid( "0xFF999999" ) , Gdip_FillRoundedRectangle( G , Brush , 0 , 0 , 330 , 280 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 302 , 7 , 23 , 229 , "0xFFC5C5C5" , "0xFF444444" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 300 , 5 , 25 , 230 , 5 ) , Gdip_DeleteBrush( Brush )
	;ok button
	Brush := Gdip_CreateLineBrushFromRect( 302 , 241 , 23 , 36 , "0xFFC5C5C5" , "0xFF444444" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 300 , 239 , 25 , 36 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , "OK" , "s12 Center vCenter Bold c" Brush " x300 y239" , "Segoe ui" , 25 , 36 ) , Gdip_DeleteBrush( Brush )
	
	
	;List cells
	;***********************************************************
	Brushes := {} 
	Brushes.BG1 := Gdip_BrushCreateSolid( "0xFF333333" )
	Brushes.BG2 := Gdip_BrushCreateSolid( "0xFF444444" )
	Brushes.Selected := Gdip_BrushCreateSolid( "0xff3399ff" )
	Brushes.Hover := Gdip_BrushCreateSolid( "0x66336699" )
	Brushes.MainTextB := Gdip_BrushCreateSolid( "0xFFF0F0F0" )
	Brushes.SelTextB := Gdip_BrushCreateSolid( "0xFF000000" )
	
	;~ Master.DDL.Value := Master.SelectedImage
	y := 5
	Loop, % 13	{
		
		SplitPath, % Master.FullPath[ A_Index + Master.Index - 1 ] ,,,, name
		if( ( A_Index + Master.Index - 1 ) != Master.SelectedImage ){
			Gdip_FillRoundedRectangle( G , ( tog := !tog ) ? ( Brushes.BG1 ) : ( Brushes.BG2 ) , 5 , y , 290 , 20 , 5 ) 
		}else{
			Gdip_FillRoundedRectangle( G , Brushes.Selected , 5 , y , 290 , 20 , 5 )
			;Highlighted Cell
			Brush := Gdip_CreateLineBrushFromRect( 5 , y , 290 , 20 , "0xFF336699" , "0xFF222222" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 2 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 5 , y , 290 , 20 , 5 ) , Gdip_DeletePen( Pen )
	
		}
		
		if( Master.DDL.HoverActive = A_Index && ( A_Index + Master.Index - 1 ) != Master.SelectedImage ){
			Gdip_FillRoundedRectangle( G , Brushes.Hover , 5 , y , 290 , 20 , 5 )
		}
		
		Brush := Gdip_BrushCreateSolid( ( ( A_Index + Master.Index - 1 ) = Master.SelectedImage ) ? ( "0xFF000000" ) : ( "0xFFF0F0F0" ) ) , Gdip_TextToGraphics( G , Name , "s12 left nowrap vCenter Bold c" Brush " x14 y" y + 1 , "Segoe ui" , 270 , 20 ) , Gdip_DeleteBrush( Brush )
		
		;~ if( ( A_Index + Master.Index - 1 ) = Master.SelectedImage ){
			;~ Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , name , "s12 left  vCenter Bold nowrap c" Brush " x15 y" y + 1 , "Segoe ui" , 270 , 20 ) , Gdip_DeleteBrush( Brush )
	
		;~ }
		
		y += 21
	}
	
	for k, v in Brushes
		Gdip_DeleteBrush( Brushes[ k ] )
	
	
	;slider button
	Brush := Gdip_CreateLineBrushFromRect( 301 , Master.DDL.SliderButtonY , 22 , 86 , "0xFF777777" , "0xFF333333" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 302 , Master.DDL.SliderButtonY , 21 , 90 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , 305 , Master.DDL.SliderButtonY + 44 , 15 , 3 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , 305 , Master.DDL.SliderButtonY + 55 - 7 , 15 , 3 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , 305 , Master.DDL.SliderButtonY + 59 - 7 , 15 , 3 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , 305 , Master.DDL.SliderButtonY + 47 - 7 , 15 , 3 ) , Gdip_DeleteBrush( Brush )
	
	
	
	
	Gdip_DeleteGraphics( G )
	return pBitmap
}

_CreateWindows( obj ){
    obj.Gui1 := New PopUpWindow( { WindowName: "1" , WindowOptions: " -DPIScale +AlwaysOnTop " , WindowSmoothing: 2 , X: 300 , Y: 410 , W: 900 , H: 100 } )
    obj.Gui1.ShowWindow()
    obj.Gui1.DrawBitmap( ImageViewerMain( obj ) , { X: 0 , Y: 0 , W: 900 , H: 100 } , dispose := 1 )
    Loop, % obj.BitMaps.Length()
        obj.Gui1.DrawBitmap( obj.BitMaps[ A_Index ].Bitmap , { X: obj.BitMaps[ A_Index ].X , Y: obj.BitMaps[ A_Index ].Y  , W: obj.BitMaps[ A_Index ].Width , H: obj.BitMaps[ A_Index ].Height } , dispose := 0 )
    obj.Gui1.UpdateWindow()

}

ResizeIt( PB , ByRef tWidth , ByRef tHeight , InputValue ){
	Gdip_GetDimensions( PB , tWidth , tHeight )
	if( tWidth > InputValue && tWidth >= tHeight )
		Ratio := tHeight / tWidth , tWidth := InputValue , tHeight := InputValue * Ratio 
	else if( tHeight > InputValue && tHeight >= tWidth )
		Ratio := tWidth / tHeight , tHeight := InputValue , tWidth := InputValue * Ratio 
	else if( tWidth > InputValue && tWidth <= tHeight )
		Ratio := tWidth / tHeight , tHeight := InputValue , tWidth := InputValue * Ratio 
}


;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
class PopUpWindow	{
	;Class By: Hellbent
	;Apr 2021
	static Index := 0 , Windows := [] , Handles := [] , HelpHandles := [] , HelperEditHwnd
	__New( obj := "" ){
		This._SetDefaults()
		if( isObject( obj ) )
			This.SetWindowProperties( obj )
		This._SetupWindowGraphics()
	}
	_SetDefaults(){
		PopUpWindow.Index++
		This.WindowName := "HBLayeredWindow" PopUpWindow.Index
		This.WindowSmoothing := 2
		This.WindowOptions := " -DPIScale +AlwaysOnTop "
		This.X := 10
		This.Y := 10
		This.W := 10
		This.H := 10
	}
	PaintBackground( color := "0xFF000000" ){
		Brush := Gdip_BrushCreateSolid( color ) 
		Gdip_FillRectangle( This.G , Brush , -1 , -1 , This.W + 2 , This.H + 2 ) 
		Gdip_DeleteBrush( Brush )
	}
	_SetupWindowGraphics(){
		This.Hwnd := This._CreateGUI()
		This.hbm := CreateDIBSection( This.W , This.H )
		This.hdc := CreateCompatibleDC()
		This.obm := SelectObject( This.hdc , This.hbm )
		This.G := Gdip_GraphicsFromHDC( This.hdc )
		Gdip_SetSmoothingMode( This.G , This.WindowSmoothing )
		PopUpWindow.Handles[ This.Hwnd ] := PopUpWindow.Index
		PopUpWindow.Windows[ PopUpWindow.Index ] := This
	}
	SetWindowProperties( obj ){
		local k , v 
		for k , v in obj
			if( k != "hwnd" )
				This[k] := v
	}
	ShowWindow( Title := "" ){
		Gui , % This.WindowName ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H " NA", % Title
	}
	HideWindow(){
		Gui , % This.WindowName ":Hide",
	}
	UpdateWindow(){
		UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
	}
	ClearWindow(){
		Gdip_GraphicsClear( This.G )
	}
	DrawBitmap( pBitmap , obj , dispose := 1 ){
		Gdip_DrawImage( This.G , pBitmap , obj.X , obj.Y , obj.W , obj.H )
		if( dispose )
			Gdip_DisposeImage( pBitmap )
	}
	DeleteWindow(){
		Gui, % This.WindowName ":Destroy"
		SelectObject( This.hdc , This.obm )
		DeleteObject( This.hbm )
		DeleteDC( This.hdc )
		Gdip_DeleteGraphics( This.G )
		hwnd := This.Hwnd
		for k, v in PopUpWindow.Windows[ Hwnd ]
			This[k] := ""
		PopUpWindow.Windows[ Hwnd ] := ""
	}
	_CreateGUI(){
		local hwnd
		Gui , % This.WindowName ":New" , % " +E0x80000 hwndhwnd -Caption  " This.WindowOptions
		return hwnd
	}
	Helper(){
		local List := ["New Window","SetWindowProperties","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow"]
		local hwnd, bd
		
		
		Gui, HBLWHelperGui:New, +AlwaysOnTop 
		Gui, HBLWHelperGui:Color, 62666a, 24282c
		Gui, HBLWHelperGui:Font, cWhite s10 , Segoe UI
		Gui, HBLWHelperGui:Margin, 5 , 5
		
		Gui, HBLWHelperGui:Add, Edit, xm ym w200 r1 Center hwndHwnd, Gui1
		PopUpWindow.HelperEditHwnd := Hwnd
		Gui, HBLWHelperGui:Margin, 5 , 1
		Loop, % List.Length()	{
		
			Gui, HBLWHelperGui:Add, Button, xm wp h23 -Theme hwndhwnd, % List[ A_Index ]
			PopUpWindow.HelpHandles[hwnd] := List[ A_Index ]
			bd := PopUpWindow._ClipIt.Bind( PopUpWindow )
			GuiControl , HBLWHelperGui: +G , % Hwnd , % bd
		}
		
		Gui, HBLWHelperGui:Show, 
		
	}
	_ClipIt(){
		local List := ["New Window","SetWindowProperties","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow"]
		local Output , FQ := 400
		GuiControlGet, Output , HBLWHelperGui: , % PopUpWindow.HelperEditHwnd
		Switch A_GuiControl
		{
			case List[1]:
				Clipboard := Output " := New PopUpWindow( { WindowName: ""1"" , WindowOptions: "" -DPIScale +AlwaysOnTop "" , WindowSmoothing: 2 , X: ""Center"" , Y: ""Center"" , W: 100 , H: 100 } )"
				loop 2
					SoundBeep, FQ
				return
			case List[2]:
				Clipboard := Output ".SetWindowProperties( { X: """" , Y: """" , W: """" , H: """" } )"
				loop 2
					SoundBeep, FQ
				return
			case List[3]:
				Clipboard := Output ".ShowWindow( MyWindowTitle := """" )"
				loop 2
					SoundBeep, FQ
				return
			case List[4]:
				Clipboard := Output ".HideWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[5]:
				Clipboard := Output ".UpdateWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[6]:
				Clipboard := Output ".ClearWindow()"
				loop 2
					SoundBeep, FQ
				return
			case List[7]:
				Clipboard := Output ".DrawBitmap( pBitmap := """" , { X: """" , Y: """" , W: """" , H: """" } , dispose := 1 )"
				loop 2
					SoundBeep, FQ
				return
			case List[8]:
				Clipboard := Output ".PaintBackground( color := ""0xFF000000"" )"
				loop 2
					SoundBeep, FQ
				return
			case List[9]:
				Clipboard := Output ".DeleteWindow()"
				loop 2
					SoundBeep, FQ
				return
			Default:
				ToolTip, Looks like a new case needs to be added
				return
			
		}
	}
}

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: A few questions...

Post by mikeyww » 11 Aug 2021, 05:49

1. Accelerator: yes, other posts have examples of key accelerators. The basic concept is that, while the hotkey continues to be held, increase the number of presses (Send) as the time since the hotkey trigger increases. You define whatever formula you need, for the relationship between elapsed time and number of Sends. A_TickCount can mark the time for you. This is generally a two- or three-liner.

2. Thumbnails: yes, you can store a thumbnail and then use that instead. You can then swap in the original wherever it is needed.

3. File selector: to enable multiple file types, you can separate them with a semicolon (Example). In a loop, you could include all files and then use A_LoopFileExt to act accordingly.
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: A few questions...

Post by Hellbent » 15 Aug 2021, 11:52

mikeyww wrote:
11 Aug 2021, 05:49
1. Accelerator: yes, other posts have examples of key accelerators. The basic concept is that, while the hotkey continues to be held, increase the number of presses (Send) as the time since the hotkey trigger increases. You define whatever formula you need, for the relationship between elapsed time and number of Sends. A_TickCount can mark the time for you. This is generally a two- or three-liner.
I have recently noticed a few variations in the way ui's handle wheel up and down actions. Some accelerate , some move the page a percentage / fraction , and others move at a fixed distance. I think may will go with percentage, perhaps 10% ( 10 wheel turns to travel the whole page ).
So the first wheel action would move one, the second would move one but if the time between the 2nd and 3rd (and any after) is short enough it will start jumping to 10% marks.

The issue with it is with short lists. Not sure if it would cause too much of a issue. ( 10 wheel strokes to move a word or two )
2. Thumbnails: yes, you can store a thumbnail and then use that instead. You can then swap in the original wherever it is needed.
Is there an actual "ThumbNail" that can be used or is it just me resizing a image?
Resizing the images before I show them could help performance, but it still has to process the image in it's large form.
3. File selector: to enable multiple file types, you can separate them with a semicolon (Example). In a loop, you could include all files and then use A_LoopFileExt to act accordingly.

Code: Select all

(*.png; *.bmp; *.jpg; *.jpeg)
I have tried multiple variations of the above code but none work.

Code: Select all

_LoadImageList( obj , loadit := 0 ){
    local index := 0 , Fileinput := ""
    IniRead Fileinput , % A_ScriptFullPath , MyPath , Path , ""
    if( !Fileinput || loadit ){
        Gui, 1:+OwnDialogs
        FileSelectFolder, Fileinput 
		if( !Fileinput )
			return
        IniWrite, % Fileinput , % A_ScriptFullPath , MyPath, path
    }
	obj.FullPath := []
    obj.Index := 1
    Loop, % Fileinput "\*.png; *.bmp"     ;   % Fileinput "\ (*.png; *.bmp)"          <-----------------------------------
        obj.FullPath[ ++Index ] := A_LoopFileFullPath
    SetImageList( obj )
}
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: A few questions...

Post by mikeyww » 15 Aug 2021, 12:00

If you don't already have thumbnails, you can use Gdip to resize your images-- search forum for examples-- or just let AHK scale the pictures for you in the GUI. The latter seems likely to be faster, but you can compare. There might be a way to access an existing thumbnail cache, but I don't know what that method is.

As I already noted, when using a loop, get all files in your loop command, and then use A_LoopFileExt to filter according to what you want.
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: A few questions...

Post by Hellbent » 15 Aug 2021, 12:33

mikeyww wrote:
15 Aug 2021, 12:00
If you don't already have thumbnails, you can use Gdip to resize your images-- search forum for examples-- or just let AHK scale the pictures for you in the GUI. The latter seems likely to be faster, but you can compare. There might be a way to access an existing thumbnail cache, but I don't know what that method is.
Thank you. I currently have it using GDIP to resize when it shows the image, but I'll try adapting it to resize the bitmap before drawing it and see if there is a difference with large image files.
As I already noted, when using a loop, get all files in your loop command, and then use A_LoopFileExt to filter according to what you want.
I think that we may have our wires crossed a bit here.

This is how the current system works.

1. The script checks to see if the path to a folder was already saved ( as a .ini section at the very top of the script)

Code: Select all

/*
    [MyPath]
    path=
*/
IniRead Fileinput , % A_ScriptFullPath , MyPath , Path , ""
If the path exits it jumps to step two, else it gets the user to select a folder.

Code: Select all

 if( !Fileinput || loadit ){
        Gui, 1:+OwnDialogs
        FileSelectFolder, Fileinput 
2. The selected folder is looped and every instance of a ".png" gets its path loaded into an array.

Code: Select all

Loop, % Fileinput "\*.png"
        obj.FullPath[ ++Index ] := A_LoopFileFullPath

3. As the user cycles through the images in the image viewer, the script checks for the current position and gets the bitmap for 10 images from the array of image paths.

Code: Select all

SetImageList( obj )

Code: Select all

 Loop, % obj.FullPath.Length()  {
	obj.BitMaps[ A_Index ].Bitmap := Gdip_CreateBitmapFromFile( obj.FullPath[ A_Index + obj.Index - 1 ] )
	if( A_Index = 10 )
            break
	...
In this script I don't need to do anything differently with the images based on their extensions. They can be .png .bmp .jpg etc. They just need to be an image that GDIP can process.

This is the lines that sorts the file

Code: Select all

Loop, % Fileinput "\*.png"
        obj.FullPath[ ++Index ] := A_LoopFileFullPath
I just need it to get other image formats.
I tried

Code: Select all

Loop, % Fileinput "\*.png; *.bmp"     ;   % Fileinput "\ (*.png; *.bmp)"          <-----------------------------------
        obj.FullPath[ ++Index ] := A_LoopFileFullPath
and other variations of adding a ";" but that causes no images to get loaded, not even .png's.

If I need to, I can just do this.

Code: Select all

Loop, % Fileinput "\*.png"
        obj.FullPath[ ++Index ] := A_LoopFileFullPath
Loop, % Fileinput "\*.bmp"
        obj.FullPath[ ++Index ] := A_LoopFileFullPath  
Loop, % Fileinput "\*.jpg"
        obj.FullPath[ ++Index ] := A_LoopFileFullPath   
...                   
But I thought that there was a way to get them all in one loop. "*.png; *.bmp".
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: A few questions...

Post by mikeyww » 15 Aug 2021, 12:39

I will add a third time: instead of Loop, % Fileinput "\*.png; *.bmp", use Loop, % Fileinput "\*.*". Inside your loop, use the A_ variable that I mentioned, which contains the file's extension. You can ignore any of the extensions as needed.
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: A few questions...

Post by Hellbent » 15 Aug 2021, 13:07

mikeyww wrote:
15 Aug 2021, 12:39
I will add a third time: instead of Loop, % Fileinput "\*.png; *.bmp", use Loop, % Fileinput "\*.*". Inside your loop, use the A_ variable that I mentioned, which contains the file's extension. You can ignore any of the extensions as needed.
lol.
I see where my confusion came from. In your first comment you mentioned (*.png; *.bmp) and then connected it to the second part about using A_Variable . Since I don't actually care about the ext once they are selected I didn't see the relevance in my case. Then when you mentioned A_Variable again I still assumed you were talking about something else to do with (*.png; *.bmp).

So if i'm correct, this doesn't work (*.png; *.bmp) and it's not some syntax error on my part.
Instead I should use something like this.

Code: Select all

ExtList := ["png","bmp","etc"]
Loop, % Fileinput "\*.*"
	ext := A_LoopFileExt 
	Loop, % ExtList.Length()
		if( ext = ExtList[A_Index]){
			obj.FullPath[ ++Index ] := A_LoopFileFullPath
			break
		}
Or

Code: Select all

ExtList := { png: 1, bmp: 1, jpg: 1}
Loop, % Fileinput "\*.*"
	if( ExtList.HasKey( A_LoopFileExt  ) )
		obj.FullPath[ ++Index ] := A_LoopFileFullPath
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: A few questions...

Post by mikeyww » 15 Aug 2021, 13:17

I did not run your script, but yes, that is the idea.
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: A few questions...

Post by Hellbent » 15 Aug 2021, 13:30

mikeyww wrote:
15 Aug 2021, 13:17
I did not run your script, but yes, that is the idea.
I haven't ran it yet either, but it should work fine. (Not sure yet if A_LoopFileExt has a leading "." in it or not, but easy to adapt to).
I can also just use something like InStr() instead of the two examples above.

Thanks again.

I'll post again once I have had a chance to play with the dropdownlist a bit.
Post Reply

Return to “Ask for Help (v1)”