ahha Posted April 23, 2014 Share Posted April 23, 2014 (edited) Upgraded to Windows 8.1 and dual monitor. Have a program that uses _WinAPI_RedrawWindow that does not seem to work. Tried example in help file and it does not erase cross. See notation below. What am I doing wrong? (forgot how to include code in a separate window - sorry) #include <WindowsConstants.au3> #include <WinAPI.au3> ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000) Func ShowCross($start_x, $start_y, $length, $width, $color, $time) Local $hDC, $hPen, $obj_orig $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $width, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $start_x - $length, $start_y, $start_x - 5, $start_y) ; horizontal left _WinAPI_DrawLine($hDC, $start_x + $length, $start_y, $start_x + 5, $start_y) ; horizontal right _WinAPI_DrawLine($hDC, $start_x, $start_y - $length, $start_x, $start_y - 5) ; vertical up ; _WinAPI_DrawLine($hDC, $start_x, $start_y + $length, $start_x, $start_y + 5) ; vertical down _WinAPI_MoveTo($hDC, $start_x, $start_y + $length) _WinAPI_LineTo($hDC, $start_x, $start_y + 5) Sleep($time) ; show cross over screen for defined seconds ; refresh desktop (clear cross) _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN) ;<<<<<< does not seem to work ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>ShowCross Edited April 23, 2014 by ahha Link to comment Share on other sites More sharing options...
Unc3nZureD Posted April 23, 2014 Share Posted April 23, 2014 (edited) Try this one: #include <WindowsConstants.au3> #include <WinAPI.au3> ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000) Func ShowCross($start_x, $start_y, $length, $width, $color, $time) Local $hDC, $hPen, $obj_orig $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $width, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $start_x - $length, $start_y, $start_x - 5, $start_y) ; horizontal left _WinAPI_DrawLine($hDC, $start_x + $length, $start_y, $start_x + 5, $start_y) ; horizontal right _WinAPI_DrawLine($hDC, $start_x, $start_y - $length, $start_x, $start_y - 5) ; vertical up ; _WinAPI_DrawLine($hDC, $start_x, $start_y + $length, $start_x, $start_y + 5) ; vertical down _WinAPI_MoveTo($hDC, $start_x, $start_y + $length) _WinAPI_LineTo($hDC, $start_x, $start_y + 5) Sleep($time) ; show cross over screen for defined seconds ; refresh desktop (clear cross) _WinAPI_RedrawWindow(WinGetHandle("[active]"), 0, 0, BitOR($RDW_INVALIDATE, $RDW_ALLCHILDREN)) ;<<<<<< does not seem to work ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>ShowCross Edited April 23, 2014 by Unc3nZureD Link to comment Share on other sites More sharing options...
ahha Posted April 24, 2014 Author Share Posted April 24, 2014 Unc3nZureD, - No difference. It clearly is an issue with _WinAPI_RedrawWindow I'm wondering if in Windows 8.1 the desktop or "active window" is somehow different. Can anyone else run these scripts and verify behaviour? Link to comment Share on other sites More sharing options...
Solution ahha Posted April 24, 2014 Author Solution Share Posted April 24, 2014 Okay found a similiar thread but with a rectangle issue here: It looks like calling _WinAPI_RedrawWindow like this takes care of the desktop _WinAPI_RedrawWindow(ControlGetHandle("[Class:WorkerW]", "", "SysListView321"), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN) Malkey notes this works for windows 7 and it also seems to work for windows 8.1, as does this _WinAPI_RedrawWindow(ControlGetHandle("[Class:SysListView32]", "", "SysListView321"), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN) I'll check it out furhter and report back - looks like _WinAPI_GetDesktopWindow() or getting the handle to the desktop may be the issue. Link to comment Share on other sites More sharing options...
UEZ Posted April 24, 2014 Share Posted April 24, 2014 Well, if you compare the handles than you will see that they are different: #include <WinAPI.au3> ConsoleWrite(_WinAPI_GetDesktopWindow() & @CRLF) ConsoleWrite(WinGetHandle("[active]") & @CRLF) That means _WinAPI_GetDesktopWindow() isn't working for Win8. Why? Good question. MSDN needs to be asked... Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Unc3nZureD Posted April 24, 2014 Share Posted April 24, 2014 (edited) I've got Windows 8.1 and the script I posted works perfectly for me. That's why I posted it Edited April 24, 2014 by Unc3nZureD Link to comment Share on other sites More sharing options...
ahha Posted April 24, 2014 Author Share Posted April 24, 2014 Strange. Okay here's what my AU3Info shows for the 8.1 desktop. Unc3nZureD - what does your's show? AU3Info.pdf AU3Info.pdf Link to comment Share on other sites More sharing options...
Unc3nZureD Posted April 24, 2014 Share Posted April 24, 2014 (edited) Anyways, why do you sctrictly only want to refresh the desktop? I mean any application can be over the desktop, which means it won't be refreshed (or am I wrong?) Edited April 24, 2014 by Unc3nZureD Link to comment Share on other sites More sharing options...
ahha Posted April 25, 2014 Author Share Posted April 25, 2014 Thanks - AU3Info agrees. For me all applications seem to get refreshed not just the desktop. Since it's working for me, I consider the matter solved. 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