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 

Boolean in Ifs

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
BaldieJr



Joined: 02 Jul 2004
Posts: 23

PostPosted: Sat Jul 10, 2004 7:22 am    Post subject: Boolean in Ifs Reply with quote

if joyU < 020 && > 010
Send, somekey

Cool
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sat Jul 10, 2004 12:11 pm    Post subject: Reply with quote

The "and" in your example is already supported:
Code:
if joyU < 020
     if joyU > 010
     {
     ...
     }

But the "or" conjunction isn't yet. Much of the "or" would be realizable through an idea to have "if joyU not between 10, 20", which should be in a future version.
Back to top
View user's profile Send private message Send e-mail
BaldieJr



Joined: 02 Jul 2004
Posts: 23

PostPosted: Sat Jul 10, 2004 9:15 pm    Post subject: Reply with quote

Let me rephrase:

I wish for: expressions in if statements, with multiple comparisons using and/or.

ifing an if is fine when you've only two, but try breaking an axis into 10 (or more!) seperate keystrokes and only 'send'ing when there is a change. It gets pretty complex/ confusing (I've been at this since yesterday and still haven't made it work properly).
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sat Jul 10, 2004 11:03 pm    Post subject: Reply with quote

Since true complex expressions are pretty far down on the list, it will probably be at least several months before it happens. In the meantime, it's usually best to use a series of else if statements:

if joyu < 10
...
else if joyu < 20 ; between 10 and 19
...
else if joyu < 30 ; between 20 and 29
...
else ; joyu >= 30
...

If that doesn't help you, someone here might be able to suggest an approach if you post a sample or describe the plan for your script in more detail.
Back to top
View user's profile Send private message Send e-mail
BaldieJr



Joined: 02 Jul 2004
Posts: 23

PostPosted: Sun Jul 11, 2004 2:33 am    Post subject: Reply with quote

Seems kinda involved to me Laughing

If anyone ever needs to know how to do key-stroke 'banding' on a joy axis, this is it.

This uses axis U.

0-10 = 0 % mixture
11-20 = 10% mixture
etc etc etc

It does not continuously send keys. It only sends when over/under a band.

Code:

#Persistent
#SingleInstance
SetFormat, float, 03
JoystickNumber = 2 ; Set this to joystick to be used.
state = 000
current = 0
Loop
{   
  sleep, 100
  GetKeyState, joyu, %JoystickNumber%JoyU
  If state <> %joyu%
  {
    Loop
    {
      if joyu < 10
        {
   if current = 1
   {
   Break
   }
        Send, Setting Mixture 0 Percent {enter}
        state = %joyu%
   current = 1
        Break
        }
      else if joyu < 20 ; between 10 and 19
        {
   if current = 2
   {
   Break
   }
        Send, Setting Mixture 10 Percent {enter}
        state = %joyu%
   current = 2
        Break
        }
      else if joyu < 30 ; between 20 and 29
        {
   if current = 3
   {
   Break
   }
        Send, Setting Mixture 30 Percent {enter}
        state = %joyu%
   current = 3
        Break
        }
      else if joyu < 40 ; between 20 and 29
        {
   if current = 4
   {
   Break
   }
        Send, Setting Mixture 40 Percent {enter}
        state = %joyu%
   current = 4
        Break
        }
      else if joyu < 50 ; between 20 and 29
        {
   if current = 5
   {
   Break
   }
        Send, Setting Mixture 50 Percent {enter}
   state = %joyu%
   current = 5
   Break
   }
      else if joyu < 60 ; between 20 and 29
   {
   if current = 6
   {
   Break
   }
   Send, Setting Mixture 60 Percent {enter}
   state = %joyu%
   current = 6
   Break
   }
      else if joyu < 70 ; between 20 and 29
   {
   if current = 7
   {
   Break
   }
   Send, Setting Mixture 70 Percent {enter}
   state = %joyu%
   current = 7
   Break
   }
      else if joyu < 80 ; between 20 and 29
   {
   if current = 8
   {
   Break
   }
   Send, Setting Mixture 80 Percent {enter}
   state = %joyu%
   current = 8
   Break
   }
      else if joyu < 90 ; between 20 and 29
   {
   if current = 9
   {
   Break
   }
   Send, Setting Mixture 90 Percent {enter}
   state = %joyu%
   current = 9
   Break
   }
   else ; joyu >= 100
   if current = 10
   {
   Break
   }
   Send, Setting Mixture 100 Percent {enter}
   state = %joyu%
   current = 10
   Break
   }
    }
  }


Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sun Jul 11, 2004 3:51 am    Post subject: Reply with quote

Quote:
JoystickNumber = 2

So you actually have more than one joystick installed? If so, that's good because I hadn't been able to test multi-joystick support.
Back to top
View user's profile Send private message Send e-mail
BaldieJr



Joined: 02 Jul 2004
Posts: 23

PostPosted: Sun Jul 11, 2004 4:16 am    Post subject: Reply with quote

Chris,

I'm not normal. I'm building a cockpit. Laughing

3 sticks are installed now (one is virtual) and autohotkeys sees them all. I have a dual-device USB controller awaiting more parts. I plan to get a 256 button controller board and a 256 channel digital output board.

I'm banging around with autohotkey in hopes that it will be the glue that brings all the hardware together.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sun Jul 11, 2004 5:11 am    Post subject: Reply with quote

Sounds cool -- a simulator I imagine -- good luck with it.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List 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