evilhero Posted January 15, 2018 Share Posted January 15, 2018 Hi everyone ! After making screenshots and searching image script can't delete temp files. where i was wrong ? expandcollapse popup#include <GUIConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include "BmpSearch.au3" #include <Clipboard.au3> #include <ScreenCapture.au3> ;#include <BMP3.au3> #include <WinAPIFiles.au3> #include <FileConstants.au3> ;$Del = Filedelete ("Temp.bmp") ;$Del2 = Filedelete ("Map.bmp") Global $j = 1 Global $Offset=800 ; Для экрана 1920х1080 $hForm = GUICreate('', 550, 550,1960-$Offset, 540,$WS_EX_TOPMOST + $WS_SIZEBOX + $WS_SYSMENU) ; Создаем форму для отслеживания построения карты $PIC1 = GUICtrlCreatePic("",0,0,500,500) ; Тут отображение карты в форме $PIC2 = GUICtrlCreatePic("",0,0,31,31) ; Тут мы видим, что захватили скриншотом Global $LargePath = @Scriptdir & "\Large.bmp" Global $TempPath = @Scriptdir & "\Temp.bmp" Global $MapPath = @Scriptdir & "\Map.bmp" Global $MapPath1 = @Scriptdir & "\Map1.bmp" Global $MapPathTMP = @Scriptdir & "\MapTMP.bmp" Global $SmallPath = @Scriptdir & "\Small.bmp" HotKeySet("+!q", "_MapCreate") ; Shift-Alt-q HotKeySet("+!e", "_Capture") ; Shift-Alt-e HotKeySet("r", "Terminate") Global $aCords=0 GUISetState() _GDIPlus_Startup() WinSetOnTop($hForm, " ", 1) ; Форма поверх всех окон While 1 Sleep(1000) _MapCreate() WEnd Func _MapCreate() $err = False ; Local $hHighlight_Capture = GUICreate('', 31, 31, -1, -1, $WS_POPUPWINDOW, $WS_EX_CONTROLPARENT) ; подсвечиваем место, где делаем захват изображения ;GUISetState(@SW_SHOW) ; WinSetOnTop($hHighlight_Capture, '', 1) ; WinMove($hHighlight_Capture, '', 2269-$Offset, 244) ;Sleep (1000) ; Водсвечиваем область 1 сек ; GUIDelete($hHighlight_Capture) ; Удаляем подсветку $hSmall = _ScreenCapture_Capture('', 2269-$Offset, 244, 2269-$Offset + 12, 244 + 12) ;Захватываем "маленькое" изображение $hLarge = _ScreenCapture_Capture('', 2260-$Offset, 235, 2290-$Offset, 265) ;Захватываем "большое" изображение $hLargeImage = _GDIPlus_BitmapCreateFromHBITMAP ($hLarge) ; Создаем объект _GDIPlus_ImageSaveToFile ($hLargeImage,$TempPath) ; Сохраняем в файл на сякий случай $hSmallImage = _GDIPlus_BitmapCreateFromHBITMAP ($hSmall) ; Создаем объект _GDIPlus_ImageSaveToFile ($hSmallImage,$SmallPath) ; Сохраняем в файл на сякий случай GUICtrlSetImage($PIC2,$TempPath); Выводим картики в форму GUICtrlSetImage($PIC1,$MapPath) GUISetState() Local $hBmp = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\123.bmp") ;На этой картике мы ищем "маленькое" изображение <<< Local $hSource = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp); Создаем объект $aCords = _BmpSearch($hSource, $hSmall); Ищем изображение If @error Then ConsoleWrite("Не найдено" & @CRLF) MsgBox(0, "NO MATCHES", "No Matches Found!" & $j) Else ConsoleWrite("X:" & $aCords[1][2] & " Y:" &$aCords[1][3] & " time:" & @extended & @CRLF) WinSetTitle($hForm, 'Found', "X:" & $aCords[1][2] & " Y:" & $aCords[1][3]& " J:" & $j ) ;Пишем в заголовк координаты найденного изображения $Path = (@Scriptdir & "\Temp\Temp"& $j& ".bmp") _GDIPlus_ImageSaveToFile ($hLargeImage,$Path) GUICtrlCreatePic($Path,(($aCords[1][2])-9),(($aCords[1][3])-9),31,31) ; Заполняем форму захваченными изображениями GUICtrlSetImage(-1,$Path) GUISetState() $j+=1 Local $Map = _GDIPlus_BitmapCreateFromFile($MapPath) ;Открываем шаблон карты Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($Map) ;Получаем графический контекст _GDIPlus_GraphicsDrawImage($hGraphic, $hLargeImage, (($aCords[1][2])-9), (($aCords[1][3])-9)) ; Наносим отснятое изображение в шаблон карты в найденные координаты _GDIPlus_ImageSaveToFile ($Map,$MapPath1); Сохраняем шаблон в новый файл EndIf ;Чистим ресурсы _WinAPI_DeleteObject($hSource) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hLargeImage) _GDIPlus_ImageDispose($hSmallImage) _GDIPlus_PathDispose($MapPath) _GDIPlus_PathDispose($MapPath1) _WinAPI_DeleteObject($hSmall) _WinAPI_DeleteObject($hLarge) _WinAPI_DeleteObject($Map) Local $iDelete = FileDelete($MapPath) ;Удаляем шаблон If $iDelete Then ; MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.") Else MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.1") EndIf FileMove($MapPath1,$MapPathTMP, $FC_OVERWRITE + $FC_CREATEPATH) ;Копируем результат наложения изображений во временный файл FileMove($MapPathTMP,$MapPath, $FC_OVERWRITE + $FC_CREATEPATH) ;Заменяем шаблон на новый _GDIPlus_PathDispose($MapPath1) FileClose($MapPath1) Local $iDelete1 = FileDelete($MapPath1); Удаляем файл If $iDelete1 Then ; MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.") Else MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.2") EndIf Local $iDelete2 = FileDelete($MapPathTMP); Удаляем файл If $iDelete2 Then ; MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.") Else MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.3") EndIf EndFunc ;==>_MapCreate Func Terminate() Exit EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
careca Posted January 15, 2018 Share Posted January 15, 2018 Cant test dont have BmpSearch.au3 evilhero 1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
evilhero Posted January 15, 2018 Author Share Posted January 15, 2018 test please BmpSearch.au3 Link to comment Share on other sites More sharing options...
careca Posted January 15, 2018 Share Posted January 15, 2018 Got this error in the udf "C:\Users\careca\Desktop\BmpSearch.au3" (46) : ==> Variable must be of type "Object".: Local $iRowInc = ($tSizeSource.X - $tSizeFind.X) * 4 Local $iRowInc = ($tSizeSource^ ERROR The return for the functions is "$tagSIZE structure that contains the bitmap dimension, in pixels." Something like DllStructGetData($tSizeSource, 'X') Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
evilhero Posted January 15, 2018 Author Share Posted January 15, 2018 i'm dont getting error like that and use same code ... more questions. Link to comment Share on other sites More sharing options...
evilhero Posted January 15, 2018 Author Share Posted January 15, 2018 try this code pls expandcollapse popup#include <GUIConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include "BmpSearch.au3" #include <Clipboard.au3> #include <ScreenCapture.au3> ;#include <BMP3.au3> #include <WinAPIFiles.au3> #include <FileConstants.au3> ;$Del = Filedelete ("Temp.bmp") ;$Del2 = Filedelete ("Map.bmp") Global $j = 1 Global $Offset=0 ; Для экрана 1920х1080 $hForm = GUICreate('', 550, 550,1960-$Offset, 540,$WS_EX_TOPMOST + $WS_SIZEBOX + $WS_SYSMENU) ; Создаем форму для отслеживания построения карты $PIC1 = GUICtrlCreatePic("",0,0,500,500) ; Тут отображение карты в форме $PIC2 = GUICtrlCreatePic("",0,0,31,31) ; Тут мы видим, что захватили скриншотом Global $LargePath = @Scriptdir & "\Large.bmp" Global $TempPath = @Scriptdir & "\Temp.bmp" Global $MapPath = @Scriptdir & "\Map.bmp" Global $MapPath1 = @Scriptdir & "\Map1.bmp" Global $MapPathTMP = @Scriptdir & "\MapTMP.bmp" Global $SmallPath = @Scriptdir & "\Small.bmp" HotKeySet("+!q", "_MapCreate") ; Shift-Alt-q HotKeySet("+!e", "_Capture") ; Shift-Alt-e HotKeySet("r", "Terminate") GUISetState() _GDIPlus_Startup() WinSetOnTop($hForm, " ", 1) ; Форма поверх всех окон While 1 Sleep(1000) _MapCreate() WEnd Func _MapCreate() $err = False ; Local $hHighlight_Capture = GUICreate('', 31, 31, -1, -1, $WS_POPUPWINDOW, $WS_EX_CONTROLPARENT) ; подсвечиваем место, где делаем захват изображения ;GUISetState(@SW_SHOW) ; WinSetOnTop($hHighlight_Capture, '', 1) ; WinMove($hHighlight_Capture, '', 2269-$Offset, 244) ;Sleep (1000) ; Водсвечиваем область 1 сек ; GUIDelete($hHighlight_Capture) ; Удаляем подсветку ;$hSmall = _ScreenCapture_Capture('', 2269-$Offset, 244, 2269-$Offset + 12, 244 + 12) ;Захватываем "маленькое" изображение $hSmall = _GDIPlus_BitmapCreateFromFile($SmallPath) ;$hLarge = _ScreenCapture_Capture('', 2260-$Offset, 235, 2290-$Offset, 265) ;Захватываем "большое" изображение $hLarge = _GDIPlus_BitmapCreateFromFile($TempPath) $hLargeImage = _GDIPlus_BitmapCreateFromHBITMAP ($hLarge) ; Создаем объект ; _GDIPlus_ImageSaveToFile ($hLargeImage,$TempPath) ; Сохраняем в файл на сякий случай $hSmallImage = _GDIPlus_BitmapCreateFromHBITMAP ($hSmall) ; Создаем объект ; _GDIPlus_ImageSaveToFile ($hSmallImage,$SmallPath) ; Сохраняем в файл на сякий случай GUICtrlSetImage($PIC2,$TempPath); Выводим картики в форму GUICtrlSetImage($PIC1,$MapPath) GUISetState() Local $hBmp = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\123.bmp") ;На этой картике мы ищем "маленькое" изображение <<< Local $hSource = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp); Создаем объект ;$aCords = _BmpSearch($hSource, $hSmall); Ищем изображение ;If @error Then ; ConsoleWrite("Не найдено" & @CRLF) ; MsgBox(0, "NO MATCHES", "No Matches Found!" & $j) ;Else ; ConsoleWrite("X:" & 250 & " Y:" &$aCords[1][3] & " time:" & @extended & @CRLF) WinSetTitle($hForm, 'Found', "X:" & "250" & " Y:" & "250" & " J:" & $j ) ;Пишем в заголовк координаты найденного изображения $Path = (@Scriptdir & "\Temp\Temp"& $j& ".bmp") _GDIPlus_ImageSaveToFile ($hLargeImage,$Path) GUICtrlCreatePic($Path,(250-9),(250-9),31,31) ; Заполняем форму захваченными изображениями GUICtrlSetImage(-1,$Path) GUISetState() $j+=1 Local $Map = _GDIPlus_BitmapCreateFromFile($MapPath) ;Открываем шаблон карты Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($Map) ;Получаем графический контекст _GDIPlus_GraphicsDrawImage($hGraphic, $hLargeImage, (250-9), (250-9)) ; Наносим отснятое изображение в шаблон карты в найденные координаты _GDIPlus_ImageSaveToFile ($Map,$MapPath1); Сохраняем шаблон в новый файл ;EndIf ;Чистим ресурсы _WinAPI_DeleteObject($hSource) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hLargeImage) _GDIPlus_ImageDispose($hSmallImage) _GDIPlus_PathDispose($MapPath) _GDIPlus_PathDispose($MapPath1) _WinAPI_DeleteObject($hSmall) _WinAPI_DeleteObject($hLarge) _WinAPI_DeleteObject($Map) FileClose($MapPath) Local $iDelete = FileDelete($MapPath) ;Удаляем шаблон If $iDelete Then ; MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.") Else MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.1") EndIf FileMove($MapPath1,$MapPathTMP, $FC_OVERWRITE + $FC_CREATEPATH) ;Копируем результат наложения изображений во временный файл FileMove($MapPathTMP,$MapPath, $FC_OVERWRITE + $FC_CREATEPATH) ;Заменяем шаблон на новый _GDIPlus_PathDispose($MapPath1) FileClose($MapPath1) Local $iDelete1 = FileDelete($MapPath1); Удаляем файл If $iDelete1 Then ; MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.") Else MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.2") EndIf Local $iDelete2 = FileDelete($MapPathTMP); Удаляем файл If $iDelete2 Then ; MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.") Else MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.3") EndIf EndFunc ;==>_MapCreate Func Terminate() Exit EndFunc ;==>Terminate And with this images 123.bmp Map.bmp Small.bmp Temp.bmp Link to comment Share on other sites More sharing options...
careca Posted January 15, 2018 Share Posted January 15, 2018 (edited) the only thing you missed was this _GDIPlus_BitmapDispose($Map) _GDIPlus_BitmapCreateFromFile requires that, and because of it, when you tried to delete the file, it's still in use and it's not deleted. As for the rest of the files, you move them/rename, so when you try to delete, they dont exist. Edited January 15, 2018 by careca evilhero 1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Earthshine Posted January 16, 2018 Share Posted January 16, 2018 careca, send him the bill for testing.. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
careca Posted January 16, 2018 Share Posted January 16, 2018 Sometimes a person thinks he's been through everything, cant find the issue, and just needs another person to analyse stuff. Earthshine 1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now