xdp22 Posted December 14, 2010 Share Posted December 14, 2010 (edited) Sorry for bad englisch i will use translator. Hello, i have one problem, i need to make screen capture, but it's not normal screen capture function. In ScreenCapture UDF it's possible to say screen cordinates, but i need to make it automatic, example : Let's say we have a picture of him as a man, but we want to program only took a picture of an item, this program is to shoot the image area in which you hit the square may be defined volume of 300 to 300, that is, for example, you press on your head man, is a program that takes a picture the place where you push the area 300 on 300th Is it possible? for example, using mousegetpos + a few other functions? This is example code but i dont know how it works, i just found that at google. expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <ScreenCapture.au3> Global $hDLL = DllOpen("User32.dll") Global $Drag = False Global $aCoord_Start Global $aCoord_End Global $iLeft, $iTop, $iRight, $iBottom Global $sCapture = False HotKeySet("{Esc}", "_Exit") Global $pStub_MouseProc = DllCallbackRegister ("_Mouse_Handler", "int", "int;ptr;ptr") Global $hHookMouse = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($pStub_MouseProc), _WinAPI_GetModuleHandle(0), 0) While 1 If $sCapture Then $sCapture = False _ScreenCapture_Capture(@ScriptDir & "\Capture.jpg", $iLeft, $iTop, $iRight, $iBottom) EndIf Sleep(100) WEnd Func _Mouse_Handler($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam) Switch $wParam Case $WM_LBUTTONDOWN $aCoord_Start = MouseGetPos() Case $WM_MOUSEMOVE If _IsPressed("01", $hDLL) Then $Drag = True Case $WM_LBUTTONUP $aCoord_End = MouseGetPos() If $Drag = True Then $Drag = False If $aCoord_Start[0] < $aCoord_End[0] Then $iLeft = $aCoord_Start[0] $iRight = $aCoord_End[0] Else $iLeft = $aCoord_End[0] $iRight = $aCoord_Start[0] EndIf If $aCoord_Start[1] < $aCoord_End[1] Then $iTop = $aCoord_Start[1] $iBottom = $aCoord_End[1] Else $iTop = $aCoord_End[1] $iBottom = $aCoord_Start[1] EndIf $sCapture = True Return 0 EndIf EndSwitch Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam) EndFunc Func _Exit() DllCallbackFree($pStub_MouseProc) _WinAPI_UnhookWindowsHookEx($hHookMouse) DllClose($hDLL) Exit EndFunc Edited December 14, 2010 by xdp22 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2010 Moderators Share Posted December 14, 2010 xdp22, No need to use anything as complicated as that! This does what I believe you want: #Include <ScreenCapture.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") ; Create exit mode HotKeySet("{ESC}", "On_Exit") While 1 ; Wait for mouse click If _IsPressed("01", $dll) Then ; Get mouse position $aMPos = MouseGetPos() ; Determine coordinates to make a 300x300 square around the mouse position $iLeft = $aMPos[0] - 150 $iTop = $aMPos[1] - 150 $iRight = $aMPos[0] + 150 $iBottom = $aMPos[1] + 150 ; Capture that area _ScreenCapture_Capture("My_Image.jpg", $iLeft, $iTop, $iRight, $iBottom) ; Wait until the mouse is released - or we take too many pictures!!! Do Sleep(10) Until Not(_IsPressed("01", $dll)) EndIf WEnd Func On_Exit() DllClose($dll) Exit EndFunc If it does not, or you have any questions, please come back. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xdp22 Posted December 14, 2010 Author Share Posted December 14, 2010 (edited) That is perfect, thank you very much! Edited December 14, 2010 by xdp22 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