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 

Innefficient code - any ideas?

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



Joined: 16 Mar 2008
Posts: 25
Location: Brooklyn

PostPosted: Thu May 15, 2008 10:57 pm    Post subject: Innefficient code - any ideas? Reply with quote

I use AHK to create shipping labels. So imagine an MS office file where I create a table, then it inputs first address -TAB- inputs second address -TAB- inputs first address again -TAB- second address -TAB- first note -TAB- second note. The pattern is a very clear 1, 2, 1, 2, 1, 2.

Then the process starts again exactly the same way 3, 4, 3, 4, 3, 4, and on and on it goes. Does anyone know how I can create a loop to do this for me?

Code:
Send, %varShippingAddress1%{TAB}
Sleep, 50
Send, %varShippingAddress2%{TAB}
Sleep, 50
Send, %varShippingAddress1%{TAB}
Sleep, 50
Send, %varShippingAddress2%{TAB}
Sleep, 50
Send, %varItemTitle1%-%varNoteBox1%{ENTER}{TAB}
Sleep, 50
Send, %varItemTitle2%-%varNoteBox2%{ENTER}

_________________
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1132

PostPosted: Fri May 16, 2008 2:51 am    Post subject: Reply with quote

something like this?
Code:
Sendmode, play
VSA := "varShippingAddress"
VIT := "varItemTitle"
VNB := "varNoteBox"
Loop % NumberOfAddresses
{
   If (Mod(A_Index, 2) = 0)
      continue
   B_Index := A_Index+1
   Send, % %VSA%%A_Index% "{TAB}"
   Sleep, 50
   Send, % %VSA%%B_Index% "{TAB}"
   Sleep, 50
   Send, % %VSA%%A_Index% "{TAB}"
   Sleep, 50
   Send, % %VSA%%B_Index% "{TAB}"
   Sleep, 50
   Send, % %VIT%%A_Index% "-" %VNB%%A_Index% "{ENTER}{TAB}"
   Sleep, 50
   Send, % %VIT%%B_Index% "-" %VNB%%B_Index% "{ENTER}"
   Sleep, 250
}

_________________
My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Back to top
View user's profile Send private message
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