AutoHotkey Community

It is currently May 27th, 2012, 1:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: November 19th, 2009, 11:40 pm 
Offline

Joined: November 19th, 2009, 11:34 pm
Posts: 5
I've put together a macro to allow me to modify several differnt cells in excel and then copy those cells into an online form. The main issue I'm running into is that my macro isn't consistent. Sometimes the text it enters will leave out a letter or two. Sometimes actions such as moving up one cell or down it will either move twice or not at all.

Is there a way to prevent these issues? Or is my computer just too slow to properly run a macro like that?

I've attempted to delay the time in between commands, but that in fact has made it worse. Maybe I'm doing that part wrong?

Any help is much appreciated!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 12:01 am 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
Post some of your macro, so we can see what you're doing.

Don't forget the excel spreadsheet will keep in mind it's location relative to your typing. So if you start in A1, and do 'something{tab}somthing{tab}something{enter}' then you will start again on B1, however if you do 'Something{tab}something{down}' then it will reset it's base to C2, not C1.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 12:02 am 
Offline

Joined: November 19th, 2009, 11:34 pm
Posts: 5
#z::

WinWait, Microsoft Excel,
IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
WinWaitActive, Microsoft Excel,
Send, {F2}{HOME}{SHIFTDOWN}{RIGHT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{TAB}{DOWN}{CTRLDOWN}v{CTRLUP}{UP}{LEFT}{F2}{CTRLDOWN}{SHIFTDOWN}{LEFT}{SHIFTUP}{CTRLUP}{CTRLDOWN}c{CTRLUP}{TAB}{DOWN}{F2}{CTRLDOWN}v{CTRLUP}{ENTER}=upper{SHIFTDOWN}9{SHIFTUP}{UP}{SHIFTDOWN}0{SHIFTUP}{ENTER}{UP}{CTRLDOWN}c{CTRLUP}{UP}{UP}{APPSKEY}s
IfWinExist Paste Special
{
WinActivate
}
else
{
Send {ENTER}
}
IfWinNotActive, Paste Special, , WinActivate, Microsoft Excel,
WinWaitActive, Paste Special,
Send, {DOWN}{DOWN}{TAB}{TAB}{TAB}{TAB}{SPACE}
WinWait, Microsoft Excel,
IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
WinWaitActive, Microsoft Excel,
Send, {DOWN}{DEL}{DOWN}{DEL}{UP}{UP}{RIGHT}{RIGHT}{RIGHT}{CTRLDOWN};{CTRLUP}{TAB}{TAB}WINTER01{TAB}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{CTRLDOWN}c{CTRLUP}{ALTDOWN}{TAB}{ALTUP}
WinWait, http://,
IfWinNotActive, http://, , WinActivate, http://,
WinWaitActive, http://,
Send, {CTRLDOWN}v{CTRLUP}{ALTDOWN}{TAB}{ALTUP}
WinWait, Microsoft Excel,
IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
WinWaitActive, Microsoft Excel,
Send, {LEFT}{CTRLDOWN}c{CTRLUP}{ALTDOWN}{TAB}{ALTUP}
WinWait, http://,
IfWinNotActive, http://, , WinActivate, http://,
WinWaitActive, http://,
Send, {TAB}{CTRLDOWN}v{CTRLUP}{ALTDOWN}{TAB}{ALTUP}
WinWait, Microsoft Excel,
IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
WinWaitActive, Microsoft Excel,
Send, {TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{CTRLDOWN}c{CTRLUP}{ALTDOWN}{TAB}{ALTUP}
WinWait, http://,
IfWinNotActive, http://, , WinActivate, http://,
WinWaitActive, http://,
Send, {TAB}{CTRLDOWN}v{CTRLUP}{TAB}{CTRLDOWN}v{CTRLUP}{TAB}{TAB}{ALTDOWN}{TAB}{ALTUP}
WinWait, Microsoft Excel,
IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
WinWaitActive, Microsoft Excel,
Send, {HOME}{CTRLDOWN}c{CTRLUP}{ALTDOWN}{TAB}{ALTUP}
WinWait, http://,
IfWinNotActive, http://, , WinActivate, http://,
WinWaitActive, http://,
Send, %clipboard%
WinWait, Windows Internet Explorer,
IfWinNotActive, Windows Internet Explorer, , WinActivate, Windows Internet Explorer,
WinWaitActive, Windows Internet Explorer,
Send, {ENTER}
WinWait, http://,
IfWinNotActive, http://, , WinActivate, http://,
WinWaitActive, http://,
Send, {TAB}{TAB}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}
MsgBox, 4, , Is everything entered in UltraPoS correctly including %clipboard% as the mall name?
IfMsgBox, No
return
WinWait, http://,
IfWinNotActive, http://, , WinActivate, http://,
WinWaitActive, http://,
Send, {ENTER}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 12:04 am 
Offline

Joined: November 19th, 2009, 11:34 pm
Posts: 5
sorry, I don't actually know how to properly paste code into this forum :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 12:14 am 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
to paste the code section, it's

[ code ]
;some code here
[ /code ]

I see you can do some cleanup on your send commands.

EDIT: Here's the condensed reformatted version. You might add 'pause' before each winwait, so you can check it's reactions one block at a time. I don't have any test data to work with, nor do i have excel. So I cannot test this right now.


Code:
#z::
      ;Winwaits indented for readability, way too many of them in my opinion.
      WinWait, Microsoft Excel,
      IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
      WinWaitActive, Microsoft Excel,
   
   Send, {F2}{HOME}+{RIGHT}^c{TAB}{DOWN}^v{UP}{LEFT}{F2}^+{LEFT}^c{TAB}{DOWN}{F2}^v{ENTER}=upper({UP}){ENTER}{UP}^c{UP 2}{APPSKEY}s
   
   IfWinExist Paste Special
   {
      WinActivate
   } else {
      Send {ENTER}
   }
   
      IfWinNotActive, Paste Special, , WinActivate, Microsoft Excel,
      WinWaitActive, Paste Special,

   Send, {DOWN 2}{TAB 4}{SPACE}
   
      WinWait, Microsoft Excel,
      IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
      WinWaitActive, Microsoft Excel,
   
   Send, {DOWN}{DEL}{DOWN}{DEL}{UP 2}{RIGHT 3}^;
   Send, {TAB 2}WINTER01{TAB}{LEFT 6}^c!{TAB}
   
      WinWait, http://,
      IfWinNotActive, http://, , WinActivate, http://,
      WinWaitActive, http://,

   Send, ^v!{TAB}
   
      WinWait, Microsoft Excel,
      IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
      WinWaitActive, Microsoft Excel,
   
   Send, {LEFT}^c!{TAB}
      WinWait, http://,
      IfWinNotActive, http://, , WinActivate, http://,
      WinWaitActive, http://,
   
   Send, {TAB}^v!{TAB}
   
      WinWait, Microsoft Excel,
      IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
      WinWaitActive, Microsoft Excel,
   
   Send, {TAB 6}^c!{TAB}

      WinWait, http://,
      IfWinNotActive, http://, , WinActivate, http://,
      WinWaitActive, http://,
   
   Send, {TAB}^v{TAB}^v{TAB 2}!{TAB}
   
      WinWait, Microsoft Excel,
      IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,
      WinWaitActive, Microsoft Excel,
   
   Send, {HOME}^c!{TAB}
   
      WinWait, http://,
      IfWinNotActive, http://, , WinActivate, http://,
      WinWaitActive, http://,
   
   ;raw for safety.
   Send, {raw}%clipboard%
   
      WinWait, Windows Internet Explorer,
      IfWinNotActive, Windows Internet Explorer, , WinActivate, Windows Internet Explorer,
      WinWaitActive, Windows Internet Explorer,
   
   Send, {ENTER}
   
      WinWait, http://,
      IfWinNotActive, http://, , WinActivate, http://,
      WinWaitActive, http://,
   
   Send, {TAB 2}{DOWN 5}
   
   MsgBox, 4, , Is everything entered in UltraPoS correctly including %clipboard% as the mall name?
   IfMsgBox, No
      return

      WinWait, http://,
      IfWinNotActive, http://, , WinActivate, http://,
      WinWaitActive, http://,

   Send, {ENTER}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 6:25 pm 
Offline

Joined: November 19th, 2009, 11:34 pm
Posts: 5
Thanks for the help rtcvb32; your version does look a lot cleaner than mine.

I am still having problems with this macro though. It is rarely consistent with working. There is a portion in it where it is supposed to type WINTER01. Sometimes it will type INTER01 or WINER01. There is a lot of tabbing and moving around with the keyboard, but a majority of the time it isn't tabbing the correct number of times, and occasionally it works.

Any tips as to how to resolve this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 11:30 pm 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
Well, to solve these, do them in parts. Do one block at a time, and put pause or something between each section, until you get it right.

Also, you might put a larger delay in the keydelay. Like 50,50. If all else does fail, you can still use the clipboard for those large blocks of text.

Another option is there is Visual Basic Script for excel. It's a little confusing but you can get it to work for you, and you can specify specific locations like A1:E5. A good place to learn happens to have a compatible version for Open Office.

http://wiki.services.openoffice.org/wik ... ASIC_Guide


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], bobbysoon, iDrug, Ohnitiel, Yahoo [Bot] and 23 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group