Incredible! That DllCallBack is so powerful (I wish I understood it more). Could you comment any of that? I know Piccaso didn't comment on any of it nor did you, but at least where can I learn about what's going on (I don't just want to keep using this stuff without knowing what's going on).
If anyone else comes up with another idea, please let us know.
#include <DllCallBack.au3>
#include <A3LWinAPI.au3>
Global $pWinFlash, $vWinFlash_Jmp, $vWinFlash_Original; Required
Run("notepad","",@SW_MINIMIZE)
Local $winTitle = "Untitled - Notepad"
WinWait("Untitled - Notepad")
Global $WatchForHwnd = WinGetHandle("[Title:Untitled - Notepad]")
_WatchFlashingWinInit()
Sleep(1000*Random(3,8,1));Timer
;~ WinFlash($WatchForHwnd, "",10, 200); Doesn't work for some reason
_API_FlashWindow($WatchForHwnd)
While 1
Sleep(10)
WEnd
Func _WatchFlashingWinInit()
; No comments on this one. If you dont know whats happening just ignore it.
$pStub_WinFlash = _DllCallBack("_WatchFlashingWinInit_Stub_WinFlash", "ptr")
$hUser32 = DllCall("kernel32.dll", "ptr", "LoadLibrary", "str", "user32.dll")
$pWinFlash = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $hUser32[0], "str", "FlashWindowEx")
$vWinFlash_Original = DllStructCreate("ubyte[7]")
DllStructSetData($vWinFlash_Original, 1, DllStructGetData(DllStructCreate("ubyte[7]", $pWinFlash[0]), 1))
$vWinFlash_Jmp = DllStructCreate("ubyte[1];ptr;ubyte[2]")
DllStructSetData($vWinFlash_Jmp, 1, Binary("0xB8"))
DllStructSetData($vWinFlash_Jmp, 2, $pStub_WinFlash)
DllStructSetData($vWinFlash_Jmp, 3, Binary("0xFFE0"))
DllCall("kernel32.dll", "int", "WriteProcessMemory", "ptr", -1, "ptr", $pWinFlash[0], "ptr", DllStructGetPtr($vWinFlash_Jmp), "dword", 7, "long_ptr", 0)
EndFunc
Func _WatchFlashingWinInit_Stub_WinFlash($pFLASHWINFO)
$tFLASHWINFO = DllStructCreate("uint;hwnd;dword;uint;dword", $pFLASHWINFO)
ConsoleWrite("-----------" & @CRLF & _
"Flashing Window Detected:" & @CRLF & _
"handle = " & DllStructGetData($tFLASHWINFO, 2) & @CRLF & _
"flags = " & DllStructGetData($tFLASHWINFO, 3) & @CRLF & _
"count = " & DllStructGetData($tFLASHWINFO, 4) & @CRLF & _
"timeout = " & DllStructGetData($tFLASHWINFO, 5) & @CRLF & _
"WinTitle = " & WinGetTitle(HWnd(DllStructGetData($tFLASHWINFO, 2))) & @CRLF & _
"-----------" & @CRLF)
Local $_winHandle = HWnd(DllStructGetData($tFLASHWINFO, 2))
Local $_winTitle = WinGetTitle(HWnd(DllStructGetData($tFLASHWINFO, 2)))
If $_winHandle = $WatchForHwnd Then
_API_FlashWindow($_winHandle, True)
TrayTip('Did It','Yes',3)
EndIf
DllCall("kernel32.dll", "int", "WriteProcessMemory", "ptr", -1, "ptr", $pWinFlash[0], "ptr", DllStructGetPtr($vWinFlash_Original), "dword", 7, "long_ptr", 0)
DllCall("user32.dll", "int", "FlashWindowEx", "ptr", $pFLASHWINFO)
DllCall("kernel32.dll", "int", "WriteProcessMemory", "ptr", -1, "ptr", $pWinFlash[0], "ptr", DllStructGetPtr($vWinFlash_Jmp), "dword", 7, "long_ptr", 0)
Return 1
EndFunc