Jump to content
Sign in to follow this  
phanan

ControlSend () Problem with keys CTRL SHIFT ALT

Recommended Posts

phanan

Hi everyone!

I hav a script which used some ControlSend commands to send something (Ctrl a, Ctrl c, Shift F11 & Ctrl v) to the Excel Book. It works, but sometimes it does not work and I dont really understand. I searched a lot, and got information about this problem, but it juzt happen only to the Cezch keyboards. Here I use English keyboard

I post an example code here. So can anyone help me to solve this or suggest a new solution to make Select (Ctrl a), Copy (Ctrl c), Create New Sheet (Shift F11) & Paste (Ctrl v)?

#include <Excel.au3>
$oExcel = _ExcelBookNew()
for $i = 1 to 20 step 1
for $j = 1 to 10 step 1
  _ExcelWriteCell($oExcel, "x", $i, $j)
Next
Next
ControlSend("Microsoft Excel - Book1", "", "", "^a")
ControlSend("Microsoft Excel - Book1", "", "", "^c")
ControlSend("Microsoft Excel - Book1", "", "", "+{F11}")
ControlSend("Microsoft Excel - Book1", "", "", "^v")
;"[CLASS:EXCEL7; INSTANCE:1]"
Edited by phanan

Share this post


Link to post
Share on other sites
Zedna

There is known bug/limitation in Send/ControlSend with national keyboards, escpecially with Czech one.

One workaround is to switch keyboard to english then use Send/ControlSend and then switch it back.

More elegant solution in your example is to use COM commands for all desired actions instead of Send/ControlSend.

Search MSDN for Range/Copy/Paste and look at Excel.au3 sources to get idea

and instead of +{F11} use _ExcelSheetAddNew()

Edited by Zedna
  • Like 1

Share this post


Link to post
Share on other sites
Jos

Ничего не понял

We don't understand this,

oh wait... isn't that what you said too?

English please :)

  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
phanan

There is known bug/limitation in Send/ControlSend with national keyboards, escpecially with Czech one.

One workaround is to switch keyboard to english then use Send/ControlSend and then switch it back.

More elegant solution in your example is to use COM commands for all desired actions instead of Send/ControlSend.

Search MSDN for Range/Copy/Paste and look at Excel.au3 sources to get idea

and instead of +{F11} use _ExcelSheetAddNew()

Thanx for suggesting me about COM commands (this is first time i heard about this)

For MSDN, to select a cell we use: $oExcel.Application.ActiveSheet.Range("A1").Select

But how can we select all cell (juzt similar to Ctrl A)? Can u help me thix?

Share this post


Link to post
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
Sign in to follow this  

×