Jump to content

How to make these funcs shorter


jeroen96
 Share

Recommended Posts

Hello, I want to know if there is a shorter way to write this:

 

Func mouse_co ()
   $a += 1
   If $a = 1 Then
      Global $m1 = MouseGetPos ()
   ElseIf $a = 2 Then
      Global $m2 = MouseGetPos ()
   ElseIf $a = 3 Then
      Global $m3 = MouseGetPos ()
   ElseIf $a = 4 Then
      Global $m4 = MouseGetPos ()
   ElseIf $a = 5 Then
      Global $m5 = MouseGetPos ()
   ElseIf $a = 6 Then
      Global $m6 = MouseGetPos ()
   ElseIf $a = 7 Then
      Global $m7 = MouseGetPos ()
   ElseIf $a = 8 Then
      Global $m8 = MouseGetPos ()
   ElseIf $a = 9 Then
      Global $m9 = MouseGetPos ()
   ElseIf $a = 10 Then
      Global $m10 = MouseGetPos ()
   ElseIf $a = 11 Then
      Global $m11 = MouseGetPos ()
   ElseIf $a = 12 Then
      Global $m12 = MouseGetPos ()
   EndIf
EndFunc

Func mouse_co2 ()
   If $a >= 1 Then
      Send ("(" & $m1[0] & "," & $m1[1] & ")" & @CRLF)
      If $a >= 2 Then
         Send ("(" & $m2[0] & "," & $m2[1] & ")" & @CRLF)
         If $a >= 3 Then
            Send ("(" & $m3[0] & "," & $m3[1] & ")" & @CRLF)
            If $a >= 4 Then
               Send ("(" & $m4[0] & "," & $m4[1] & ")" & @CRLF)
               If $a >= 5 Then
                  Send ("(" & $m5[0] & "," & $m5[1] & ")" & @CRLF)
                  If $a >= 6 Then
                     Send ("(" & $m6[0] & "," & $m6[1] & ")" & @CRLF)
                     If $a >= 7 Then
                        Send ("(" & $m7[0] & "," & $m7[1] & ")" & @CRLF)
                        If $a >= 8 Then
                           Send ("(" & $m8[0] & "," & $m8[1] & ")" & @CRLF)
                           If $a >= 9 Then
                              Send ("(" & $m9[0] & "," & $m9[1] & ")" & @CRLF)
                              If $a >= 10 Then
                                 Send ("(" & $m10[0] & "," & $m10[1] & ")" & @CRLF)
                                 If $a >= 11 Then
                                    Send ("(" & $m11[0] & "," & $m11[1] & ")" & @CRLF)
                                    If $a >= 12 Then
                                       Send ("(" & $m12[0] & "," & $m12[1] & ")" & @CRLF)
                                    EndIf
                                 EndIf
                              EndIf
                           EndIf
                        EndIf
                     EndIf
                  EndIf
               EndIf
            EndIf
         EndIf
      EndIf
   EndIf
EndFunc

 

I want to use this to a max $a but in this way it costs a lot of time

thanks

Link to comment
Share on other sites

Use Arrays and Switch instead of multiple If/Then/Else.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...