Malukov.Dmitry
18-12-2018, 15:38
Всем доброго вечера !
Подскажите пожалуйста, как можно реализовать следующий сценарий:
Необходимо создать окно, в котором будут отображаться миниатюры изображений
из определенной папки (пример прилагаю). Окно фиксированного размера + скроллбар (если объектов больше определенного числа)
При нажатии на изображение - установка в качестве фона раб.стола + уведомление
При отсутствии объектов - уведомление
155545
Не получается никак, но пока еще только раскуриваю тему.
Необходимо создать окно, в котором будут отображаться миниатюры изображений »
Для начала см. пример к _GUIScrollBars_Init.
Как то так:
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <WindowsConstants.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIScrollBars.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <ScrollBarConstants.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) 'GUIScrollbars_Size.au3'
Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $iGUI_W = 600
Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $iGUI_H = 600
Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $sImages_Path = @ScriptDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@scriptdir) & '\Images'
$hGUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)('Example', $iGUI_W, $iGUI_H)
$aImages = _Images_Load(200, 200)
GUIRegisterMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIRegisterMsg.htm)($WM_VSCROLL, 'WM_VSCROLL')
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)()
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$iMsg = GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)()
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $iMsg
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $aImages[1][0] To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $aImages[$aImages[0][0]][0]
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 1 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $aImages[0][0]
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $iMsg = $aImages[$i][0] Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(0, @ScriptName (http://www.autoitscript.com/autoit3/docs/macros.htm#@scriptname), 'Image ckicked:' & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & $aImages[$i][1], 0, $hGUI)
ExitLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ExitLoop)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _Images_Load($iWidth, $iHeight)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $iWidth > $iGUI_W Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) 0
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $hFind = FileFindFirstFile (http://www.autoitscript.com/autoit3/docs/functions/FileFindFirstFile.htm)($sImages_Path & '\*.jpg')
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $iTop = 0, $iLeft = 0
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $aImages[1][2], $aSize
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$sFile = FileFindNextFile (http://www.autoitscript.com/autoit3/docs/functions/FileFindNextFile.htm)($hFind)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) @error (http://www.autoitscript.com/autoit3/docs/macros.htm#@error) Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) ExitLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ExitLoop)
$aImages[0][0] += 1
ReDim (http://www.autoitscript.com/autoit3/docs/keywords.htm#ReDim) $aImages[$aImages[0][0] + 1][2]
$aImages[$aImages[0][0]][0] = GUICtrlCreatePic (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreatePic.htm)($sImages_Path & '\' & $sFile, $iLeft, $iTop, $iWidth, $iHeight)
$aImages[$aImages[0][0]][1] = $sImages_Path & '\' & $sFile
$iLeft += $iWidth
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $iLeft + $iWidth > $iGUI_W Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$iLeft = 0
$iTop += $iHeight
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $iTop + $iHeight > $iGUI_H Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
_GUIScrollBars_Init (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_Init.htm)($hGUI)
_GUIScrollBars_ShowScrollBar (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_ShowScrollBar.htm)($hGUI, $SB_VERT, True (http://www.autoitscript.com/autoit3/docs/keywords.htm#True))
_GUIScrollBars_ShowScrollBar (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_ShowScrollBar.htm)($hGUI, $SB_HORZ, False (http://www.autoitscript.com/autoit3/docs/keywords.htm#False))
$aSize = _GUIScrollbars_Size(0, $iTop + ($iHeight / 2), $iGUI_W, $iGUI_H)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) @error (http://www.autoitscript.com/autoit3/docs/macros.htm#@error) Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
_GUIScrollBars_SetScrollInfoPage (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_SetScrollInfoPage.htm)($hGUI, $SB_VERT, $aSize[2])
_GUIScrollBars_SetScrollInfoMax (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_SetScrollInfoMax.htm)($hGUI, $SB_VERT, $aSize[3])
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
FileClose (http://www.autoitscript.com/autoit3/docs/functions/FileClose.htm)($hFind)
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $aImages
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $wParam, $lParam
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $nScrollCode = BitAND (http://www.autoitscript.com/autoit3/docs/functions/BitAND.htm)($wParam, 0x0000FFFF)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $iIndex = -1, $yChar, $yPos
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $Min, $Max, $Page, $Pos, $TrackPos
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $x = 0 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) UBound (http://www.autoitscript.com/autoit3/docs/functions/UBound.htm)($aSB_WindowInfo) - 1
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $aSB_WindowInfo[$x][0] = $hWnd Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$iIndex = $x
$yChar = $aSB_WindowInfo[$iIndex][3]
ExitLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ExitLoop)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $iIndex = -1 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) 0
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_GetScrollInfoEx.htm)($hWnd, $SB_VERT)
$Min = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tSCROLLINFO, 'nMin')
$Max = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tSCROLLINFO, 'nMax')
$Page = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tSCROLLINFO, 'nPage')
$yPos = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tSCROLLINFO, 'nPos')
$Pos = $yPos
$TrackPos = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tSCROLLINFO, 'nTrackPos')
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nScrollCode
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $SB_TOP
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($tSCROLLINFO, 'nPos', $Min)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $SB_BOTTOM
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($tSCROLLINFO, 'nPos', $Max)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $SB_LINEUP
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($tSCROLLINFO, 'nPos', $Pos - 1)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $SB_LINEDOWN
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($tSCROLLINFO, 'nPos', $Pos + 1)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $SB_PAGEUP
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($tSCROLLINFO, 'nPos', $Pos - $Page)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $SB_PAGEDOWN
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($tSCROLLINFO, 'nPos', $Pos + $Page)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $SB_THUMBTRACK
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($tSCROLLINFO, 'nPos', $TrackPos)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($tSCROLLINFO, 'fMask', $SIF_POS)
_GUIScrollBars_SetScrollInfo (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_SetScrollInfo.htm)($hWnd, $SB_VERT, $tSCROLLINFO)
_GUIScrollBars_GetScrollInfo (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_GetScrollInfo.htm)($hWnd, $SB_VERT, $tSCROLLINFO)
$Pos = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tSCROLLINFO, 'nPos')
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) ($Pos <> $yPos) Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
_GUIScrollBars_ScrollWindow (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_ScrollWindow.htm)($hWnd, 0, $yChar * ($yPos - $Pos))
$yPos = $Pos
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $GUI_RUNDEFMSG
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)
Нужно скачать (https://www.autoitscript.com/forum/applications/core/interface/file/attachment.php?id=57744) GUIScrollbars_Size.au3 тут (https://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy-new-version-13-may-18/) и положить в папку со скриптом.
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.