Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/18/2024 in all areas

  1. Hi @TheSaint Here a fast hack how to rotate the image by drawing a line on the edge of the CD cover to give you more flexibility. ;Coded by UEZ 2024-03-16 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $sFile = "cover.jpg" ;FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit Const $fPI = ACos(-1) _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sFile), $hImage_rotated Global $aDim = _GDIPlus_ImageGetDimension($hImage) Global Const $hGUI = GUICreate("Image Rotate", $aDim[0], $aDim[1]) Global Const $hDC = _WinAPI_GetDC($hGUI) Global Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aDim[0], $aDim[1]) Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Global Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) Global Const $hPen = _GDIPlus_PenCreate(0xFFFFFFFF) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, 4) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) GUISetCursor(3, 0, $hGUI) GUISetState() Global $aCI, $c = 0, $x1, $y1, $x2, $y2 Do _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) $aCI = GUIGetCursorInfo($hGUI) If $aCI[2] Then While GUIGetCursorInfo($hGUI)[2] Sleep(1) WEnd $c += 1 Switch $c Case 1 $x1 = $aCI[0] $y1 = $aCI[1] Case 2 $x2 = $aCI[0] $y2 = $aCI[1] EndSwitch EndIf Switch $c Case 1 _GDIPlus_GraphicsDrawLine($hCanvas, $x1, $y1, $aCI[0], $aCI[1], $hPen) Case 2 _GDIPlus_GraphicsDrawLine($hCanvas, $x1, $y1, $x2, $y2, $hPen) EndSwitch _WinAPI_BitBlt($hDC, 0, 0, $aDim[0], $aDim[1], $hDC_backbuffer, 0, 0, $SRCCOPY) If $aCI[3] Then ExitLoop Sleep(10) Until False _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) _GDIPlus_ImageRotate($hImage, 360 - CalculateAngle($x1, $y1, $x2, $y2)) $hImage_rotated = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) ;save result _GDIPlus_GraphicsClear($hCanvas) Do _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage_rotated, 0, 0, $aDim[0], $aDim[1]) _WinAPI_BitBlt($hDC, 0, 0, $aDim[0], $aDim[1], $hDC_backbuffer, 0, 0, $SRCCOPY) Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_ImageDispose($hImage) _GDIPlus_ImageDispose($hImage_rotated) _GDIPlus_Shutdown() Func CalculateAngle($x1, $y1, $x2, $y2) Return ATan(($y2 - $y1) / ($x2 - $x1)) * (180 / $fPi) + ($x1 > $x2 ? 180 : ($y1 > $y2 ? 360 : 0)) EndFunc Func _GDIPlus_ImageRotate($hImage, $fDegree) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fDegree = ' & $fDegree & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $aDim[0] / 2, $aDim[1] / 2) _GDIPlus_MatrixRotate($hMatrix, $fDegree) _GDIPlus_MatrixTranslate($hMatrix, -$aDim[0] / 2, -$aDim[1] / 2) _GDIPlus_GraphicsSetTransform($hCanvas, $hMatrix) _GDIPlus_MatrixDispose($hMatrix) EndFunc After you have started the script and the image is displayed click (lmb) on the left upper corner of the CD cover move the move the mouse to the right upper corner of the CD cover and press click the lmb again press the right mouse button The image should be rotated according to the angle of x1, y1 and x2, y2. You may add a crop function to get only a desired area of the image. 😉
    3 points
  2. Version 1.0.2

    1,743 downloads

    Added the ability to load a custom CSS file where you can change the look of help pages as you would with any html file displaying in Internet Explorer. Also, all external links open in your default browser. Replace the v3.3.16.1 CHM with the one in the ZIP along with the CSS file of your choosing to the same folder the CHM is at.
    2 points
  3. @UEZ, nice. I've fiddled with the UEZ listing a bit you can now rotate the image visually with a slider you can also finely adjust the rotation with two buttons I also added 2 "rulers", one vertical and one horizontal, which you can move by clicking on them and dragging them, in order to have a reference to control the orientation of the image ;Coded by UEZ 2024-03-16 ; [few mods by Gianni :) ] #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; --- rulers ----- Global $iThickness = 4 Global $hGUI1 = GUICreate("", @DesktopWidth, $iThickness, 0, @DesktopHeight / 2, $WS_POPUP, $WS_EX_TOPMOST) GUICtrlCreateLabel("", 0, 0, @DesktopWidth, $iThickness, -1, $GUI_WS_EX_PARENTDRAG) GUISetBkColor(0x00ff00, $hGUI1) WinSetTrans($hGUI1, "", 127) GUISetState(@SW_SHOW, $hGUI1) Global $hGUI2 = GUICreate("", $iThickness, @DesktopHeight, @DesktopWidth / 2, 0, $WS_POPUP, $WS_EX_TOPMOST) GUICtrlCreateLabel("", 0, 0, $iThickness, @DesktopHeight, -1, $GUI_WS_EX_PARENTDRAG) GUISetBkColor(0x00ff00, $hGUI2) WinSetTrans($hGUI2, "", 127) GUISetState(@SW_SHOW, $hGUI2) ; ---------------- Global $sFile = "cover.jpg" ;FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit Const $fPI = ACos(-1) _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global $aDim = _GDIPlus_ImageGetDimension($hImage) Global Const $hGUI = GUICreate("Image Rotate", $aDim[0], $aDim[1] + 50) Global Const $hDC = _WinAPI_GetDC($hGUI) Global Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aDim[0], $aDim[1]) Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Global Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) Global Const $hPen = _GDIPlus_PenCreate(0xFFFFFFFF) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, 4) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) Global $hButton1 = GUICtrlCreateButton(' < ', 10, $aDim[1] + 10, 40) Global $Slider = GUICtrlCreateSlider(60, $aDim[1] + 10, 360, 25) GUICtrlSetLimit(-1, 360, 0) ; change min/max value Global $hButton2 = GUICtrlCreateButton(' > ', 430, $aDim[1] + 10, 40) Global $hSlider = GUICtrlGetHandle($Slider) Global $Dummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL") ;horz slider GUISetState(@SW_SHOW, $hGUI) _ImageRefresh() ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Dummy _GDIPlus_ImageRotate($hImage, GUICtrlRead($Slider)) _ImageRefresh() Case $hButton1 _FineTuning(1) Case $hButton2 _FineTuning(2) EndSwitch WEnd _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func _FineTuning($iDirection) Local Static $iAngle Local Static $iSliderPos = GUICtrlRead($Slider) If $iSliderPos <> GUICtrlRead($Slider) Then $iAngle = 0 $iSliderPos = GUICtrlRead($Slider) EndIf Switch $iDirection Case 1 $iAngle -= .1 If $iAngle < 0 Then $iAngle = .9 $iSliderPos -= 1 If $iSliderPos < 0 Then $iSliderPos = 359 GUICtrlSetData($Slider, $iSliderPos) EndIf Case 2 $iAngle += .1 If $iAngle > .9 Then $iAngle = 0 $iSliderPos += 1 If $iSliderPos > 359 Then $iSliderPos = 0 GUICtrlSetData($Slider, $iSliderPos) EndIf EndSwitch _GDIPlus_ImageRotate($hImage, $iSliderPos + $iAngle) _ImageRefresh() EndFunc ;==>_FineTuning Func _ImageRefresh() _GDIPlus_GraphicsClear($hCanvas) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) _WinAPI_BitBlt($hDC, 0, 0, $aDim[0], $aDim[1], $hDC_backbuffer, 0, 0, $SRCCOPY) EndFunc ;==>_ImageRefresh Func _GDIPlus_ImageRotate($hImage, $fDegree) ; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fDegree = ' & $fDegree & @TAB & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $aDim[0] / 2, $aDim[1] / 2) _GDIPlus_MatrixRotate($hMatrix, $fDegree) _GDIPlus_MatrixTranslate($hMatrix, -$aDim[0] / 2, -$aDim[1] / 2) _GDIPlus_GraphicsSetTransform($hCanvas, $hMatrix) _GDIPlus_MatrixDispose($hMatrix) EndFunc ;==>_GDIPlus_ImageRotate Func WM_HVSCROLL($hwnd, $iMsg, $wParam, $lParam) #forceref $hwnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_HSCROLL Switch $lParam Case $hSlider GUICtrlSendToDummy($Dummy, GUICtrlRead($Slider)) EndSwitch Case $WM_VSCROLL EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_HVSCROLL
    2 points
  4. Added the ability to load a custom CSS file where you can change the look of help pages as you would with any html file displaying in Internet Explorer. Also, all external links open in your default browser. This area is to share your CSS coloring or report a problem with the file. Examples of how it could look are: Buuf: Dark: Light ( default ) or just forego all themes and use High Contrast in the OS The general idea is that is your PC. Make it look as you wish The file is in the file downloads area. Replace the v3.3.16.1 CHM with the one in the ZIP along with the CSS file of your choosing to the same folder the CHM is at.
    1 point
  5. I need from from time to time to run small processes to perform task that would otherwise clog the main process. Yes, there is a number of other UDF that could have done it very well, but I felt they were an over-kill for what I wanted. Don't throw me stones, I know it's not really multi-threading, but it is as close as I could get with simple AutoIt. If someone wonders why I called it PMT, the P stands for Pretending. And I'm also not pretending it is an elaborate UDF. Just small and simple to use... Version 2024-03-24 * corrected bug when 8 parameters (max) is passed to the function Example : #AutoIt3Wrapper_Res_SaveSource=y #include "PMT-UDF.AU3" #include <Constants.au3> _PMT_Init() Local $hProc1 = _PMT_Start("Test1", Default, "Test 1") _PMT_Start("Test2") _PMT_Start("Test3", 5) Local $sResponse While Sleep(50) $sResponse = _PMT_GetResponse($hProc1) If @error Then Exit MsgBox($MB_OK, "Error", "Process has dropped") If $sResponse <> "" Then MsgBox($MB_OK, "Success", $sResponse & @CRLF) ExitLoop EndIf WEnd Func Test1($sTitle, $sMessage) Local $iResp = MsgBox($MB_OK, $sTitle, $sMessage) Return "Done with value " & $iResp EndFunc Func Test2() MsgBox($MB_OK, "2", "Test 2") EndFunc Func Test3($iTimeout) MsgBox($MB_OK, "3", "Test 3", $iTimeout) EndFunc You can pass up to 8 parameters to _PMT_Start. It is up to you to manage the right number. You cannot pass structures, maps or arrays as parameter (only bool, ptr, hWnd, int, float, string, and the keyword Default). You could use my WCD-IPC if need be to exchange large amount of data. If you want to run it compiled, you need to have add #AutoIt3Wrapper_Res_SaveSource=y at the start of your script. In the case you decide to compile your script, _PMT_Init allows you to identity where AutoIt3 is located (in the situation where AutoIt is not installed in the usual directory) to get the right includes in your "threads". Let me know if you have any question, or suggestion, I will be glad to hear them. Enjoy. PMT-UDF.au3
    1 point
  6. I have also bad tastes at colors, I changed just this striking yellow to #635435 and I am happy with the final result.
    1 point
  7. tr.yellow,tr.yellowbold { background-color:#808000 /* #ffff9C */ } This is eye hurting but the overall colors are nicely picked. It's a shame that it's not the entire chm theme aware. In dark mode it gives you a feeling of two different applications when you see half of the application in light mode. Anyway, awesome work @argumentum.
    1 point
  8. Looks nice. I will not use it but I like to learn how such kind of hacks can be done 😉 I'm just curious why this isn't in Examples section of the forum ...
    1 point
  9. few mods by Gianni slightly understated 😉 Now we have hijacked TheSaint's topic... 👉👈
    1 point
  10. more ideas, more fun... 🙂 added a crop and copy to clipboard function (UDF download required. see link in list) I hope there are no bugs ;Coded by UEZ 2024-03-16 ; [few mods by Gianni :) ] #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Clipboard.au3> #include <ScreenCapture.au3> #include <.\CropTool.au3> ; <-- get this from below link ; https://www.autoitscript.com/forum/topic/203545-%E2%9C%82%EF%B8%8F-quick-crop-tool/ Opt("GUICloseOnESC", 0) ; --- rulers ----- Global $iThickness = 5 Global $hGUI1 = GUICreate("", @DesktopWidth, $iThickness, 0, @DesktopHeight / 2, $WS_POPUP, $WS_EX_TOPMOST) GUICtrlCreateLabel("", 0, 0, @DesktopWidth, $iThickness, -1, $GUI_WS_EX_PARENTDRAG) GUISetBkColor(0x00ff00, $hGUI1) WinSetTrans($hGUI1, "", 127) GUISetState(@SW_HIDE, $hGUI1) Global $hGUI2 = GUICreate("", $iThickness, @DesktopHeight, @DesktopWidth / 2, 0, $WS_POPUP, $WS_EX_TOPMOST) GUICtrlCreateLabel("", 0, 0, $iThickness, @DesktopHeight, -1, $GUI_WS_EX_PARENTDRAG) GUISetBkColor(0x00ff00, $hGUI2) WinSetTrans($hGUI2, "", 127) GUISetState(@SW_HIDE, $hGUI2) ; ---------------- Global $sFile = "cover.jpg" ; FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit Global $aRect, $bResult, $hBmp, $aTemp, $bPreviousStatus, $aBKcolor[2] = [0x008800, 0x00ff00] _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global $aDim = _GDIPlus_ImageGetDimension($hImage) Global Const $hGUI = GUICreate("Image Rotate", $aDim[0], $aDim[1] + 50) Global Const $hDC = _WinAPI_GetDC($hGUI) Global Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aDim[0], $aDim[1]) Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Global Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) Global Const $hPen = _GDIPlus_PenCreate(0xFFFFFFFF) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, 4) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) Global $hButton1 = GUICtrlCreateButton(' < ', 10, $aDim[1] + 10, 40) GUICtrlSetTip(-1, 'fine rotation to the left') Global $Slider = GUICtrlCreateSlider(60, $aDim[1] + 10, 360, 25) GUICtrlSetLimit(-1, 360, 0) ; change min/max value GUICtrlSetTip(-1, 'slide to rotate the image') Global $hButton2 = GUICtrlCreateButton(' > ', 430, $aDim[1] + 10, 40) GUICtrlSetTip(-1, 'fine rotation to the right') Global $hCrop = GUICtrlCreateButton(' # ', 480, $aDim[1] + 10, 40) GUICtrlSetTip(-1, '1) move & resize the tool' & @CR & '2) right-click inside the tool area to copy the image' & @CR & '3) hit ESC to cancel cropping', 'Crop Tool') Global $hButton3 = GUICtrlCreateButton(' + ', 530, $aDim[1] + 10, 40) GUICtrlSetBkColor(-1, $aBKcolor[_SwitcRuler()]) GUICtrlSetTip(-1, 'show/hide ruler') Global $hSlider = GUICtrlGetHandle($Slider) Global $Dummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL") ;horz slider GUISetState(@SW_SHOW, $hGUI) _ImageRefresh() ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Dummy _GDIPlus_ImageRotate($hImage, GUICtrlRead($Slider)) _ImageRefresh() Case $hButton1 _FineTuning(1) Case $hButton2 _FineTuning(2) Case $hCrop $bPreviousStatus = _SwitcRuler(0) $aTemp = WinGetPos($hGUI) $aRect = _Crop($aTemp[0] + ($aTemp[2] / 2) - 50, $aTemp[1] + ($aTemp[3] / 2) - 50) If Not @extended Then ; below snippet by UEZ ; https://www.autoitscript.com/forum/topic/129333-screen-capture-to-clipboard/?do=findComment&comment=898287 $hBmp = _ScreenCapture_Capture('', $aRect[0], $aRect[1], $aRect[0] + $aRect[2] - 1, $aRect[1] + $aRect[3] - 1, False) $bResult = _ClipBoard_Open(0) + _ClipBoard_Empty() + Not _ClipBoard_SetDataEx($hBmp, $CF_BITMAP) _ClipBoard_Close() If $bResult = 2 Then MsgBox($MB_ICONINFORMATION, '', "the area was copied to the clipboard", 2) Else MsgBox($MB_ICONERROR, '', "Something went wrong", 2) EndIf Else EndIf _SwitcRuler($bPreviousStatus) Case $hButton3 _SwitcRuler(Not _SwitcRuler()) GUICtrlSetBkColor($hButton3, $aBKcolor[_SwitcRuler()]) EndSwitch WEnd _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func _FineTuning($iDirection) Local Static $iAngle Local Static $iSliderPos = GUICtrlRead($Slider) If $iSliderPos <> GUICtrlRead($Slider) Then $iAngle = 0 $iSliderPos = GUICtrlRead($Slider) EndIf Switch $iDirection Case 1 $iAngle -= .1 If $iAngle < 0 Then $iAngle = .9 $iSliderPos -= 1 If $iSliderPos < 0 Then $iSliderPos = 359 GUICtrlSetData($Slider, $iSliderPos) EndIf Case 2 $iAngle += .1 If $iAngle > .9 Then $iAngle = 0 $iSliderPos += 1 If $iSliderPos > 359 Then $iSliderPos = 0 GUICtrlSetData($Slider, $iSliderPos) EndIf EndSwitch _GDIPlus_ImageRotate($hImage, $iSliderPos + $iAngle) _ImageRefresh() EndFunc ;==>_FineTuning Func _ImageRefresh() _GDIPlus_GraphicsClear($hCanvas) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) _WinAPI_BitBlt($hDC, 0, 0, $aDim[0], $aDim[1], $hDC_backbuffer, 0, 0, $SRCCOPY) EndFunc ;==>_ImageRefresh Func _SwitcRuler($bOn = 2) Local Static $bStatus = 0 Local $bReturn = $bStatus If $bOn = 1 Then GUISetState(@SW_SHOW, $hGUI1) GUISetState(@SW_SHOW, $hGUI2) $bStatus = 1 ElseIf $bOn = 0 Then GUISetState(@SW_HIDE, $hGUI1) GUISetState(@SW_HIDE, $hGUI2) $bStatus = 0 EndIf ; Else Return $bReturn EndFunc ;==>_SwitcRuler Func _GDIPlus_ImageRotate($hImage, $fDegree) ; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fDegree = ' & $fDegree & @TAB & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $aDim[0] / 2, $aDim[1] / 2) _GDIPlus_MatrixRotate($hMatrix, $fDegree) _GDIPlus_MatrixTranslate($hMatrix, -$aDim[0] / 2, -$aDim[1] / 2) _GDIPlus_GraphicsSetTransform($hCanvas, $hMatrix) _GDIPlus_MatrixDispose($hMatrix) EndFunc ;==>_GDIPlus_ImageRotate Func WM_HVSCROLL($hwnd, $iMsg, $wParam, $lParam) #forceref $hwnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_HSCROLL Switch $lParam Case $hSlider GUICtrlSendToDummy($Dummy, GUICtrlRead($Slider)) EndSwitch Case $WM_VSCROLL EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_HVSCROLL
    1 point
×
×
  • Create New...