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 

Problems entering in full text into excel cells, and more

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



Joined: 19 Nov 2009
Posts: 5

PostPosted: Thu Nov 19, 2009 10:40 pm    Post subject: Problems entering in full text into excel cells, and more Reply with quote

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!
Back to top
View user's profile Send private message
rtcvb32



Joined: 17 Feb 2008
Posts: 125

PostPosted: Thu Nov 19, 2009 11:01 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Yahoo Messenger
darrin0



Joined: 19 Nov 2009
Posts: 5

PostPosted: Thu Nov 19, 2009 11:02 pm    Post subject: Reply with quote

#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
Back to top
View user's profile Send private message
darrin0



Joined: 19 Nov 2009
Posts: 5

PostPosted: Thu Nov 19, 2009 11:04 pm    Post subject: Reply with quote

sorry, I don't actually know how to properly paste code into this forum Sad
Back to top
View user's profile Send private message
rtcvb32



Joined: 17 Feb 2008
Posts: 125

PostPosted: Thu Nov 19, 2009 11:14 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Yahoo Messenger
darrin0



Joined: 19 Nov 2009
Posts: 5

PostPosted: Fri Nov 20, 2009 5:25 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
rtcvb32



Joined: 17 Feb 2008
Posts: 125

PostPosted: Fri Nov 20, 2009 10:30 pm    Post subject: Reply with quote

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/wiki/Documentation/BASIC_Guide
Back to top
View user's profile Send private message Yahoo Messenger
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