Trouble with first dialog

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ari
Junior Coder
Posts: 23
Joined: Tue Jul 15, 2014 4:12 pm

Trouble with first dialog

Post by ari » Thu Dec 22, 2016 3:49 pm

I am trying to create a dialog button bar, where each button press sends some keystrokes to another program. I would like the bar to stay active until I push an exit button. This is what I have so far and I am just asking if the overall design is correct before I invest a lot more time.

Thanks for any tips!

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 699
  Top = 229
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'History Filler'
  ClientHeight = 600
  ClientWidth = 200
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -20
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 168
  TextHeight = 25
  object MSButton1: tMSButton
    Left = 8
    Top = 6
    Width = 150
    Height = 50
    Caption = 'NKDA'
    ModalResult = 1
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 8
    Top = 62
    Width = 150
    Height = 50
    Caption = 'PCN'
    ModalResult = 2
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton3: tMSButton
    Left = 8
    Top = 118
    Width = 150
    Height = 50
    Caption = 'Sulfa'
    ModalResult = 3
    TabOrder = 10
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton4: tMSButton
    Left = 8
    Top = 174
    Width = 150
    Height = 50
    Caption = 'Morphine Deriv'
    ModalResult = 4
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton5: tMSButton
    Left = 8
    Top = 230
    Width = 150
    Height = 50
    Caption = 'RCM'
    ModalResult = 5
    TabOrder = 12
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton6: tMSButton
    Left = 8
    Top = 286
    Width = 150
    Height = 50
    Caption = 'Latex'
    ModalResult = 6
    TabOrder = 13
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton7: tMSButton
    Left = 8
    Top = 342
    Width = 150
    Height = 50
    Caption = 'Other Drug'
    ModalResult = 8
    TabOrder = 14
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton8: tMSButton
    Left = 8
    Top = 414
    Width = 150
    Height = 50
    Caption = 'MSButton1'
    TabOrder = 15
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton9: tMSButton
    Left = 8
    Top = 470
    Width = 150
    Height = 50
    Caption = 'MSButton1'
    TabOrder = 16
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton10: tMSButton
    Left = 8
    Top = 526
    Width = 150
    Height = 50
    Caption = 'MSButton1'
    TabOrder = 17
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

Show>Dialog1,ModalResult

If>ModalResult=1

//NKDA
SetFocus>Citrix D*
MouseMoveRel>285,210
LClick
Send>all

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:Active Window,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  LClick
Endif

Show>Dialog1,ModalResult
Endif

If>ModalResult=2

SetFocus>Citrix D*
MouseMoveRel>285,210
LClick
Send>all
Press Tab
Wait>0.2
Press Alt
Send>e
Wait>0.2
Release Alt
Send>d
Press Tab
Send>penicillins
Press enter*3

Show>Dialog1,ModalResult
Endif


User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Trouble with first dialog

Post by Marcus Tettmar » Fri Dec 23, 2016 9:35 am

You are using a modal dialog. You are waiting for the dialog to close and then performing some action. Instead you need a non-modal dialog and event handlers:

http://help.mjtnet.com/article/41-an-in ... t-handlers
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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