Home > Capturing Data > Capturing Data in a Windows Application

Capturing Data in a Windows Application

Using Recording mode or the WinTask x64 Capture Wizard (menu item Start/Capture Wizard), you can easily retrieve data displayed in a window belonging to a Windows application (see Capturing data in a Web page for retrieving data displayed in a browser).

Video: How to capture data displayed in a Windows application

The following steps illustrate how to capture a text typed previously in Notepad.

  1. Start WinTask x64. If the Your First Script Wizard dialog box is displayed, click the Close button. The WinTask x64 Editor window should now be active.

  2. From the WinTask x64 toolbar, click the Rec button  to start recording your actions.

  3. The Start Recording Mode dialog box will appear asking What do you want to start before recording?. Select the An application radio button and click the OK button.

  4. In the following dialog box, Launching a program, type notepad into the Program text field and click the OK button.

  5. When the notepad window is loaded, type some text:
    Here is the line 1
    Here is the line 2
    Here is the line 3.

  6. After you have typed the 3 lines above, click the Capture icon  on the floating WinTask x64 toolbar. The Capture button is the third button from the left on the toolbar with the "T and magic wand" icon.

  7. The first screen of the Capture Wizard subtitled Specify the window where the data to be captured are is displayed. Click the Spy button. The mouse cursor changes to a "Crosshair within a circle". Move the cursor over the area where you have typed text. When you see the selection rectangle around the table, click the left mouse button to capture the data within the notepad window.

  8. Press the Next button.

  9. The screen subtitled Take only some of the captured data is displayed. Use this screen to capture only a part of the captured text.

 

  1. Uncheck The beginning and The end checkboxex. Select line 1 word and copy it, then paste it in the Between field. Select 2 word and copy it, then paste it in the and field. Click Show extracted data button to see the results:

  1. Click the Next button. The screen subtitled Specify where to copy the captured data is displayed. Change the variable name storing the captured data in a simple one, type var$ in Variable name field.

  1. Click Paste into the script button.

  2. Close Notepad without saving.
  3. Stop Recording Mode by clicking the Stop button on the floating WinTask x64 toolbar. The Stop button is the first button on the left side of the toolbar with the "X and rectangle" icon.

  4. The WinTask x64 Editor window is now restored and the script statements generated during Recording Mode are inserted into the current script document window.

  5. To see the results of the capture at replay, add at the end of the script a msgbox statement displaying var$
    msgbox(var$)

  6. Click  icon to execute the script. You are prompted for a name, call the script for example capture. After the script runs to completion, the captured data is displayed, click the OK button of the dialog box.


'The steps above were used to generate the following script statements. Comments have been added to explain each script statement.
'Launch notepad
Shell("notepad",1)
'Type text in notepad window
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
 SendKeys("Here is the line 1<Enter>")
 SendKeys("Here is the line 2<Enter>")
 SendKeys("Here is the line 3")
'Capture the text displayed in the notepad window and extract only a part of it
captured_string$ = Capture$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1,1)
var$ = ExtractBetween$(captured_string$,"line 1",excluded,"2",excluded)
'Close notepad window without saving
CloseWindow("NOTEPAD.EXE|Notepad|Untitled - Notepad",1)
UseWindow("NOTEPAD.EXE|CtrlNotifySink|Notepad|8",1)
 Click(Button,"Do&n't Save")
'Display the result of the capture
msgbox(var$)

See also

Capturing Data in a Web Page
Capturing Data Using OCR
Capturing Data using UI Automation framework