Dialogues, input fields, and how to assign an action to a button?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
toopnad
Junior Coder
Posts: 34
Joined: Mon Apr 12, 2021 10:10 am
Location: Russian Totalitarian Republic, Perm city

Dialogues, input fields, and how to assign an action to a button?

Post by toopnad » Wed Dec 08, 2021 8:16 am

Good day to you, friends, help the newbie!
Faced a problem, how to assign the button to close the dialog, and assign the values of the fields for entering text to variables? What properties are responsible for this?
Sorry for the question, delete the topic, found an example.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Dialogues, input fields, and how to assign an action to a button?

Post by Dorian (MJT support) » Wed Dec 08, 2021 11:07 am

These should answer your questions and give you a good grounding in dialogs :

https://help.mjtnet.com/article/40-an-i ... dal-dialog

https://help.mjtnet.com/article/41-an-i ... t-handlers
Yes, we have a Custom Scripting Service. Message me or go here

toopnad
Junior Coder
Posts: 34
Joined: Mon Apr 12, 2021 10:10 am
Location: Russian Totalitarian Republic, Perm city

Re: Dialogues, input fields, and how to assign an action to a button?

Post by toopnad » Wed Dec 08, 2021 12:37 pm

Thanks to Dorian, I was able to figure out how to request variables from the user and how to encrypt passwords, everything is very clear in ready-made macros examples. But a more complicated question arose. Is it possible to limit the user's time to answer in the dialog, and after 10 seconds automatically select the answer "no" or "cancel" so that the macro runs with the old variables unchanged and without human intervention?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Dialogues, input fields, and how to assign an action to a button?

Post by Dorian (MJT support) » Wed Dec 08, 2021 1:36 pm

There may be people here who can provide better ways of doing this. I know there are some who are very experienced with Dialogs. However, the example below works as a proof of concept or food for thought.

It sets the default value of object "Edit1" to "---". It then checks to see if Edit1 is still ---. If it is, it will wait 1 second. It'll do that 10 times and then skip. If it isn't, it'll continue. Then after the 10 second loop it'll check to see if it's still ---, and if it is it will change it to "No".

Running it step by step will give you a good idea of what it does.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 100
  Top = 200
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 333
  ClientWidth = 540
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Edit1: TEdit
    Left = 18
    Top = 23
    Width = 247
    Height = 40
    TabOrder = 0
    Text = '---'
  end
end
EndDialog>Dialog1

Show>Dialog1

Let>WaitLoop=0
Repeat>WaitLoop
  Let>WaitLoop=WaitLoop+1
  GetDialogProperty>Dialog1,Edit1,Text,Edit1Val
  If>Edit1Val<>---,skip
  Wait>1
Until>WaitLoop,10
label>skip


GetDialogProperty>Dialog1,Edit1,Text,Edit1Val
If>Edit1Val=---
SetDialogProperty>Dialog1,Edit1,Text,No
Endif


label>KeepDialogVisible
wait>1
Goto>KeepDialogVisible
Yes, we have a Custom Scripting Service. Message me or go here

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