#include <GDIPlus.au3>
#include <WinAPISys.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
global const $Setting_ind_PosX = 0
global const $Setting_ind_PosY = 1
global const $Setting_ind_Direction = 2
global const $Setting_ind_Speed = 3
global const $Setting_ind_File = 4
global const $Unknown = 0
global const $Left = 1
global const $Right = 2
global const $Up = 3
global const $Down = 4
global $g_setting[0][5]
global $ScreenWidth = @DesktopWidth
global $ScreenHeight = @DesktopHeight
global $g_hWnd[0]
global $g_WinPosX[0]
global $g_WinPosY[0]
global $g_ImgWidth[0]
global $g_ImgHeight[0]
global $g_Step[0]
global const $TimeSteps = 20
func ClearSettngArrIndex($Ind)
$g_setting[$Ind][$Setting_ind_PosX] = 0
$g_setting[$Ind][$Setting_ind_PosY] = 0
$g_setting[$Ind][$Setting_ind_Direction] = $Unknown
$g_setting[$Ind][$Setting_ind_Speed] = 0
$g_setting[$Ind][$Setting_ind_File] = ""
EndFunc
Func ReadSetting()
redim $g_setting[0][0]
local $ret = 0
local $Count=0
local $IsData=0
local $data = FileReadToArray(@ScriptDir & "\Настройки.txt")
Local $LineCount = @extended
if @error = 0 Then
For $i = 0 To $LineCount - 1
if $data[$i]<>"" and StringIsSpace($data[$i]) = 0 then
if $IsData=0 then
$IsData=1
$Count += 1
redim $g_setting[$Count][5]
ClearSettngArrIndex($Count - 1)
endif
local $Str = StringSplit($data[$i], "=")
if $Str[0]>1 then
if $Str[0] = 2 and $Str[1]<>"" and $Str[2]<>"" then
Switch StringLower($Str[1])
case "начальная координата"
$Str = StringSplit($Str[2], ";")
if $Str[0] >= 2 Then
$g_setting[$Count - 1][$Setting_ind_PosX] = Number($Str[1])
$g_setting[$Count - 1][$Setting_ind_PosY] = Number($Str[2])
endif
case "направление"
Switch StringLower($Str[2])
case "влево"
$g_setting[$Count - 1][$Setting_ind_Direction] = $Left
case "вправо"
$g_setting[$Count - 1][$Setting_ind_Direction] = $Right
case "вверх"
$g_setting[$Count - 1][$Setting_ind_Direction] = $Up
case "вниз"
$g_setting[$Count - 1][$Setting_ind_Direction] = $Down
EndSwitch
case "скорость"
$g_setting[$Count - 1][$Setting_ind_Speed] = Number($Str[2])
EndSwitch
endif
Else
if $Str[1]<>"" or FileExists($Str[1]) Then
$g_setting[$Count-1][$Setting_ind_File] = @ScriptDir & "\" & $Str[1]
endif
endif
Else
if $IsData=1 and $Count>0 then
if $g_setting[$Count-1][$Setting_ind_Direction] <> $Unknown and $g_setting[$Count - 1][$Setting_ind_Speed] > 0 then
if $g_setting[$Count-1][$Setting_ind_File]="" or FileExists($g_setting[$Count-1][$Setting_ind_File])=0 Then
$Count = $Count - 1
endif
Else
$Count = $Count - 1
endif
endif
$IsData=0
endif
Next
endif
if $Count>0 then
$ret = 1
endif
Return $ret
EndFunc
func Init()
local $Count = UBound($g_setting, 1)
redim $g_hWnd[$Count]
redim $g_WinPosX[$Count]
redim $g_WinPosY[$Count]
redim $g_ImgWidth[$Count]
redim $g_ImgHeight[$Count]
redim $g_Step[$Count]
for $i=0 to $Count-1
$g_hWnd[$i] = 0
local $hImage = _GDIPlus_ImageLoadFromFile($g_setting[$i][$Setting_ind_File])
if $hImage then
local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
if $hBitmap then
$g_WinPosX[$i] = $g_setting[$i][$Setting_ind_PosX]
$g_WinPosY[$i] = $g_setting[$i][$Setting_ind_PosY]
$g_ImgWidth[$i] = _GDIPlus_ImageGetWidth($hImage)
$g_ImgHeight[$i] = _GDIPlus_ImageGetHeight($hImage)
$g_Step[$i] = $g_setting[$i][$Setting_ind_Speed] / (1000.0 / $TimeSteps)
$g_hWnd[$i] = GUICreate("", $g_ImgWidth[$i], $g_ImgHeight[$i], $g_WinPosX[$i], $g_WinPosY[$i], $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TRANSPARENT, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
if $g_hWnd[$i] then
_WinAPI_UpdateLayeredWindowEx($g_hWnd[$i], -1, -1, $hBitmap, 255, 1)
GUISetState(@SW_SHOW, $g_hWnd[$i])
endif
_WinAPI_DeleteObject($hBitmap)
endif
_GDIPlus_ImageDispose($hImage)
endif
next
EndFunc
func MovePictures()
local $Count = UBound($g_setting, 1)
for $i=0 to $Count-1
if $g_hWnd[$i] Then
Switch $g_setting[$i][$Setting_ind_Direction]
case $Left
$g_WinPosX[$i] = $g_WinPosX[$i] - $g_Step[$i]
if $g_WinPosX[$i] + $g_ImgWidth[$i] < 0 then $g_WinPosX[$i] = $ScreenWidth
case $Right
$g_WinPosX[$i] = $g_WinPosX[$i] + $g_Step[$i]
if $g_WinPosX[$i] > $ScreenWidth then $g_WinPosX[$i] = 0 - $g_ImgWidth[$i]
case $Up
$g_WinPosY[$i] = $g_WinPosY[$i] - $g_Step[$i]
if $g_WinPosY[$i] + $g_ImgHeight[$i] < 0 then $g_WinPosY[$i] = $ScreenHeight
case $Down
$g_WinPosY[$i] = $g_WinPosY[$i] + $g_Step[$i]
if $g_WinPosY[$i] > $ScreenHeight then $g_WinPosY[$i] = 0 - $g_ImgHeight[$i]
EndSwitch
WinMove($g_hWnd[$i], "", $g_WinPosX[$i], $g_WinPosY[$i])
endif
next
EndFunc
Func AppExit()
AdlibUnRegister("MovePictures")
for $i=0 to UBound($g_hWnd, 1)-1
if $g_hWnd[$i] Then
GUIDelete($g_hWnd[$i])
$g_hWnd[$i] = 0
endif
next
_GDIPlus_Shutdown()
EndFunc
Local $gllPhotoVideo=-1
if @AutoItX64 Then
$gllPhotoVideo = DllOpen(@ScriptDir&"\PhotoVideo\PhotoVideo_x64.dll")
Else
$gllPhotoVideo = DllOpen(@ScriptDir&"\PhotoVideo\PhotoVideo_x86.dll")
endif
if $gllPhotoVideo<>-1 Then
Local $Res = DllCall($gllPhotoVideo, "int", "RunOnce")
if $Res[0]=0 Then
Exit
endif
DllCall($gllPhotoVideo, "none", "CreateWin")
Else
MsgBox(0,"", "Не удалось загрузить PhotoVideo.dll")
endif
_GDIPlus_Startup()
if ReadSetting() then
Init()
AdlibRegister("MovePictures", $TimeSteps)
OnAutoItExitRegister("AppExit")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Else
MsgBox($MB_SYSTEMMODAL, "", "Не удалось прочитать данные файла 'Настройки.txt' или файл пуст")
exit
endif