One time dialog and repeated hotkeys

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
stev3n
Junior Coder
Posts: 22
Joined: Thu Nov 01, 2007 1:13 am

One time dialog and repeated hotkeys

Post by stev3n » Wed Dec 12, 2007 2:24 pm

My goal is to create a dialog box, which asks for two inputs

Input one has a combo box which you can only select one option.
This option, I want it to do the macro normally (no matter what option you pick), but depending on the option, midway through it, does a certain action.


The action would be repeated by a hotkey everytime, so I'm not sure if I need to create one script for the dialog, and one for the actual process?

The other input, would have check boxes, which again with a different hotkey, would do certain functions.

So this is kind of the outline

Input 1
1,2,3,4,5 (only one)

Input 2
1,2,3 (can be any combo)

Hotkey 1:
..Does first part of macro...
..Clicks certain places based on Input 1...
..Finishes Macro..

Hotkey 2:
..Does Macro..
..Clicks certain places if input 2 has checked items...
..Finished macro...


So my first question is, how am I going to set this up?

Do I have three scripts, or what do I do?

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

Post by Marcus Tettmar » Wed Dec 12, 2007 3:34 pm

I guess you could either have two macros, assigned to two different hotkeys, or one macro using OnEvent>KEY_DOWN to handle both hotkeys.

If you want to present several options and allow the user to select multiple choices, use a Radio Button Group.

Use a combo box if only one option should be selected.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

stev3n
Junior Coder
Posts: 22
Joined: Thu Nov 01, 2007 1:13 am

Post by stev3n » Wed Dec 12, 2007 5:31 pm

mtettmar wrote:If you want to present several options and allow the user to select multiple choices, use a Radio Button Group.
Don't radios only allow one choice?

I currently have a radio selection for the options that I want to use for once choice, and I have 3 check boxes for the other.

Wouldn't that be best?

Also, how do I apply each selection? I don't understand how I use the radios or checkboxes as variables later on in my script.

So how do I say if option two in in list 1 is selected, do this?

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

Post by Marcus Tettmar » Wed Dec 12, 2007 5:47 pm

Sorry, yes, I meant checkboxes. Radio boxes, or a combo list for one choice, check boxes for multiple choices.

In regards to how to use them, perhaps this simple example will help:

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=445
   Height=171
   Top=502
   Left=384
   RadioGroup=msRadioGroup1,msRadioGroup1,16,16,185,105,One%CRLF%Two%CRLF%Three,-1
   CheckBox=msCheckBox1,msCheckBox1,248,32,97,False
   CheckBox=msCheckBox2,msCheckBox2,248,56,97,False
EndDialog>Dialog1

Show>Dialog1,r

MessageModal>Radio Button Selected: %Dialog1.msRadioGroup1%

MessageModal>CeckBox1 Checked: %Dialog1.msCheckBox1%
MessageModal>CeckBox2 Checked: %Dialog1.msCheckBox2%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

stev3n
Junior Coder
Posts: 22
Joined: Thu Nov 01, 2007 1:13 am

Post by stev3n » Thu Dec 13, 2007 1:10 am

Just one more question.. maybe

What would the "if" be then?

So how do I decipher between which radio was pressed, and decide to do something if it was? And the same if a checkbox was checked?

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

Post by Marcus Tettmar » Thu Dec 13, 2007 8:23 am

My example above displays the values you have to check for. So, something like:

Code: Select all

If>Dialog1.msRadioGroup1=1
   MessageModal>First option selected
Endif

If>Dialog1.msRadioGroup1=2
   MessageModal>Second option selected
Endif

If>Dialog1.msRadioGroup1=3
   MessageModal>Third option selected
Endif

If>Dialog1.msCheckBox1=True
   MessageModal>CheckBox1 Selected
Else
   MessageModal>CheckBox1 Not Selected
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

stev3n
Junior Coder
Posts: 22
Joined: Thu Nov 01, 2007 1:13 am

Post by stev3n » Thu Dec 13, 2007 1:05 pm

That works fine for the check boxes, but the radio buttons still aren't responding? I don't get any messagemodal for them with that
Last edited by stev3n on Thu Dec 13, 2007 1:16 pm, edited 1 time in total.

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

Post by Marcus Tettmar » Thu Dec 13, 2007 1:10 pm

Perhaps you'd better show us your code so that we can see what might be wrong.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

stev3n
Junior Coder
Posts: 22
Joined: Thu Nov 01, 2007 1:13 am

Post by stev3n » Thu Dec 13, 2007 1:18 pm

Code:

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=313
   Height=247
   Top=557
   Left=322
   RadioGroup=msRadioGroup1,msRadioGroup1,8,8,121,145,No Mage%CRLF%Fire Blast%CRLF%Fire Wave%CRLF%Guthix%CRLF%Saradomin%CRLF%Zamorak,-1
   CheckBox=msCheckBox1,Steel Skin,136,48,97,False
   CheckBox=msCheckBox2,Ultimate Strength,136,72,105,False
   CheckBox=msCheckBox3,Incredible Reflexes,136,96,113,False
   Button=OK,64,160,75,25,1
   Button=Cancel,176,160,75,25,2
EndDialog>Dialog1

Show>Dialog1,r

If>Dialog1.msRadioGroup1=1
   MessageModal>First option selected
Endif

If>Dialog1.msRadioGroup1=2
   MessageModal>Second option selected
Endif

If>Dialog1.msRadioGroup1=3
   MessageModal>Third option selected
Endif

If>Dialog1.msCheckBox1=True
   MessageModal>CheckBox1 Selected
Else
   MessageModal>CheckBox1 Not Selected
Endif

If>Dialog1.msCheckBox2=True
   MessageModal>CheckBox2 Selected
Else
   MessageModal>CheckBox2 Not Selected
Endif

If>Dialog1.msCheckBox3=True
   MessageModal>CheckBox3 Selected
Else
   MessageModal>CheckBox3 Not Selected
Endif
This is all there is right now as I'm trying to build to my previous goal before, but I just can't get the results out of the dialog

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

Post by Marcus Tettmar » Thu Dec 13, 2007 1:30 pm

Ah - sorry, it was my mistake. Radio boxes return:

DialogName.RadioGroupName: Text of item selected
DialogName.RadioGroupName.ItemIndex: Numeric index of item selected (base 0).

Sorry, my bad. My last example missed out ItemIndex.

So your script should be:

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=313
   Height=247
   Top=557
   Left=322
   RadioGroup=msRadioGroup1,msRadioGroup1,8,8,121,145,No Mage%CRLF%Fire Blast%CRLF%Fire Wave%CRLF%Guthix%CRLF%Saradomin%CRLF%Zamorak,-1
   CheckBox=msCheckBox1,Steel Skin,136,48,97,False
   CheckBox=msCheckBox2,Ultimate Strength,136,72,105,False
   CheckBox=msCheckBox3,Incredible Reflexes,136,96,113,False
   Button=OK,64,160,75,25,1
   Button=Cancel,176,160,75,25,2
EndDialog>Dialog1

Show>Dialog1,r

If>Dialog1.msRadioGroup1.itemindex=0
   MessageModal>First option selected
Endif

If>Dialog1.msRadioGroup1.itemindex=1
   MessageModal>Second option selected
Endif

If>Dialog1.msRadioGroup1.itemindex=2
   MessageModal>Third option selected
Endif

If>Dialog1.msCheckBox1=True
   MessageModal>CheckBox1 Selected
Else
   MessageModal>CheckBox1 Not Selected
Endif

If>Dialog1.msCheckBox2=True
   MessageModal>CheckBox2 Selected
Else
   MessageModal>CheckBox2 Not Selected
Endif

If>Dialog1.msCheckBox3=True
   MessageModal>CheckBox3 Selected
Else
   MessageModal>CheckBox3 Not Selected
Endif
If you step through your script with the debugger you will see the variables the dialog creates.

Re why didn't your code post properly: Seems for CODE/TEXTAREA to work there needs to be text prior to the firs textarea tag. Will try to get that fixed. In the mean time, I've edited your post to fix it up.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Dec 13, 2007 9:59 pm

mtettmar wrote:Re why didn't your code post properly: Seems for CODE/TEXTAREA to work there needs to be text prior to the firs textarea tag. Will try to get that fixed. In the mean time, I've edited your post to fix it up.
Hi Marcus,

You might want to upgrade your phpBB installation to phpBB3 Gold released today.
There are a ton of fixes, see CHANGELOG.

It might even have a fix for the following annoyance mentioned at the end of this post...
Rain wrote:FYI, I did use the forums search feature but find it kind of aggravating when every time I click the back button to go back to the search result list I get the “Page has Expiredâ€Â
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu Dec 13, 2007 10:31 pm

[quote="jpuziano"][quote="Rain"]FYI, I did use the forums search feature but find it kind of aggravating when every time I click the back button to go back to the search result list I get the “Page has Expiredâ€Â

stev3n
Junior Coder
Posts: 22
Joined: Thu Nov 01, 2007 1:13 am

Post by stev3n » Fri Dec 14, 2007 3:23 pm

Alright, I have one more final problem to this script.

I want to be able to use the hotkeys in this script until I shut the script off. I'm not understanding why it's just not in a continuous loop.

Both of these, when I press them, keep repeating, and don't stop. I only want them to do their subroutine once each time I press the button, until I shut the script off.

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=428
   Height=247
   Top=592
   Left=296
   Max=1
   Min=1
   Close=1
   Resize=1
   RadioGroup=msRadioGroup1,msRadioGroup1,8,8,121,145,No Mage%CRLF%Fire Blast%CRLF%Fire Wave%CRLF%Guthix%CRLF%Saradomin%CRLF%Zamorak,-1
   CheckBox=msCheckBox1,Steel Skin,136,48,97,False
   CheckBox=msCheckBox2,Ultimate Strength,136,72,105,False
   CheckBox=msCheckBox3,Incredible Reflexes,136,96,113,False
   Button=OK,112,160,75,25,1
   Button=Cancel,256,160,75,25,2
   Edit=msEdit1,344,64,25,P
   Edit=msEdit2,344,88,25,M
   Label=Pray Hotkey,272,64,true
   Label=Mage Hotkey,272,88,true
EndDialog>Dialog1

Show>Dialog1,r

Label>MainLoop
OnEvent>KEY_DOWN,%Dialog1.msEdit1%,5,Pray
OnEvent>KEY_DOWN,%Dialog1.msEdit2%,5,Mage
GoTo>MainLoop

SRT>Pray
Label>First
GetWindowPos>StorkClient,sX,sY
GetCursorPos>xX,yY
//disable mouse
Pos>98,WIN_VER,1,IsWin98orMe
If>{(%IsWin98orMe%=0)}
BlockInput>1
Endif
//to book
Add>sX,393
Add>sY,40
MouseMove>sX,sY
Wait>.09
//to prayers
Add>sX,66
Add>sY,33
MouseMove>sX,sY
Wait>.08
LDown
Wait>.05
LUp
//to bottom of scrollbar
Add>sX,43
Add>sY,84
MouseMove>sX,sY
Wait>.05
LDown
Wait>.05
LUp
Sub>sX,502
Sub>sY,157
Wait>.05
Wait>.05

GoTo>steelpart

Label>steelpart
//steel
If>Dialog1.msCheckBox1=True
Add>sX,395
Add>sY,102
MouseMove>sX,sY
Wait>.05
LClick
Wait>.05
Sub>sX,395
Sub>sY,102
GoTo>strengthpart
Else
GoTo>strengthpart
Endif

Label>strengthpart
//strength
If>Dialog1.msCheckBox2=True
Add>sX,395
Add>sY,122
MouseMove>sX,sY
Wait>.05
LClick
Wait>.05
Sub>sX,395
Sub>sY,122
GoTo>reflexpart
Else
GoTo>reflexpart
Endif

Label>reflexpart
//reflex
If>Dialog1.msCheckBox3=True
Add>sX,395
Add>sY,136
MouseMove>sX,sY
Wait>.05
LClick
Sub>sX,395
Sub>sY,136
GoTo>lastpart
Else
GoTo>lastpart
Endif

Label>lastpart
BlockInput>0
End>Pray

GoTo>MainLoop

SRT>Mage
Label>magestart
GetWindowPos>StorkClient,sX,sY
GetCursorPos>xX,yY
//disable mouse
Pos>98,WIN_VER,1,IsWin98orMe
If>{(%IsWin98orMe%=0)}
BlockInput>1
Endif
//to book
Add>sX,392
Add>sY,38
MouseMove>sX,sY
Wait>.08
//to "magic"
Add>sY,32
MouseMove>sX,sY
LClick
Sub>sX,392
Sub>sY,70
Wait>.08
GoTo>death

Label>death
If>Dialog1.msRadioGroup1.itemindex=1
   Add>sX,503
   Add>sY,141
MouseMove>sX,sY
Wait>.08
LDown
Wait>.08
LUp
Wait>.02
Sub>sX,123
Sub>sY,20
MouseMove>sX,sY
GoTo>magecont
Else
GoTo>blood
Endif

//to bottom of scrollbar
Label>blood
If>Dialog1.msRadioGroup1.itemindex=2
   Add>sX,503
   Add>sY,160
MouseMove>sX,sY
Wait>.08
LDown
Wait>.08
LUp
Wait>.02
Sub>sX,123
Sub>sY,26
MouseMove>sX,sY
GoTo>magecont
Else
GoTo>guthix
Endif

Label>guthix
If>Dialog1.msRadioGroup1.itemindex=3
   Add>sX,503
   Add>sY,145
MouseMove>sX,sY
Wait>.08
LDown
Wait>.08
LUp
Wait>.02
Sub>sX,123
Sub>sY,48
MouseMove>sX,sY
GoTo>magecont
Else
GoTo>saradom
Endif

Label>saradom
If>Dialog1.msRadioGroup1.itemindex=4
   Add>sX,503
   Add>sY,145
MouseMove>sX,sY
Wait>.08
LDown
Wait>.08
LUp
Wait>.02
Sub>sX,123
Sub>sY,36
MouseMove>sX,sY
GoTo>magecont
Else
GoTo>zamorak
Endif

Label>zamorak
If>Dialog1.msRadioGroup1.itemindex=5
   Add>sX,503
   Add>sY,145
MouseMove>sX,sY
Wait>.08
LDown
Wait>.08
LUp
Wait>.02
Sub>sX,123
Sub>sY,22
MouseMove>sX,sY
GoTo>magecont
Else
GoTo>magecont
Endif

Label>magecont
Wait>.05
LClick
Wait>.08
//return home!
MouseMove>xX,yY
Wait>.08
//enable mouse
BlockInput>0
End>Mage

GoTo>MainLoop

stev3n
Junior Coder
Posts: 22
Joined: Thu Nov 01, 2007 1:13 am

Post by stev3n » Sat Dec 15, 2007 6:48 pm

I saw the blog http://www.mjtnet.com/blog/2007/11/20/exes-and-hotkeys/ , and I tried this and it still didn't work. What am I doing wrong?

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