AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

This or This for a If Statement and Message Box question

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Josh
Guest





PostPosted: Thu Jun 19, 2008 12:55 pm    Post subject: This or This for a If Statement and Message Box question Reply with quote

I did quite a bit of searching yesterday for a solution but didnt come up with anything. I want to know if there is something like a or statement so I could do something like

IfNotEqual ReoM, 5
OR
IfNotEqual PpgM, 4
Then Do This

I couldnt find anything in the help file which could do this and if I just put them one after another after the first time the script is run with one of those correct the script will always just skip those afterwards thinking it does not have to do them even if I choose the same option again.


Another question I have is it possible to have a MsgBox AlwaysOnTop like the Gui.
Back to top
John W



Joined: 09 Apr 2007
Posts: 169

PostPosted: Thu Jun 19, 2008 12:56 pm    Post subject: Reply with quote

If (StatementA || StatementB)
If (StatementA OR StatementB)

Both do the same.
_________________
John
Inactive - Until AutoHotkey is available for Linux.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 5888

PostPosted: Thu Jun 19, 2008 1:07 pm    Post subject: Reply with quote

Code:
If ( ReoM <> 5 OR PpgM <> 4 )
     MsgBox, I am got to do this

Quote:
is it possible to have a MsgBox AlwaysOnTop like the Gui.

Code:
MsgBox, 262144, MsgBox, Always on TOP

Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Josh
Guest





PostPosted: Thu Jun 19, 2008 1:46 pm    Post subject: Reply with quote

Either it is my script or something else is wrong. I used

If (ReoM <> 5 OR PpgM <> 4)

and tried

If (ReoM <> 5 || PpgM <> 4)

I guess I should explain my setup first. I have two commands Ctrl+M and Ctrl+P. Both open a speified Gui and after completed go on to a base script that both Gui's will use as it is 100% identical except for a few If statements. Right now I need two portions skipped if a certian value is true which is what I am doing now.

What the command I am using does is when I try Ctrl+M after first running the script the value I set to skip does not work at all. If I change to Ctrl+P the value works perfect. Now if I go back to Ctrl+M that value works perfect. If I reload the script and try it the other way around and use Ctrl+P first then the value needed to skip a portion does not work at all and when I go to Ctrl+M it work perfect.
Back to top
Josh
Guest





PostPosted: Thu Jun 19, 2008 1:47 pm    Post subject: Reply with quote

Thanks SKAN. The message box's stay on top now. The readme made it too confusing.
Back to top
Josh
Guest





PostPosted: Thu Jun 19, 2008 3:01 pm    Post subject: Reply with quote

Ok here is a example of my problem. When ever I run this it does not do as I specified it to do.

Code:

;; Testing ----------------------------------------------------------------------------------------
^n:: ; Ctrl+N
Gui Destroy
IfWinActive Untitled - Notepad ahk_class Notepad
   { WinActivate
   }
   Else
   { Run notepad
   WinActivate
   }
Gui +AlwaysOnTop -SysMenu
Gui Add, Edit, vNumber Number Limit3 w40, 0
Gui Add, Radio, vRadio1 Checked, Option 1
Gui Add, Radio, , Option 2
Gui Add, Radio, , Option 3
Gui Add, Radio, , Option 4
Gui Add, Radio, , Option 5
Gui Add, Text, ym+4 xm+43, Num
Gui Add, Checkbox, vCheck ym+4 xm+92, Check
Gui Add, Button, Submit Default w42 ym+125 xm+33, OK
Gui Add, Button, Cancel w42 ym+125 xm+82, Cancel
Gui Add, Checkbox, vBox Disabled ym-50 xm-50
Gui Show, AutoSize, Box 1
Return


;; Testing ----------------------------------------------------------------------------------------
^m:: ; Ctrl+M
Gui Destroy
IfWinActive Untitled - Notepad ahk_class Notepad
   { WinActivate
   }
   Else
   { Run notepad
   WinActivate
   }
Gui +AlwaysOnTop -SysMenu
Gui Add, Edit, vNumber Number Limit3 w40, 0
Gui Add, Radio, vRadio2 Checked, Option 1
Gui Add, Radio, , Option 2
Gui Add, Radio, , Option 3
Gui Add, Radio, , Option 4
Gui Add, Text, ym+4 xm+43, Num
Gui Add, Button, Submit Default w42 ym+106 xm+33, OK
Gui Add, Button, Cancel w42 ym+106 xm+82, Cancel
Gui Add, Checkbox, vBox Checked Disabled ym-50 xm-50
Gui Show, AutoSize, Box 2
Return


;; Testing ----------------------------------------------------------------------------------------
ButtonCancel:
Gui Destroy
Return

ButtonOK:
Gui Submit
If ( Radio1 <> 5 OR Radio2 <> 4 )
   { If Number <= 0
      { MsgBox 262144, MsgBox, Invalid Quantity
      If Box = 0
         { Gui Destroy
         Gui +AlwaysOnTop -SysMenu
         Gui Add, Edit, vNumber Number Limit3 w40, 0
         Gui Add, Radio, vRadio1 Checked, Option1
         Gui Add, Radio, , Option2
         Gui Add, Radio, , Option3
         Gui Add, Radio, , Option4
         Gui Add, Radio, , Option5
         Gui Add, Text, ym+4 xm+43, Num
         Gui Add, Checkbox, vCheck ym+4 xm+92, Check
         Gui Add, Button, Submit Default w42 ym+125 xm+33, OK
         Gui Add, Button, Cancel w42 ym+125 xm+82, Cancel
         Gui Add, Checkbox, vBox Disabled ym-50 xm-50
         Gui Show, AutoSize, Box 1
         Return
         }
      Else If Box = 1
         { Gui Destroy
         Gui +AlwaysOnTop -SysMenu
         Gui Add, Edit, vNumber Number Limit3 w40, 0
         Gui Add, Radio, vRadio2 Checked, Option1
         Gui Add, Radio, , Option2
         Gui Add, Radio, , Option3
         Gui Add, Radio, , Option4
         Gui Add, Text, ym+4 xm+43, Num
         Gui Add, Button, Submit Default w42 ym+106 xm+33, OK
         Gui Add, Button, Cancel w42 ym+106 xm+82, Cancel
         Gui Add, Checkbox, vBox Checked Disabled ym-50 xm-50
         Gui Show, AutoSize, Box 2
         Return
         }
      }
   }
CoordMode Mouse, Relative
SetDefaultMouseSpeed 3
SetControlDelay -1
IfWinActive Untitled - Notepad ahk_class Notepad
   { WinActivate
   }
   Else
   { WinWait Untitled - Notepad ahk_class Notepad, , 20
      If ErrorLevel
         { MsgBox hotkey timed out.
         Return
         }
      Else
         { WinActivate
         }
   }
Send Num ={Space}
If Number > 0
   { Send %Number%
   }
Else If Number <= 0
   { Send 0
   }
Send {Enter}
Send Check ={Space}
If Box = 0
   { If Check = 1
      { Send Box is checked
      }
   Else If Check = 0
      { Send Box is not checked
      }
   }
Else If Box = 1
   { Send N/A
   }
Send {Enter}
Send Radio ={Space}
If Box = 0
   { If Radio1 = 1
      { Send Radio1 - Option1
      }
   Else If Radio1 = 2
      { Send Radio1 - Option2
      }
   Else If Radio1 = 3
      { Send Radio1 - Option3
      }
   Else If Radio1 = 4
      { Send Radio1 - Option4
      }
   Else If Radio1 = 5
      { Send Radio1 - Option5
      }
   }
Else If Box = 1   
   { If Radio2 = 1
      { Send Radio2 - Option1
      }
   Else If Radio2 = 2
      { Send Radio2 - Option2
      }
   Else If Radio2 = 3
      { Send Radio2 - Option3
      }
   Else If Radio2 = 4
      { Send Radio2 - Option4
      }
   }
Send {Enter}
Send {Enter}
Gui Destroy
Return


The last radio button on each should accept 0 as the num but it does not until you switch between Ctrl+N and Ctrl+M once with an Invalid Quantity.
Back to top
Josh
Guest





PostPosted: Fri Jun 20, 2008 3:13 pm    Post subject: Reply with quote

Thanks anyways. I figured it out finally after alot of trial and error.

For anyone attempting a similar script you will need to do the following with the whole script I posted above in order to skip portions of a base script for the two gui windows.

If ( Radio1 <> 5 AND Box = 0 OR Radio2 <> 4 AND Box = 1 )

I should had figured this because I originally created the hidden checkbox to distinguish the two windows apart without the radios interfering with each other.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group