Я так и не понял,как в autoit получать доступ к глобальной переменной из функции.
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPIGdi.au3>
#include <Array.au3>
Local $hGUI = GUICreate("Image show", 1000, 700)
Local $Array_Base[100]
Local $idButton1 = GUICtrlCreateButton("1", 0, 600, 50,50)
Local $image_counter
$image_counter = find_files()
_ArrayDisplay( $Array_Base)
Local $counter = 0
GUISetState(@SW_SHOW, $hGUI)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
case $idButton1
$counter = $counter + 1
GuiCtrlSetData($idButton1,$counter)
draw_image($Array_Base[$image_counter-$counter])
EndSwitch
WEnd
func draw_image($sFileName)
_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile($sFileName)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
_GDIPlus_Shutdown()
EndFunc
func find_files()
Local $hSearch = FileFindFirstFile("*.png*")
Local $image_counter = 0
Local $sFileName = ""
While 1
$sFileName = FileFindNextFile($hSearch)
$image_counter = $image_counter + 1
_ArrayPush( $Array_Base, $sFileName,1)
If $sFileName ="" then ExitLoop
WEnd
FileClose($hSearch)
return $image_counter
EndFunc
Оказывается я просто был невнимателен и функцию вызывал до определения переменной!
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPIGdi.au3>
#include <Array.au3>
Local $hGUI = GUICreate("Зачем такое нужно 2?", 1000, 700)
Local $Array_Base[100]
Local $idButton1 = GUICtrlCreateButton("1", 0, 600, 50,50)
Local $image_counter = 0
find_files()
_ArrayDisplay( $Array_Base)
Local $counter = 0
GUISetState(@SW_SHOW, $hGUI)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
case $idButton1
$counter = $counter + 1
GuiCtrlSetData($idButton1,$counter)
draw_image($Array_Base[$image_counter-$counter])
EndSwitch
WEnd
func draw_image($sFileName)
_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile($sFileName)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
_GDIPlus_Shutdown()
EndFunc
func find_files()
Local $hSearch = FileFindFirstFile("*.png*")
Local $sFileName = ""
While 1
$sFileName = FileFindNextFile($hSearch)
$image_counter = $image_counter + 1
_ArrayPush( $Array_Base, $sFileName,1)
If $sFileName ="" then ExitLoop
WEnd
FileClose($hSearch)
EndFunc
|