Jump to content
Sign in to follow this  
teemo

While in While is my problem...i guess

Recommended Posts

teemo

I am completly new to autoit but i need it because it works for a problem i need to solve:

I want to click on different stuff in the corner of my screen. It goes 3 up then adjust the window and clicks the new 3 (works so far). Then if you press the up button it should go up again (it doesnt).

It needs to be triggered by keys and is just clicking up and down.

My problem is that it makes sense in my head what i did there but i have no idea how to tell autoit what i want.

I guess i used to many whiles cause thats the only thing that worked for me. the "Key" function is the same as _ispressed and 1 while alone it would even run up or down (the 1 click in between adjusts the window)

 

i am sorry for the huge mess i did there...please try to fix it!

#include "Key.au3"

; going down
$all = 1
$u = 1
$i = 1
while $all = 1
   Sleep(50)
   While $i = 1
      Sleep(50)
      While Key("NUMPAD1")
         MouseClick ("right", 1500 , 1000, 1, 0)
         Sleep(10)
         Send ("{DOWN}")
         sleep (5)
         Send ("{ENTER}") 
         $i = $i + 1
         While $i = 2
            Sleep(50)
            While Key("NUMPAD1")
               MouseClick ("right", 1500 , 1020, 1, 0)
               Sleep(10)
               Send ("{DOWN}")
               sleep (5)
               Send ("{ENTER}")
               $i = $i + 1
               While $i = 3
                  Sleep(50)
                  While Key("NUMPAD1")
                     MouseClick ("right", 1500 , 1040, 1, 0)
                     Sleep(10)
                     Send ("{DOWN}")
                     sleep (5)
                     Send ("{ENTER}")
                     Sleep(20) 
                     $i = $i + 1
                     While $i = 4
                        Sleep(50)
                        While Key("NUMPAD1")
                           MouseClick ("left", 1905 , 1047, 1, 0)
                           Sleep (200)
                           MouseClick ("right", 1500 , 1040, 1, 0)
                           Sleep(10)
                           Send ("{DOWN}")
                           sleep (5)
                           Send ("{ENTER}") 
                        WEnd
                     WEnd
                  WEnd
               WEnd
            WEnd
         WEnd    
      WEnd
   WEnd

; going up

   While $i = 5
      Sleep(50)
      While Key("NUMPAD4")
         MouseClick ("right", 1500 , 1040, 1, 0)
         Sleep(10)
            Send ("{DOWN}")
         sleep (5)
         Send ("{ENTER}") 
         $i = $i + 1
         While $i = 6
            Sleep(50)
            While Key("NUMPAD4")
               MouseClick ("right", 1500 , 1020, 1, 0)
               Sleep(10)
               Send ("{DOWN}")
               sleep (5)
               Send ("{ENTER}")
               $i = $i + 1
               While $i = 7
                  Sleep(50)
                  While Key("NUMPAD4")
                     MouseClick ("right", 1500 , 1000, 1, 0)
                     Sleep(10)
                     Send ("{DOWN}")
                     sleep (5)
                     Send ("{ENTER}")
                     Sleep(20) 
                     $i = $i + 1
                     While $i = 8
                        Sleep(50)
                        While Key("NUMPAD4")
                           MouseClick ("left", 1905 , 987, 1, 0)
                           Sleep (200)
                           MouseClick ("right", 1500 , 1000, 1, 0)
                              Sleep(10)
                           Send ("{DOWN}")
                           sleep (5)
                           Send ("{ENTER}") 
                        WEnd
                     WEnd
                  WEnd
               WEnd
            WEnd
         WEnd    
      WEnd
   WEnd

; change direction logic ; from down to up

   While $i = 3
      sleep (50)
      While Key("NUMPAD4")
         MouseClick ("right", 1500 , 1020, 1, 0)
         Sleep(10)
         Send ("{DOWN}")
            sleep (5)
         Send ("{ENTER}")
         $i = 6
      WEnd
   WEnd

   While $i = 4
      sleep (50)
      While Key("NUMPAD4")
         MouseClick ("right", 1500 , 1020, 1, 0)
         Sleep(10)
         Send ("{DOWN}")
         sleep (5)
         Send ("{ENTER}")
         $i = 6
      WEnd
   WEnd

   While $i = 2
      sleep (50)
      While Key("NUMPAD4")
         MouseClick ("right", 1500 , 1000, 1, 0)
         Sleep(10)
         Send ("{DOWN}")
         sleep (5)
         Send ("{ENTER}")
         $i = 7
      WEnd
   WEnd

   While $i = 1
      sleep (50)
      While Key("NUMPAD4")
         MouseClick ("left", 1905 , 987, 1, 0)
         Sleep (200)
         MouseClick ("right", 1500 , 1000, 1, 0)
         Sleep(10)
         Send ("{DOWN}")
         sleep (5)
         Send ("{ENTER}")
         $i = 8
      WEnd
   WEnd

; change direction logic ; from down to up

   While $i = 8
      sleep (50)
      While Key("NUMPAD2")
         MouseClick ("right", 1500 , 1020, 1, 0)        
         Sleep(10)
         Send ("{DOWN}")
         sleep (5)
         Send ("{ENTER}")
         $i = 2
      WEnd
   WEnd

   While $i = 7
      sleep (50)
      While Key("NUMPAD2")
         MouseClick ("right", 1500 , 1020, 1, 0)
         Sleep(10)
         Send ("{DOWN}")            
         sleep (5)
         Send ("{ENTER}")
         $i = 2
      WEnd
   WEnd

   While $i = 6
      sleep (50)
      While Key("NUMPAD2")
         MouseClick ("right", 1500 , 1020, 1, 0)
         Sleep(10)
         Send ("{DOWN}")
         sleep (5)
         Send ("{ENTER}")
         $i = 3
      WEnd
   WEnd

   While $i = 5
      sleep (50)
      While Key("NUMPAD2")
         MouseClick ("right", 1500 , 1020, 1, 0)
         Sleep(10)
         Send ("{DOWN}")
         sleep (5)
         Send ("{ENTER}")
         $i = 4
      WEnd
   WEnd

Share this post


Link to post
Share on other sites
Danp2

You definitely don't want all of those nested While statements. Have a look at the Switch command in the help file.

P.S. What exactly are you trying to automate here?

Share this post


Link to post
Share on other sites
spudw2k

Holy cow!  No offense.
I am also interested in what you are automating.  There may be more accurate/graceful means than what you are doing.

Share this post


Link to post
Share on other sites
teemo

Its for work...the firefighters want to push 1 button to switch between fire alerts.

unfortunatly they have no hotkey in the program itself.

And due to the fact that I'm just an intern i never used autoit before.

The screen is on 2 meters my neck hurts from all the help i read today but I'll check it and keep on trying ^^

Share this post


Link to post
Share on other sites
teemo

it runs up it runs down i just cant change direction.

Share this post


Link to post
Share on other sites
spudw2k

Check out the AutoIt Window Info tool (included with AutoIt).  Depending on the software used for the fire alerts you may be able to use more sophisticated automation techniques.  If you are interested in learning AutoIt it would do you good service to learn some of those methods anyways.

Just my two cents.

Share this post


Link to post
Share on other sites
JLogan3o13

Hi, teemo. Can you provide us with an application name, or a screenshot of the window you're trying to automate, so we can see what you're seeing? It will help us in offering suggestions.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
teemo

Application is called Winmag

I can provide a screenshot as soon as i am home cause im done for today. And my phone cant upload.

I think the stuff at the end cant direct to a point in the loops...but i also cant think of a way to get that done.

Share this post


Link to post
Share on other sites
teemo

To get it straight once: in this program the alerts are shown in a window at the bottom. Now i need to press 1 button to click on the 1st line in the window...a down button

Then 2 after next press

then 3

and then adjust the window with the scroll arrow dow and click 3 again cause the window only has 3 alerts. that is working!

And then i need an up button going up at any point in the line... And also down has to reverse at any point of the up loop. that is not working.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×