Jump to content

Recommended Posts

Posted

Hi jugador,

Thanks. As my script works behind lock screen, send("^v") is out of selection . I also tried ControlSend  but using ctrl-v or shift-paste does not seems to work.

Strangely . When I put Send Command  before ControlSend Command  , both seems to work. Unfortunately , if you only use ControlSend by itself or put it before Send , it stop working. 

Hence I re-arrange Send("^v") to be Method 5 instead. Perhaps this is a clue to why it is behaving so strangely. 

 

#include <Excel.au3>
#include <Array.au3>
Global $oHandler = ObjEvent("AutoIt.Error", ErrFunc)
__Method1()
Func __Method1()
    Local $o_Excel = _Excel_Open()
    If @error Then Exit

    Local $o_Workbook = _Excel_BookNew($o_Excel, 1)
    If @error Then
        _Excel_Close($o_Excel)
        Exit
    EndIf

    ;~ Method 1
    ClipPut("a    b    c    d    ")
    _Excel_RangeWrite($o_Workbook, Default, ClipGet(), "A1")
    ClipPut("")

    ;~ Method 2
    ClipPut("a    b    c    d    ")
        $o_Workbook.ActiveSheet.Range("A2").PasteSpecial
    ClipPut("")

    ;~ Method 3
    ClipPut("a    b    c    d    ")
    $o_Workbook.ActiveSheet.Range("A3").Select
    $o_Workbook.ActiveSheet.paste
    ClipPut("")

   ;~ Method 4
   ClipPut("a    b    c    d    ")
   $o_Workbook.ActiveSheet.Range("A4").Select
    ControlSend("[CLASS:XLMAIN]","","","{CTRLDOWN}" & "v" & "{CTRLUP}")
    ClipPut("")

   ;~ Method 5
    ClipPut("a    b    c    d    ")
    $o_Workbook.ActiveSheet.Range("A5").Select
    Send("^v")
    ClipPut("")

    MsgBox(0, "", "Click to continue.....")
    _Excel_BookClose($o_Workbook, False)
    _Excel_Close($o_Excel)
    Exit
 EndFunc

 Func ErrFunc($oError)
    MsgBox($MB_OK, "We intercepted a COM Error !", _
            "Number: 0x" & Hex($oError.number, 8) & @CRLF & _
            "Description: " & $oError.windescription & _
            "At line: " & $oError.scriptline & @CRLF)
EndFunc   ;==>ErrFunc

 

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
×
×
  • Create New...