Jump to content

icadea

Active Members
  • Posts

    157
  • Joined

  • Last visited

About icadea

  • Birthday April 25

Profile Information

  • Location
    asia

Recent Profile Visitors

637 profile views

icadea's Achievements

Prodigy

Prodigy (4/7)

2

Reputation

  1. Uez, Thank you so much for the help
  2. Uez, thanks it works. The picture is shown in the gui. Could you help on how can the picture be placed on clipboard? I tried clipsetdata at the save file section and its not successful. Thanks found another link of yours. https://www.autoitscript.com/forum/topic/121902-jpg-to-clipboard/?do=findComment&comment=846103 I have to rename _WinAPI_CopyImage to _WinAPI_CopyImageq for it to grab this one instead of default. The default one hangs for 4seconds before showing the grab screen Not sure how to dispose _GDIPlus_ImageDispose($hImage) as in the original script The script below works. If you have any suggestion on how to make it better do advise in terms of less memory use or streamline. Thanks again ;code by UEZ 2011 #AutoIt3Wrapper_UseX64=y #include <Array.au3> #include <Misc.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <ClipBoard.au3> #include <Constants.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() $hHBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, @DesktopHeight, False) $hTexture = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) $hTextureBrush = _GDIPlus_TextureCreate($hTexture) _WinAPI_DeleteObject($hHBitmap) $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hTexture, 0, 0) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) $hPen = _GDIPlus_PenCreate(0xFFFF0000, 2) Global $dll = DllOpen("user32.dll") GUISetOnEvent(-3, "_Exit") $exitloop = False $min_x = @DesktopWidth $min_y = @DesktopHeight $max_x = 0 $max_y = 0 $mo = MouseGetCursor() Global $aPoints[2^20][2] $p = 1 GUISetCursor(14, 1, $hGUI) While Sleep(100) $mxo = MouseGetPos(0) $myo = MouseGetPos(1) While _IsPressed("01", $dll) * Sleep(10) $mx = MouseGetPos(0) $my = MouseGetPos(1) _GDIPlus_GraphicsDrawLine($hGraphic, $mx, $my, $mxo, $myo, $hPen) $mxo = $mx $myo = $my $aPoints[$p][0] = $mx $aPoints[$p][1] = $my $min_x = Min($min_x, $mx) $min_y = Min($min_y, $my) $max_x = Max($max_x, $mx) $max_y = Max($max_y, $my) $p += 1 $exitloop = True WEnd If $exitloop Then ExitLoop WEnd GUISetCursor($mo, 1, $hGUI) ReDim $aPoints[$p][2] $aPoints[0][0] = $p - 1 _GDIPlus_GraphicsDispose($hGraphic) $new_w = $max_x - $min_x $new_h = $max_y - $min_y $hBitmap_Hidden = _GDIPlus_BitmapCreateFromScan0(@DesktopWidth, @DesktopHeight) $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap_Hidden) _GDIPlus_GraphicsClear($hContext, 0xFFFFFFFF) _GDIPlus_GraphicsFillPolygon($hContext, $aPoints, $hTextureBrush) $hBitmap_Capture = _GDIPlus_BitmapCloneArea($hBitmap_Hidden, $min_x, $min_y, $new_w, $new_h) ;~ _GDIPlus_ImageSaveToFile($hBitmap_Capture, "Testc.jpg") $hBmpq = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Capture) $hBitmapq = _WinAPI_CopyImageq($hBmpq, 0, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG) _ClipBoard_Open(0) _ClipBoard_Empty() _ClipBoard_SetDataEx($hBitmapq, $CF_BITMAP) _ClipBoard_Close() ;=============================================================================== ; ; Function Name: _WinAPI_CopyImage ; Description:: Copies an image, also makes GDIPlus-HBITMAP to GDI32-BITMAP ; Parameter(s): $hImg -> HBITMAP Object, GDI or GDIPlus ; Requirement(s): WinAPI.au3 ; Return Value(s): Succes: Handle to new Bitmap, Error: 0 ; Author(s): Prog@ndy ; http://www.autoitscript.com/forum/topic/70237-images-and-the-clipboard/page__p__514857 ;=============================================================================== Func _WinAPI_CopyImageq($hImg, $uType = 0 ,$x = 0, $y = 0, $flags = 0) Local $aResult $aResult = DllCall("User32.dll", "hwnd", "CopyImage", "hwnd", $hImg, "UINT", $uType, "int", $x, "int", $y,"UINT", $flags) ;~ _WinAPI_Check("_WinAPI_CopyImage", ($aResult[0] = 0), 0, True) Return $aResult[0] EndFunc ;==>_WinAPI_CopyIcon GUISetOnEvent(-3, "") GUIDelete($hGUI) $hGUI = GUICreate("Freehand Screen Capture by UEZ 2011", $new_w, $new_h) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap_Capture, 0, 0) GUISetOnEvent(-3, "_Exit") _GDIPlus_BitmapDispose($hBitmap_Hidden) _GDIPlus_BitmapDispose($hBitmap_Capture) _GDIPlus_GraphicsDispose($hContext) While Sleep(100) WEnd Func Max($a, $b) If $a > $b Then Return $a Return $b EndFunc Func Min($a, $b) If $a < $b Then Return $a Return $b EndFunc Func _Exit() DllClose($dll) _GDIPlus_BrushDispose($hTextureBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_BitmapDispose($hTexture) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) $aPoints = 0 Exit EndFunc
  3. Uez, Does the em occur everytime or on special moves? Same issue also with Windows Screenshooter?  It occurs everytime on the separate code included for freehand select only. No issue with Windows Screenshooter
  4. UEZ, thank you for this GEM, somehow symantec is targetting it as a virus. I can run without compiling which works great. No errors at all. I saw the other thread here as well https://www.autoitscript.com/forum/topic/132095-how-to-capture-irregular-picture/?do=findComment&comment=920225 Below is the error after lmb release. !>21:18:25 AutoIt3.exe ended.rc:-1073741819. If possible could you help on where i could insert the clipboard function so it captures the shape to clipboard in PNG? and use this as a function I tried comparing to autoitshooter and it was beyond my compression. sorry !>21:18:25 AutoIt3.exe ended.rc:-1073741819. Using win7, 64bit. latest replaced $ghGDIPDll as $__g_hGDIPDll as searched in the forum ;code by UEZ 2011 #include <Array.au3> #include <Misc.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() $hHBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, @DesktopHeight, False) $hTexture = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) $hTextureBrush = DllCall($__g_hGDIPDll, "uint", "GdipCreateTexture", "hwnd", $hTexture, "int", 0, "int*", 0) $hTextureBrush = $hTextureBrush [3] _WinAPI_DeleteObject($hHBitmap) $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hTexture, 0, 0) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) $hPen = _GDIPlus_PenCreate(0xFFFF0000, 2) Global $dll = DllOpen("user32.dll") GUISetOnEvent(-3, "_Exit") $exitloop = False $min_x = @DesktopWidth $min_y = @DesktopHeight $max_x = 0 $max_y = 0 $mo = MouseGetCursor() Global $aPoints[2^20][2] $p = 1 GUISetCursor(14, 1, $hGUI) While Sleep(100) $mxo = MouseGetPos(0) $myo = MouseGetPos(1) While _IsPressed("01", $dll) * Sleep(10) $mx = MouseGetPos(0) $my = MouseGetPos(1) _GDIPlus_GraphicsDrawLine($hGraphic, $mx, $my, $mxo, $myo, $hPen) $mxo = $mx $myo = $my $aPoints[$p][0] = $mx $aPoints[$p][1] = $my $min_x = Min($min_x, $mx) $min_y = Min($min_y, $my) $max_x = Max($max_x, $mx) $max_y = Max($max_y, $my) $p += 1 $exitloop = True WEnd If $exitloop Then ExitLoop WEnd GUISetCursor($mo, 1, $hGUI) ReDim $aPoints[$p][2] $aPoints[0][0] = $p - 1 _GDIPlus_GraphicsDispose($hGraphic) $new_w = $max_x - $min_x $new_h = $max_y - $min_y $hBitmap_Hidden = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", @DesktopWidth, "int", @DesktopHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) $hBitmap_Hidden = $hBitmap_Hidden[6] $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap_Hidden) _GDIPlus_GraphicsClear($hContext, 0xFFFFFFFF) _GDIPlus_GraphicsFillPolygon($hContext, $aPoints, $hTextureBrush) $hBitmap_Capture = _GDIPlus_BitmapCloneArea($hBitmap_Hidden, $min_x, $min_y, $new_w, $new_h) ;~ _GDIPlus_ImageSaveToFile($hBitmap_Capture, "Testc.jpg") GUISetOnEvent(-3, "") GUIDelete($hGUI) $hGUI = GUICreate("Freehand Screen Capture by UEZ 2011", $new_w, $new_h) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap_Capture, 0, 0) GUISetOnEvent(-3, "_Exit") _GDIPlus_BitmapDispose($hBitmap_Hidden) _GDIPlus_BitmapDispose($hBitmap_Capture) _GDIPlus_GraphicsDispose($hContext) While Sleep(5000) WEnd Func Max($a, $b) If $a > $b Then Return $a Return $b EndFunc Func Min($a, $b) If $a < $b Then Return $a Return $b EndFunc Func _Exit() DllClose($dll) _GDIPlus_BrushDispose($hTextureBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_BitmapDispose($hTexture) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) $aPoints = 0 Exit EndFunc
  5. thank you
  6. Sorry Seem to type MS instead of Mr. Thank you for the full example
  7. Valuater, your guide and MsCreator examples have point me to the solution. Thank you.
  8. Hi all, I would like help on how to accomplish this. The data file in text that I am having Data -56 -40 -40 -32 -3 -32 I would like to AUTO count of occurance or repetition of the number within the given data set as shown below. Number of Occurance -56,1 -40,2 -32,2 -3,1 Would like to know how would I accomplish this? I have searched the forum but found mostly that you have to defined the item that need to be searched. Thanks
  9. Thanks. works a little but you have given me an idea. I'll insert the CR at the time it produces the log so i can use this script. thanks again.
  10. Authenticity. Thank you but after running my log files and example given here i am still getting the same result as shown below This is the modified script Local $esSrcFile2, $esSrcFile = @TempDir & "\all.txt" $esResultFile = @DesktopDir & "\Sum23.txt" FileDelete($esResultFile) $esFileData = FileRead($esSrcFile) Dim $sPattern = '(?m)^((\w+-?)(?:(?:\d+)?\r?\n)(?:\2(?:\d+)?\r?\n)*)' $esFileData1 = StringRegExpReplace($esFileData, $sPattern, '\1' & @CRLF) $esFileData1 = StringRegExpReplace($esFileData, '(?=\n)(?<!\r)', @CR) ;ConsoleWrite($sStr & @LF) FileWrite($esResultFile, $esFileData1) FileDelete(@TempDir & "\all.txt") Could someone help.. I am using Autoit 3.2.10 thanks.
  11. Hi all, I would need help to insert @CRLF in between a cluster of data form a log files using regex. The log files are 60MB to 80MB Data_before After using the script below by randallc I would like the final data to be The current code I am using from the forum is shown below Local $esSrcFile2, $esSrcFile = @TempDir & "\all.txt" $esResultFile = @DesktopDir & "\Sum23.txt" FileDelete($esResultFile) $esFileData = FileRead($esSrcFile) $esFileData1 = StringRegExpReplace($esFileData, "(?m)^(.*+)\r?\n(?=(?:.*+\r?\n)*?\1$)", "") FileWrite($esResultFile, $esFileData1) FileDelete(@TempDir & "\all.txt") I did manage to find that /r/n are equivalent for CRLF but am having problem not knowing where to insert them. Please help. thanks
  12. Thanks val. sure is a great script from the former findstr i have been using. Thanks
  13. Could someone show some guidance. I have searched the forum in terms of this but have not yield any except SmokeN and weaponx and randallc search. Would only need examples or guidance on how to copy files by dates. I can do that by using xcopy in DOS but not over network. Would like the entire thing to be done in AUtoit. Thanks
×
×
  • Create New...