Dialog will not respond

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
aboredprogrammer
Junior Coder
Posts: 40
Joined: Wed Jan 27, 2010 6:31 am

Dialog will not respond

Post by aboredprogrammer » Thu Feb 11, 2010 6:44 am

Hello,

Recently somehow I lost the script I was in the process of making. I am currently trying to re-create it, however I'm running into what I'm sure is a very simple fix I'm looking past.

When I run my program, I have it set so the dialog remains open. So if the user clicks "Start" the dialog is still there allowing them to press "Pause" or "About". The problem I'm running into is that when I click "Start" it disables all other functions of the dialog! It will not allow me to click any other buttons on the dialog.

Here is the part causing the troubles:

Code: Select all

Label>Loop
    GetDialogAction>dialog1,r
  If>r=2,exit
  If>r=10,start
  If>r=20,pause
  If>r=30,about
Goto>Loop

Label>start
    GetDialogAction>dialog1,r
GetCursorPos>CurX,CurY
  GetScreenRes>sX,xY
  ScreenCapture>0,0,sX,sY,d:\screen.bmp
  FindImagePos>C:\\Program Files\aboredprogrammer\SlotBot 1.3\bma-ab.bmp,SCREEN,20,1,XPosa,YPosa,imgsa
  FindImagePos>C:\\Program Files\aboredprogrammer\SlotBot 1.3\bmb-ab.bmp,SCREEN,20,1,XPosb,YPosb,imgsb
GetCursorPos>CurX,CurY
  If>imgsa>0
Wai>0.2
Mou>XPosa_0,YPosa_0
  Lcl
  If>imgsb>0
  Endif
  //button already pushed
  //user free to operate mouse
Mou>CurX,CurY
  Endif
      ResetDialogAction>dialog1
Goto>start
Thanks for reading
aboredprogrammer

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

Post by JRL » Thu Feb 11, 2010 1:58 pm

Your "Loop" loop acquires a button value ("r") and acts on that value (If>r=Something... do whatever ). After you jump out of your "Loop" loop, there is no way out of the "Start" loop. In the "Start" loop you acquire button values using GetDialogAction>, but you do nothing to act on those values. Therefore you are stuck in an endless "Start" loop and clicking buttons does nothing.

User avatar
aboredprogrammer
Junior Coder
Posts: 40
Joined: Wed Jan 27, 2010 6:31 am

Post by aboredprogrammer » Thu Feb 11, 2010 4:24 pm

Thanks for the reply.

So, is the GDA>dialog1,r correct in the "Loop"?
What should I do in the "Start" label to allow the dialog to act on buttons pressed? I have tried putting the IF's in the "Start" label, but that didn't work.

Thanks
aboredprogrammer

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

Post by JRL » Thu Feb 11, 2010 5:03 pm

So, is the GDA>dialog1,r correct in the "Loop"?
Looks good to me. As long as there are no invisible characters in the actual script, the "Loop" loop all looks workable. Of course you need labels for the if statements to go to. The only one you've included is "start". I'm assuming the other labels all exist.

I have tried putting the IF's in the "Start" label, but that didn't work.
That is what you should do... put the IFs in the "start" loop.

There is a ResetDialogAction line in the start loop. Its sole function in the scriptet you've posted is to set the value of variable "r" back to zero. So you must be sure that the reset does not occur before you check the value of "r" with the IFs. As a generality I try to avoid putting a GetDialogAction and a ResetDialogAction in the same loop. There is usually a way to isolate the reset. For example put it in the label blocks.

Another thing I try to avoid is using single characters as variable names. As examples, I suggest you use "res1" for the result variable for "dialog1" and "res_md" for a dialog named "MyDialog"... etc.

User avatar
aboredprogrammer
Junior Coder
Posts: 40
Joined: Wed Jan 27, 2010 6:31 am

Post by aboredprogrammer » Thu Feb 11, 2010 8:29 pm

Thanks JRL.

I got it working. In the start label, at the end I put

GDA>dialog1,res1
If>res1=20,pause
If>res1=30,about

Works good now.

Thanks
aboredprogrammer

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