Capture text from a grid object

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Capture text from a grid object

Post by JRL » Thu Apr 04, 2013 7:35 pm

If I run the following script as a .SCP file.
- Click on the text displayed in the Grid object and the text is captured and displayed in a message box.

If I compile the script and run the executable.
- Click on the text displayed in the Grid object and the text is not captured and does not display in the message box.

Any thoughts?



Code: Select all

  GetTextInit

Dialog>Dialog1
object Dialog1: TForm
  Left = 504
  Top = 266
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 223
  ClientWidth = 484
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSStringGrid1: tMSStringGrid
    Left = 36
    Top = 30
    Width = 320
    Height = 120
    RowCount = 1
    FixedRows = 0
    TabOrder = 8
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSStringGrid1,OnMouseDown,CaptureTheTag
Let>FileProperties="Files","Properties","Date","Time","Size"
SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,FileProperties

Show>dialog1,res1

SRT>CaptureTheTag
  GetCursorPos>CurX,CurY
  GetTextAtPoint>CurX,CurY,GetTextResult,CharPos
  MDL>GetTextResult
END>CaptureTheTag

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Fri Apr 05, 2013 12:00 am

I'm not sure if it applies to v. 14. It's not in my budget to upgrade to 14 since the changes to the upgrade protection have increased drastically and is only for 1 year now.

Taken from the version 13 help file.
Create Exe

If your script contains any of the text capture functions (GetTextAtPos, GetTextInRect, GetWindowsTextEx, GetTextPos, WaitScreenText) you will need to supply the following files with your .exe:

GetWord.dll
GetWordNT.dll
GetWord_x64.dll
GetWordNT_x64.dll
GetWord_x64.exe
License.dat

These files can be found in the Macro Scheduler program folder. Copy the above files to the same location as your .exe.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Apr 05, 2013 3:39 am

Thanks Rain. You are correct, and it still applies to version 14. I thought there was something like this and looked all over for it but didn't look in help for "Create Exe."

I have since found another way using a Grid event handler called "OnSelectCell". When you click a cell you get a group of variables that can be used to determine which cell was selected. With that information you can parse the csv data and acquire the row information... which is what I was after.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 504
  Top = 266
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 223
  ClientWidth = 484
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSStringGrid1: tMSStringGrid
    Left = 28
    Top = 30
    Width = 320
    Height = 120
    RowCount = 1
    FixedRows = 0
    Options = []
    TabOrder = 0
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSStringGrid1,OnSelectCell,CaptureTheTag
Let>FileProperties="Files","Properties","Date","Time","Size",%crlf%"Fi","Prop","Dat","Tim","Siz",
SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,FileProperties
AddDialogHandler>Dialog1,,OnClose,Quit

Show>dialog1,res1

SRT>CaptureTheTag
  GetDialogProperty>Dialog1,MSStringGrid1,SaveToCSV,retRes
  Separate>retRes,crlf,retLine
  Add>CaptureTheTag_aRow,1
  Let>value=retLine_%CaptureTheTag_aRow%
  MDL>value
END>CaptureTheTag

SRT>Quit
  Exit>0
END>Quit

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts