Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/09/2019 in all areas

  1. I have split the documentation into two parts: Download page: Just a quick overview of the provided functions. For details it points to the Wiki. Wiki: Full details What do you think?
    2 points
  2. It is simply a regedit read under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup
    1 point
  3. Use latest version and study the example carefully :
    1 point
  4. @Nine, @Earthshine I've just tested your code above and it works! It reported 0 when the checkbox is unchecked, and 1 when it is checked, and I've tested this on win 10 and PosReady7. All I've got to do now is work my way through the rest of the code to set permissions
    1 point
  5. Here's a C DLL version (attached, or compile with TCC) #include <GDIPlus.au3> #include <ScreenCapture.au3> Global Static $Dll = DllOpen("GrayScaleLUMA.dll") Global $Image, $iWidth, $iHeight, $Pixels, $Gfx, $hGui, $hBmp $hBmp = _ScreenCapture_Capture("", 0, 0, 640, 480) _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) $hGui = GUICreate ("GrayScale DLL", $iWidth, $iHeight, -1, -1) GUISetState(@SW_SHOW, $hGui) $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGui) _GrayScaleLUMA($hImage) _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage, 0, 0, $iWidth, $iHeight) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() Do Sleep(10) Until GUIGetMsg() = - 3 Func _GrayScaleLUMA(ByRef $hImage) $Pixels = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) DllCall($Dll, "int:cdecl", "GrayScaleLUMA", "ptr", $Pixels.Scan0, "int", $iWidth * $iHeight) _GDIPlus_BitmapUnlockBits($hImage, $Pixels) ;$Pixels = 0 EndFunc #cs ======================================================================================================= C code for the DLL, compile with 'Tiny C Compiler' (TCC) https://bellard.org/tcc/ tcc -shared GrayScale.c #include <stdlib.h> __declspec(dllexport) int GrayScaleLUMA(int* pixel, int len) { int i, rgb; for(i = 0; i < len; i++) { rgb=(((pixel[i]&0x00ff0000)>>16)*.3+(((pixel[i]&0x0000ff00))>>8)*.59+(pixel[i]&0x000000ff)*.11); pixel[i]=(pixel[i]&0xff000000)+(rgb<<16)+(rgb<<8)+rgb; } return; } #ce GrayScaleLUMA.dll
    1 point
  6. Enhanced version with image capture : #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> Example() Func Example() _GDIPlus_Startup() ;initialize GDI+ Local $hWnd = WinGetHandle("[CLASS:Photo_Lightweight_Viewer]") WinActivate($hWnd) Local $hCtrl = ControlGetHandle($hWnd, "", "[CLASS:Photos_PhotoCanvas; INSTANCE:1]") Local $aPos = WinGetPos($hCtrl) Local Const $iWidth = $aPos[2], $iHeight = $aPos[3] Local $hGUI = GUICreate("GDI+", $iWidth, $iHeight) ;create a test GUI Local $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object Local $tColorMatrix = _GDIPlus_ColorMatrixCreateGrayScale() ;create greyscale color matrix _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;set greyscale color matrix Local $hHBmp = _ScreenCapture_CaptureWnd("", $hCtrl, 0, 0, $iWidth, $iHeight, False) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) _GDIPlus_ImageSaveToFile($hBitmap, @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC & @MSEC & ".bmp") GUISetState(@SW_SHOW) Do _GDIPlus_GraphicsDrawImageRectRect($hGraphicGUI, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup GDI+ resources _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hGraphicGUI) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example
    1 point
  7. This modified version of the _GDIPlus_ColorMatrixCreateGrayScale function's example in the AutoIt Help file, saves the grayscale bitmap to a file. #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> Example() Func Example() _GDIPlus_Startup() ;initialize GDI+ Local Const $iWidth = 600, $iHeight = 600 Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI GUISetState(@SW_SHOW) Local $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object Local $tColorMatrix = _GDIPlus_ColorMatrixCreateGrayScale() ;create greyscale color matrix _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;set greyscale color matrix Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop Local $hBitmapGUI = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap Local $hBitmapBM = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap Local $hGraphicBM = _GDIPlus_ImageGetGraphicsContext($hBitmapBM) _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore _GDIPlus_GraphicsDrawImageRectRect($hGraphicBM, $hBitmapBM, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment _GDIPlus_ImageSaveToFile($hBitmapBM, @ScriptDir & "\" & @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC & @MSEC & ".bmp") Do _GDIPlus_GraphicsDrawImageRectRect($hGraphicGUI, $hBitmapGUI, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup GDI+ resources _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hGraphicGUI) _GDIPlus_GraphicsDispose($hGraphicBM) _GDIPlus_BitmapDispose($hBitmapGUI) _GDIPlus_BitmapDispose($hBitmapBM) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example
    1 point
  8. Suggestion : _GDIPlus_ColorMatrixCreateGrayScale
    1 point
  9. You can easily find the equation for converting pixel from RGB to grayscale (E.g this Tutorial Spoint) Now your job is iterating through the image, then edit the R, G, B value of every pixel into the newly calculated grayscale value.
    1 point
  10. You want to use the $WS_POPUP style and set the width and height to the desktop dimensions #include <GUIConstants.au3> Global $hMain = GUICreate("Example", 600, 400, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX)) Global $btnFullScreen = GUICtrlCreateButton("Fullscreen", 10, 10, 100, 20) Global $aGuiStyle = GUIGetStyle($hMain) ; Save the default styles GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit 0 Case $btnFullScreen Fullscreen() EndSwitch WEnd Func Fullscreen() Local Static $bFullScreen = False $bFullScreen = Not $bFullScreen Switch ($bFullScreen) Case True GUISetStyle($WS_POPUP, -1, $hMain) WinMove($hMain, "", 0, 0, @DesktopWidth, @DesktopHeight) Case False GUISetStyle($aGuiStyle[0], -1, $hMain) WinMove($hMain, "", 0, 0, 600, 400) EndSwitch EndFunc
    1 point
  11. Sorry, I had a small bug in the last one. Fixed it here by adding Func _preUnlock(). Without this function I had a problem if someone strikes PAUSE key in PC Unlocked state, or if the same key is pressed while the password window is already shown. Here is the corrected code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=lockPC.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinAPI.au3> #include <Timers.au3> #include <Date.au3> Opt("TrayMenuMode", 1) Opt("WinTitleMatchMode", 2) HotKeySet("{PAUSE}", "_preUnlock") ; Values ;------- $idleTimeValue = 10000 ; Idle time to wait until lock $validPass = "pass" ; This password unlocks all, but program still counts idle time and will lock all again if there's no user input $ultimatePass = "secret" ; With this password all is unlocked and program exits $iniFile = "C:\lockPC.log" ; Location and name of log file ;$password = "" ; Declaration of input box variable (must be like this) IniWrite($iniFile, @ComputerName & " - Log", _Now(), "Program started") ; This is the initial idle time check, after this IDLE time PC is locked ;----------------------------------------------------------------------- while 1 if _Timer_GetIdleTime()<$idleTimeValue Then ContinueLoop Else ExitLoop EndIf WEnd Global $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr") Global $pStub_MouseProc = DllCallbackRegister ("_Mouse_Handler", "int", "int;ptr;ptr") Global $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($pStub_KeyProc), _WinAPI_GetModuleHandle(0), 0) Global $hHookMouse = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($pStub_MouseProc), _WinAPI_GetModuleHandle(0), 0) SplashTextOn ( "Lock", "Keyboard and mouse locked!" & @LF & @LF & "Press PAUSE key to unlock",300,100,20,-1,1,"",14,200) for $anim = 0 to 360 WinSetTrans("Lock","",$anim/2) Next IniWrite($iniFile, @ComputerName & " - Log", _Now(), "PC Locked") While 1 Sleep(100) WEnd ; Func _preUnlock is making sure that _UnBlock should be called, without this the script has a bug ;------------------------------------------------------------------------------------------------- Func _preUnlock() If WinExists("Lock") Then call("_UnBlock") Else Beep(500, 100) EndIf EndFunc ; Func _UnBlock runs password check and unlocks only keys needed for password input ;---------------------------------------------------------------------------------- Func _UnBlock() for $anim = 360 to 0 step -1 WinSetTrans("Lock","",$anim/2) Next SplashOff() DllCallbackFree($pStub_KeyProc) _WinAPI_UnhookWindowsHookEx($hHookKeyboard) $pStub_KeyProc = DllCallbackRegister("_noTab", "int", "int;ptr;ptr") $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($pStub_KeyProc), _WinAPI_GetModuleHandle(0), 0) $password = InputBox("UnBlock", "Enter the password", "", "*",-1,130) ; Password check ;---------------- if $password = $validPass Then call("_unlockAll") IniWrite($iniFile, @ComputerName & " - Log", _Now(), "PC Unlocked") while 1 ; Again idle time check, after this IDLE time PC is locked ;---------------------------------------------------------- if _Timer_GetIdleTime()<$idleTimeValue Then ContinueLoop Else call("_unlockAll") call("_block") IniWrite($iniFile, @ComputerName & " - Log", _Now(), "PC Locked") SplashTextOn ( "Lock", "Keyboard and mouse locked!" & @LF & @LF & "Press PAUSE key to unlock",300,100,20,-1,1,"",14,200) for $anim = 0 to 360 WinSetTrans("Lock","",$anim/2) Next ExitLoop EndIf WEnd ;Exit ElseIf $password = $ultimatePass Then call("_unlockAll") IniWrite($iniFile, @ComputerName & " - Log", _Now(), "Secret Password - Program end") Exit else ;WinClose("UnBlock") call("_unlockAll") call("_block") IniWrite($iniFile, @ComputerName & " - Log", _Now(), "Unlock Attempt - Wrong password") SplashTextOn ( "Lock", "Keyboard and mouse locked!" & @LF & @LF & "Press PAUSE key to unlock",300,100,20,-1,1,"",14,200) for $anim = 0 to 360 WinSetTrans("Lock","",$anim/2) Next EndIf EndFunc ; Func _KeyProc determines which keys are locked - $vkCode <> values are keys that are UNLOCKED (Pause key [0x13] and ENTER [0x0D]) ;---------------------------------------------------------------------------------------------------------------------------------- Func _KeyProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) Local $KBDLLHOOKSTRUCT = DllStructCreate("dword vkCode;dword scanCode;dword flags;dword time;ptr dwExtraInfo", $lParam) Local $vkCode = DllStructGetData($KBDLLHOOKSTRUCT, "vkCode") If $vkCode <> 0x13 and $vkCode <> 0x0D Then Return 1 _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) EndFunc Func _Mouse_Handler($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam) Return 1 EndFunc ; Func _block is locking everything ;---------------------------------- Func _block() $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr") $pStub_MouseProc = DllCallbackRegister ("_Mouse_Handler", "int", "int;ptr;ptr") $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($pStub_KeyProc), _WinAPI_GetModuleHandle(0), 0) $hHookMouse = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($pStub_MouseProc), _WinAPI_GetModuleHandle(0), 0) EndFunc ; Func _noTab turns off CTRL, Tab, Left Win, Right Win and App key during the password input ;------------------------------------------------------------------------------------------- Func _noTab($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) Local $KBDLLHOOKSTRUCT = DllStructCreate("dword vkCode;dword scanCode;dword flags;dword time;ptr dwExtraInfo", $lParam) Local $vkCode = DllStructGetData($KBDLLHOOKSTRUCT, "vkCode") If $vkCode = 0x11 or $vkCode = 0x09 or $vkCode = 0x5B or $vkCode = 0x5C or $vkCode = 0x5D Then Return 1 _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) EndFunc ; Func _unlockAll unlocks all (?! really) ;---------------------------------------- Func _unlockAll() DllCallbackFree($pStub_KeyProc) DllCallbackFree($pStub_MouseProc) _WinAPI_UnhookWindowsHookEx($hHookKeyboard) _WinAPI_UnhookWindowsHookEx($hHookMouse) EndFunc
    1 point
×
×
  • Create New...