Christos Posted December 4, 2008 Posted December 4, 2008 @ corgano your function is still not working for me! Is crashing after 8 10 seconds if I move the mouse. My screen 1920x1200 is not complete black, I see a small stripe of my desktop on the right side. @ UEZ your function is working for me.
corgano Posted December 4, 2008 Author Posted December 4, 2008 (edited) @ corgano your function is still not working for me! Is crashing after 8 10 seconds if I move the mouse. My screen 1920x1200 is not complete black, I see a small stripe of my desktop on the right side.@ UEZ your function is working for me.thats odd. its width is suposed to be screen width + 30........are you useing the newest beta autoit? Edited December 4, 2008 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
Christos Posted December 4, 2008 Posted December 4, 2008 I have tried with the latest beta and v3.2.12.1, both with the same result. I have here a screenshot of my Desktop.
UEZ Posted December 4, 2008 Posted December 4, 2008 I've tested it on my dual monitor and it didn't work properly. The mouse and the "hole" are not on same position because of virtual screen size. Here the corrected code: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 78);sm_virtualwidth $VirtualDesktopWidth = $VirtualDesktopWidth[0] $VirtualDesktopHeight = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 79);sm_virtualheight $VirtualDesktopHeight = $VirtualDesktopHeight[0] $VirtualDesktopX = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 76);sm_xvirtualscreen $VirtualDesktopX = $VirtualDesktopX[0] $VirtualDesktopY = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 77);sm_yvirtualscreen $VirtualDesktopY = $VirtualDesktopY[0] Global $hGUI = GUICreate("Test", $VirtualDesktopWidth, $VirtualDesktopHeight, $VirtualDesktopX, $VirtualDesktopY, $WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) HotKeySet("{ESC}", "Quit") GUISetBkColor (0x000000) GUISetState(@SW_SHOW) While 1 $diameter = 200 $radius = $diameter / 2 $pos = MouseGetPos() _GuiHole($hGUI , Abs($VirtualDesktopX) + $pos[0] - $radius, Abs($VirtualDesktopY) + $pos[1] - $radius, $diameter) Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Quit() ; exit program Exit EndFunc Func _GuiHole($h_win, $i_x, $i_y, $i_size) ;modified code by ProgAndy Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn, $ret $pos = WinGetPos($h_win) $outer_rgn = DllCall("gdi32.dll", "hwnd", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3]) If IsArray($outer_rgn) Then $inner_rgn = DllCall("gdi32.dll", "hwnd", "CreateEllipticRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_size, "long", $i_y + $i_size) If IsArray($inner_rgn) Then DllCall("gdi32.dll", "long", "CombineRgn", "hwnd", $outer_rgn[0], "hwnd", $outer_rgn[0], "hwnd", $inner_rgn[0], "int", 4) $ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "hwnd", $outer_rgn[0], "int", 1) ;~ DllCall("gdi32.dll", "long", "DeleteObject", "hwnd", $inner_rgn[0]) If $ret[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf Else Return 0 EndIf EndFunc ;==>_GuiHole Whole screen is black, not only main window on primary monitor! 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
AzKay Posted December 4, 2008 Posted December 4, 2008 I've tested it on my dual monitor and it didn't work properly. The mouse and the "hole" are not on same position because of virtual screen size. Here the corrected code: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 78);sm_virtualwidth $VirtualDesktopWidth = $VirtualDesktopWidth[0] $VirtualDesktopHeight = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 79);sm_virtualheight $VirtualDesktopHeight = $VirtualDesktopHeight[0] $VirtualDesktopX = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 76);sm_xvirtualscreen $VirtualDesktopX = $VirtualDesktopX[0] $VirtualDesktopY = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 77);sm_yvirtualscreen $VirtualDesktopY = $VirtualDesktopY[0] Global $hGUI = GUICreate("Test", $VirtualDesktopWidth, $VirtualDesktopHeight, $VirtualDesktopX, $VirtualDesktopY, $WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) HotKeySet("{ESC}", "Quit") GUISetBkColor (0x000000) GUISetState(@SW_SHOW) While 1 $diameter = 200 $radius = $diameter / 2 $pos = MouseGetPos() _GuiHole($hGUI , Abs($VirtualDesktopX) + $pos[0] - $radius, Abs($VirtualDesktopY) + $pos[1] - $radius, $diameter) Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Quit() ; exit program Exit EndFunc Func _GuiHole($h_win, $i_x, $i_y, $i_size) ;modified code by ProgAndy Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn, $ret $pos = WinGetPos($h_win) $outer_rgn = DllCall("gdi32.dll", "hwnd", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3]) If IsArray($outer_rgn) Then $inner_rgn = DllCall("gdi32.dll", "hwnd", "CreateEllipticRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_size, "long", $i_y + $i_size) If IsArray($inner_rgn) Then DllCall("gdi32.dll", "long", "CombineRgn", "hwnd", $outer_rgn[0], "hwnd", $outer_rgn[0], "hwnd", $inner_rgn[0], "int", 4) $ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "hwnd", $outer_rgn[0], "int", 1) ;~ DllCall("gdi32.dll", "long", "DeleteObject", "hwnd", $inner_rgn[0]) If $ret[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf Else Return 0 EndIf EndFunc ;==>_GuiHole Whole screen is black, not only main window on primary monitor! UEZWorks perfectly. xD # MY LOVE FOR YOU... IS LIKE A TRUCK- #
ResNullius Posted December 4, 2008 Posted December 4, 2008 Add WinSetTrans($hGui,"",20) just after the GUISetBkColor (0x000000) and then you've got something that can "spotlight" a portion of the screen, like some projectors have to draw attention to certain areas. In fact, I bet somebody with more time on their hands could easily make up a utility that would have different shaped holes with maybe even dynamic resizing & colouring to make a cool screen spotlighter...
spudw2k Posted December 4, 2008 Posted December 4, 2008 (edited) Very cool. I like the latest ver a lot. Works great on my dual screen setup. edit: My own updated ver. Uses scroll wheel to adjust the size of the guihole. spuds_candle.au3 Edited December 4, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Delta Posted December 5, 2008 Posted December 5, 2008 Add #include <WindowsConstants.au3> Remove dim $WS_EX_TOPMOST, $WS_MAXIMIZE Replace @DesktopWidth + 10, @DesktopHeight-1, -10, -30,"" ,0x00000008 with @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, 0 The result is a perfect black window that covers up everything including the taskbar as long as the gui is topmost and selected. [size="1"]Please stop confusing "how to" with "how do"[/size]
UEZ Posted December 5, 2008 Posted December 5, 2008 Here all suggestion in one code: expandcollapse popup;mixed together by UEZ #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #Include <WinAPI.au3> Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global Const $WM_MOUSEWHEEL = 0x020A ;wheel up/down Global $diameter = 200 $VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 78);sm_virtualwidth $VirtualDesktopWidth = $VirtualDesktopWidth[0] $VirtualDesktopHeight = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 79);sm_virtualheight $VirtualDesktopHeight = $VirtualDesktopHeight[0] $VirtualDesktopX = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 76);sm_xvirtualscreen $VirtualDesktopX = $VirtualDesktopX[0] $VirtualDesktopY = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 77);sm_yvirtualscreen $VirtualDesktopY = $VirtualDesktopY[0] $hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) Global $hGUI = GUICreate("The HOLE", $VirtualDesktopWidth, $VirtualDesktopHeight, $VirtualDesktopX, $VirtualDesktopY, $WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) HotKeySet("{ESC}", "Quit") GUISetBkColor (0x000000) WinSetTrans($hGui,"", 224) GUISetState(@SW_SHOW) While 1 $radius = $diameter / 2 $pos = MouseGetPos() _GuiHole($hGUI , Abs($VirtualDesktopX) + $pos[0] - $radius, Abs($VirtualDesktopY) + $pos[1] - $radius, $diameter) Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Quit() ; exit program DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 Exit EndFunc Func _GuiHole($h_win, $i_x, $i_y, $i_size) ;modified code by ProgAndy Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn, $ret $pos = WinGetPos($h_win) $outer_rgn = DllCall("gdi32.dll", "hwnd", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3]) If IsArray($outer_rgn) Then $inner_rgn = DllCall("gdi32.dll", "hwnd", "CreateEllipticRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_size, "long", $i_y + $i_size) If IsArray($inner_rgn) Then DllCall("gdi32.dll", "long", "CombineRgn", "hwnd", $outer_rgn[0], "hwnd", $outer_rgn[0], "hwnd", $inner_rgn[0], "int", 4) $ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "hwnd", $outer_rgn[0], "int", 1) ;~ DllCall("gdi32.dll", "long", "DeleteObject", "hwnd", $inner_rgn[0]) If $ret[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf Else Return 0 EndIf EndFunc ;==>_GuiHole Func _Mouse_Proc($nCode, $wParam, $lParam) ;function called for mouse events.. ;define local vars Local $info, $ptx, $pty, $mouseData, $flags, $time, $dwExtraInfo Local $xevent = "Unknown", $xmouseData = "" If $nCode < 0 Then ;recommended, see http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) ;recommended Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) ;used to get all data in the struct ($lParam is the ptr) $ptx = DllStructGetData($info, 1) ;see notes below.. $pty = DllStructGetData($info, 2) $mouseData = DllStructGetData($info, 3) $flags = DllStructGetData($info, 4) $time = DllStructGetData($info, 5) $dwExtraInfo = DllStructGetData($info, 6) ;Find which event happened Select Case $wParam = $WM_MOUSEWHEEL If _WinAPI_HiWord($mouseData) > 0 Then $xmouseData = "Wheel Forward" ConsoleWrite($diameter & @CRLF) If $diameter < $VirtualDesktopWidth Then $diameter += 40 Else $xmouseData = "Wheel Backward" ConsoleWrite($diameter & @CRLF) If $diameter > 0 Then $diameter -= 40 EndIf EndSelect ;This is recommended instead of Return 0 $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_Mouse_Proc @spudw2k: your exit code was not correct initialized 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
ProgAndy Posted December 5, 2008 Posted December 5, 2008 @UEZ: made some changes, too change size with SHIFT-Scroll -> scroll wheel not useless in other apps moved _GUIHole to MouseProc -> doesn't need to update when mouse not moved. expandcollapse popup;mixed together by UEZ #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #Include <WinAPI.au3> #Include <Misc.au3> Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global Const $WM_MOUSEWHEEL = 0x020A ;wheel up/down Global $diameter = 200 $VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 78);sm_virtualwidth $VirtualDesktopWidth = $VirtualDesktopWidth[0] $VirtualDesktopHeight = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 79);sm_virtualheight $VirtualDesktopHeight = $VirtualDesktopHeight[0] $VirtualDesktopX = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 76);sm_xvirtualscreen $VirtualDesktopX = $VirtualDesktopX[0] $VirtualDesktopY = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 77);sm_yvirtualscreen $VirtualDesktopY = $VirtualDesktopY[0] $hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) Global $hGUI = GUICreate("The HOLE", $VirtualDesktopWidth, $VirtualDesktopHeight, $VirtualDesktopX, $VirtualDesktopY, $WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) HotKeySet("{ESC}", "Quit") GUISetBkColor (0x000000) WinSetTrans($hGui,"", 224) GUISetState(@SW_SHOW) $pos = MouseGetPos() _GuiHole($hGUI , Abs($VirtualDesktopX) + $pos[0] - 100, Abs($VirtualDesktopY) + $pos[1] - 100, $diameter) While 1 ;~ $radius = $diameter / 2 ;~ $pos = MouseGetPos() ;~ _GuiHole($hGUI , Abs($VirtualDesktopX) + $pos[0] - $radius, Abs($VirtualDesktopY) + $pos[1] - $radius, $diameter) ;~ Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Quit() ; exit program DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 Exit EndFunc Func _GuiHole($h_win, $i_x, $i_y, $i_size) ;modified code by ProgAndy Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn, $ret $pos = WinGetPos($h_win) $outer_rgn = DllCall("gdi32.dll", "hwnd", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3]) If IsArray($outer_rgn) Then $inner_rgn = DllCall("gdi32.dll", "hwnd", "CreateEllipticRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_size, "long", $i_y + $i_size) If IsArray($inner_rgn) Then DllCall("gdi32.dll", "long", "CombineRgn", "hwnd", $outer_rgn[0], "hwnd", $outer_rgn[0], "hwnd", $inner_rgn[0], "int", 4) $ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "hwnd", $outer_rgn[0], "int", 1) ;~ DllCall("gdi32.dll", "long", "DeleteObject", "hwnd", $inner_rgn[0]) If $ret[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf Else Return 0 EndIf EndFunc ;==>_GuiHole Func _Mouse_Proc($nCode, $wParam, $lParam) ;function called for mouse events.. ;define local vars Local $info, $ptx, $pty, $mouseData, $flags, $time, $dwExtraInfo Local $xevent = "Unknown", $xmouseData = "" If $nCode < 0 Then ;recommended, see http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) ;recommended Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) ;used to get all data in the struct ($lParam is the ptr) $ptx = DllStructGetData($info, 1) ;see notes below.. $pty = DllStructGetData($info, 2) $mouseData = DllStructGetData($info, 3) $flags = DllStructGetData($info, 4) $time = DllStructGetData($info, 5) $dwExtraInfo = DllStructGetData($info, 6) ;Find which event happened Select Case $wParam = $WM_MOUSEWHEEL If _IsPressed("10") Then ; If SHIFT pressed If _WinAPI_HiWord($mouseData) > 0 Then $xmouseData = "Wheel Forward" ConsoleWrite($diameter & @CRLF) If $diameter < $VirtualDesktopWidth Then $diameter += 40 Else $xmouseData = "Wheel Backward" ConsoleWrite($diameter & @CRLF) If $diameter > 0 Then $diameter -= 40 EndIf EndIf EndSelect $radius = $diameter / 2 ;~ $pos = MouseGetPos() ;~ _GuiHole($hGUI , Abs($VirtualDesktopX) + $pos[0] - $radius, Abs($VirtualDesktopY) + $pos[1] - $radius, $diameter) _GuiHole($hGUI , Abs($VirtualDesktopX) + $ptx - $radius, Abs($VirtualDesktopY) + $pty - $radius, $diameter) ;This is recommended instead of Return 0 $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_Mouse_Proc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
UEZ Posted December 5, 2008 Posted December 5, 2008 @ProgAndy: thanks again! Nice to learn from your coding examples... 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
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