#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compile_Both=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; Demo FastFind (officielle)
#include "FastFind.au3"
#Include <WinAPI.au3>
global const $DEBUG_DEFAULT = 3
global const $DEBUG_GRAPHIC = $DEBUG_DEFAULT + 4
global const $WINDOW_CLASS = "Notepad" ; CLASS of the target Window
global const $WINDOW_TITLE = "" ; TITLE of the target Window
FFSetDebugMode($DEBUG_GRAPHIC) ; Enable advanced (graphical) debug mode, so you will have traces + graphical feedback
FFSetDefaultSnapShot(0)
HotKeySet("{F5}", "ShowChanges")
HotKeySet("{F6}", "PeriodicChanges")
HotKeySet("{F3}", "SelectWindow")
While (1)
Sleep(10) ; 'til we press "Esc" to leave
Wend
Func SelectWindow()
FFTrace(@lf&" ** SelectWindow"&@lf&"") ; Put this in the different debugging channels as set with FFSetDebugMode
local $hWnd = WinActivate("[CLASS:"&$WINDOW_CLASS&"; TITLE:"&$WINDOW_TITLE&"]", "") ; We try to find and activate the proper windows
if $hWnd="" Then
$hWnd = WinGetHandle("[ACTIVE]", "") ; If the proper set window can't be found, we use the current active window
EndIf
WinSetOnTop ( $hWnd, "", 1)
FFSetDebugMode($DEBUG_DEFAULT)
FFSetWnd($hWnd)
FFSnapShot()
TrayTip("Select Window","Title of the Window: "&WinGetTitle($hWnd)&" Class:"&_WinAPI_GetClassName($hWnd), 2000)
FFTrace(" ** SelectWindow => Title of the Window: "&WinGetTitle($hWnd)&" Class:"&_WinAPI_GetClassName($hWnd)&@lf) ; Put this in the different debugging channels as set with FFSetDebugMode
EndFunc
Func ShowChanges()
FFTrace(@lf&" ** ShowChanges"&@lf) ; Put this in the different debugging channels as set with FFSetDebugMode
FFSetDebugMode($DEBUG_DEFAULT) ; We keep traces in a file, but no graphical display, to avoid adding our own changes on the screen
FFSetDefaultSnapShot(1) ; We select Slot N°1 as the default for next operations
FFSnapShot()
FFSetDebugMode($DEBUG_GRAPHIC) ; Include graphical feedback to see the area that have changed
$Res = FFLocalizeChanges(0, 1) ; We're loonking for differences bestween SnatShot N°0 and N°1
if @Error Then
TrayTip("ShowChanges","No change detected",2000)
FFTrace(" ** ShowChanges => No change detected !"&@lf) ; Put this in the different debugging channels as set with FFSetDebugMode
Else
TrayTip("ShowChanges","Change detected : ("&$Res[0]&","&$Res[1]&","&$Res[2]&","&$Res[3]&"), "&$Res[4]&" pixels are different",2000)
FFTrace(" ** ShowChanges => Change detected : ("&$Res[0]&","&$Res[1]&","&$Res[2]&","&$Res[3]&"), "&$Res[4]&" pixels are different"&@lf) ; Put this in the different debugging channels as set with FFSetDebugMode
EndIf
FFSetDefaultSnapShot(0) ; Back on SnapShot N°0 by default for next operations
FFSnapShot() ; And take New SnapShot (N°0)
EndFunc
; We continuously watch changes on the screen (or selected Window, if any), showing them when any occure (Graphical debug + Tray Message)
Func PeriodicChanges()
while 1
FFSetDebugMode($DEBUG_DEFAULT) ; Remove graphical debug
FFSetDefaultSnapShot(0) ; Take a SnapShot in slot 0
FFSnapShot()
Sleep(300) ; wait 300ms (no need to eat to much CPU), the value here should be much higher compare to the other operations in the loop (less than 100ms alltogether)
FFSetDefaultSnapShot(1) ; Take a second SnapShot in slot 1
FFSnapShot()
FFSetDebugMode($DEBUG_GRAPHIC) ; Activate graphical debug to show the result
$Res = FFLocalizeChanges(0, 1) ; Search all differences between two SnapShots
if @Error Then
FFTrace(" ** ShowChanges => No change detected !"&@lf) ; Put this in the different debugging channels as set with FFSetDebugMode
Else
TrayTip("ShowChanges","Change detected : ("&$Res[0]&","&$Res[1]&","&$Res[2]&","&$Res[3]&"), "&$Res[4]&" pixels are different",2000)
FFTrace(" ** ShowChanges => Change detected : ("&$Res[0]&","&$Res[1]&","&$Res[2]&","&$Res[3]&"), "&$Res[4]&" pixels are different"&@lf) ; Put this in the different debugging channels as set with FFSetDebugMode
EndIf
Wend
EndFunc
Func TheEnd()
FFTrace(" ** Bybye"&@lf&@lf) ; Put this in the different debugging channels as set with FFSetDebugMode
CloseFFDll() ; Unload the DLL, free the memory, close files... makes all the cleaning. Don't use FastFind anymore after this instruction.
Exit
Endfunc
HotKeySet("{ESC}", "TheEnd")