Excel does not recognize the CTRL Press

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
bobmcc81
Newbie
Posts: 4
Joined: Mon Dec 08, 2008 9:18 pm

Excel does not recognize the CTRL Press

Post by bobmcc81 » Mon Dec 08, 2008 9:26 pm

I have a simple script trying to change to another tab on an excel spreadsheet and to do that requires a CTRL Page Up command. Below is my script and I can't get the CTRL to be recognized and pressed in teh macro.

Thanks for an education

execute file>todaysfile.xls
setfocus>Microsoft Excel - todaysfile.xls
wait>.2
press up * 50
wait>.2
press left * 50
wait>.2
press CTRL
wait>.2
press page up
wait>.2
release CTRL
wait>.2
press home

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Mon Dec 08, 2008 9:34 pm

use vk keys here is a sample script mettmar gave me back in the day that i still use you will ned to go to site to get vkcode for ctrl but this works with all keypresses also you only need to change where it says VK_down=40 just have to change the 40 for each key you can use exact same snippet of code for each key your pressing just use whole snippet and change 40 and change wait for duration the wait is how long it holds down key before releasing it

Code: Select all

//Key codes at <a>http://www.mjtnet.com/vkcodes.htm</a>
Let>VK_DOWN=40
Let>ExtendedKey=1
Let>KeyUp=2

//Press Down Arrow
LibFunc>user32.dll,keybd_event,r,VK_DOWN,0,ExtendedKey,0

//Wait 10 seconds
Wait>10

//Now release Down Arrow
Let>FLAGS={%ExtendedKey% OR %KeyUp%}
LibFunc>user32.dll,keybd_event,r,VK_DOWN,0,FLAGS,0

if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
JRL
Automation Wizard
Posts: 3529
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Dec 08, 2008 10:04 pm

I'd suggest adding a WaitWindowOpen> line. As-is the script has run and completed before Excel has opened. Then I'd bump the first wait up a bit. After the script is working start shaving time off the different Waits being careful to not go so far as to cause intermittent failures.

Code: Select all

execute file>todaysfile.xls
WaitWindowOpen>Microsoft Excel - todaysfile.xls
setfocus>Microsoft Excel - todaysfile.xls
wait>3
press up * 50
wait>.2
press left * 50
wait>.2
press CTRL
wait>.2
press page up
wait>.2
release CTRL
wait>.2
press home

bobmcc81
Newbie
Posts: 4
Joined: Mon Dec 08, 2008 9:18 pm

Post by bobmcc81 » Tue Dec 09, 2008 1:03 pm

Thanks idiot (that sounds funny) and JRL the waitwindow open worked perfectly thanks so much.

I will be checking into the vkcode stuff though.

Have a great day

Bob

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts