kuhasu Posted April 22, 2008 Share Posted April 22, 2008 (edited) Hey guys! I need to capture the following 4 digits from the panel of a process,not the full screen,and the GUI doesn't appear at the same place on my desktop. Any code for autoit or VBS? I know v3.2.10.0 supply some screencapture fuctions, but no one can work at this condition. Thank you for your help. BTW,is there any code can let the pic capture work in the field of the dialog? Edited April 25, 2008 by kuhasu Link to comment Share on other sites More sharing options...
aGorilla Posted April 23, 2008 Share Posted April 23, 2008 Welcome to AutoIt! In your AutoIt install directory, check out: AutoIt3\Examples\GUI\Advanced\Slicer.au3 That might give you a start. Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
kuhasu Posted April 23, 2008 Author Share Posted April 23, 2008 Welcome to AutoIt!In your AutoIt install directory, check out:AutoIt3\Examples\GUI\Advanced\Slicer.au3That might give you a start.I've reviewed the script.I don't need the caputure based on the full screen.just the region I need on a dialog/window.Show me the code pls.Thank you! Link to comment Share on other sites More sharing options...
Generator Posted April 23, 2008 Share Posted April 23, 2008 I've reviewed the script.I don't need the caputure based on the full screen.just the region I need on a dialog/window.Show me the code pls.Thank you!You are getting nowhere. Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 23, 2008 Share Posted April 23, 2008 (edited) Hi, try using the relative Coord. to your window. Mega Edited April 23, 2008 by Xenobiologist Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
kuhasu Posted April 23, 2008 Author Share Posted April 23, 2008 Hi,try using the relative Coord. to your window.MegaThank you man.I just reviewed helper for finding relative Coord. to active windowbut Am afraid I can not find any for pic capture....sorry for bothering u guys.Am new here.Thank you. Link to comment Share on other sites More sharing options...
kuhasu Posted April 23, 2008 Author Share Posted April 23, 2008 I know there is a C# can do this,but how can I get the same thing in autoit or VBS? Thank you. expandcollapse popupusing System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Imaging; public class Form1 : Form { private Button button1; private System.ComponentModel.Container components = null; public Form1 ( ) { //初始化窗体中的各个组件 InitializeComponent ( ); } // 清除程序中使用过的资源 protected override void Dispose ( bool disposing ) { if ( disposing ) { if ( components != null ) { components.Dispose ( ); } } base.Dispose ( disposing ); } private void InitializeComponent ( ) { button1 = new Button ( ); SuspendLayout ( ); button1.Location = new System.Drawing.Point ( 64 , 40 ); button1.Name = "button1"; button1.Size = new System.Drawing.Size ( 80 , 32 ); button1.TabIndex = 0; button1.Text = "捕获"; button1.Click += new System.EventHandler ( button1_Click ); AutoScaleBaseSize = new System.Drawing.Size ( 6 , 14 ); ClientSize = new System.Drawing.Size ( 216 , 125 ); Controls.Add ( button1 ); MaximizeBox = false; MinimizeBox = false; Name = "Form1"; Text = "C#捕获当前屏幕!"; ResumeLayout ( false ); } //声明一个API函数 [ System.Runtime.InteropServices.DllImportAttribute ( "gdi32.dll" ) ] private static extern bool BitBlt ( IntPtr hdcDest , // 目标 DC的句柄 int nXDest , int nYDest , int nWidth , int nHeight , IntPtr hdcSrc , // 源DC的句柄 int nXSrc , int nYSrc , System.Int32 dwRop // 光栅的处理数值 ); static void Main ( ) { Application.Run ( new Form1 ( ) ); } private void button1_Click ( object sender , System.EventArgs e ) { //获得当前屏幕的大小 Rectangle rect = new Rectangle ( ); rect = Screen.GetWorkingArea ( this ); //创建一个以当前屏幕为模板的图象 Graphics g1 = this.CreateGraphics ( ); //创建以屏幕大小为标准的位图 Image MyImage = new Bitmap ( rect.Width , rect.Height , g1 ); Graphics g2 = Graphics.FromImage ( MyImage ); //得到屏幕的DC IntPtr dc1 = g1.GetHdc ( ); //得到Bitmap的DC IntPtr dc2 = g2.GetHdc ( ); //调用此API函数,实现屏幕捕获 BitBlt ( dc2 , 0 , 0 , rect.Width , rect.Height , dc1 , 0 , 0 , 13369376 ); //释放掉屏幕的DC g1.ReleaseHdc ( dc1 ); //释放掉Bitmap的DC g2.ReleaseHdc ( dc2 ); //以JPG文件格式来保存 MyImage.Save ( @"c:\Capture.jpg" , ImageFormat.Jpeg ); MessageBox.Show ( "当前屏幕已经保存为C盘的capture.jpg文件!" ); } } Link to comment Share on other sites More sharing options...
kuhasu Posted April 23, 2008 Author Share Posted April 23, 2008 Is there any help for ScreenCapture_CaptureWnd I tried ,but failed to run. Thank you. Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 23, 2008 Share Posted April 23, 2008 Hi, I tried this: #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ; ScreenCaputre with realtive coords HotKeySet('{F2}', '_capture') Global $path = @ScriptDir & '\ScreenCaputreRelative.jpg' GUICreate("GUI", 419, 155, 193, 125) GUICtrlCreatePic($path, 0, 0, 436, 172, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _capture() _ScreenCapture_RelativeWindow(@DesktopDir & '\realtive.jpg', 310, 123, 371, 145) ConsoleWrite("! DONE" & @CRLF) EndFunc ;==>_capture Func _ScreenCapture_RelativeWindow($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True) Local $iopt_WTMM = Opt("WinTitleMatchMode", 4) Local $iopt_WSC = Opt("WinSearchChildren", 1) _ScreenCapture_CaptureWnd($sFileName, WinGetHandle(WinGetTitle('active')), $iLeft, $iTop, $iRight, $iBottom, $fCursor) Opt("WinTitleMatchMode", $iopt_WTMM) Opt("WinSearchChildren", $iopt_WSC) EndFunc ;==>_ScreenCapture_RelativeWindow Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
kuhasu Posted April 23, 2008 Author Share Posted April 23, 2008 (edited) Thank you man! I just got it! My code here; #include <ScreenCapture.au3> _Main() Opt('MustDeclareVars', 1) Func _Main() Local $hWnd WinActivate("渤海证券网上交易V6.05") WinWaitActive("渤海证券网上交易V6.05") $hWnd = WinGetHandle("渤海证券网上交易V6.05") GUISetState() _ScreenCapture_CaptureWnd ("x:\GDIPlus_Image.jpg",$hWnd,313,124,371,141) EndFunc ;==>_Main It costs 0.773 ,and if I del the WinWaitActive("渤海证券网上交易V6.05"),the time to 0.443 Is there any script can be deleted? Thx again. Edited April 23, 2008 by kuhasu Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 23, 2008 Share Posted April 23, 2008 Welcome! Why GUISETSTATE? Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
kuhasu Posted April 23, 2008 Author Share Posted April 23, 2008 Welcome!Why GUISETSTATE?Megahehe,I don't know,just some sample contain....Could u optimize the script?Thank you.I wanna it can be ran as fast as it can:) Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 23, 2008 Share Posted April 23, 2008 Hi, this should be enough #include <ScreenCapture.au3> Opt('MustDeclareVars', 1) _Main('GUI') Func _Main(Const $title) WinActivate($title) _ScreenCapture_CaptureWnd(@DesktopDir & "\GDIPlus_Image.jpg", WinGetHandle(WinGetTitle($title)), 313, 124, 371, 141) EndFunc ;==>_Main Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
kuhasu Posted April 23, 2008 Author Share Posted April 23, 2008 Thank you!here's my code modified,any suggestions? #include <ScreenCapture.au3> #include <Date.au3> Opt('MustDeclareVars', 1) _Main('渤海证券网上交易V6.05') Func _Main(Const $title) Local $tTime, $aTime ,$bTime, $time $tTime = _Date_Time_GetSystemTime() $aTime = _Date_Time_SystemTimeToArray($tTime) $bTime = $aTime[6] $time=@Hour & " h " & @MIN & " m " & @SEC & " Sec " & $bTime WinActivate($title) _ScreenCapture_CaptureWnd("x:\orc\" & $time & ".jpg", WinGetHandle(WinGetTitle($title)), 313, 124, 371, 141) EndFunc ;==>_Main Link to comment Share on other sites More sharing options...
junkew Posted April 23, 2008 Share Posted April 23, 2008 With the code in http://www.autoitscript.com/forum/index.ph...mp;#entry493137you should be able to get the logic.Your number seems to be fixed in 4 different slices so if you make 10 bitmaps for each digit and then search in each slice for all 10 different bitmaps you should be able to read the number as shown in the picture FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
kuhasu Posted April 23, 2008 Author Share Posted April 23, 2008 With the code in http://www.autoitscript.com/forum/index.ph...mp;#entry493137you should be able to get the logic.Your number seems to be fixed in 4 different slices so if you make 10 bitmaps for each digit and then search in each slice for all 10 different bitmaps you should be able to read the number as shown in the pictureThank you man,very good idea! 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