jugador Posted March 13, 2022 Posted March 13, 2022 @KhooYong Patch this with above code and run..... ;~ Method 4 ClipPut("a b c d ") $o_Workbook.ActiveSheet.Range("D4").Select Send("^v") ClipPut("")
KhooYong Posted March 13, 2022 Author Posted March 13, 2022 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. expandcollapse popup#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
jugador Posted March 14, 2022 Posted March 14, 2022 @KhooYong Can't comment as no such issue using ControlSend ControlSend("[CLASS:XLMAIN]", "", "", ClipGet() & "{ENTER}") Not sure about other option like _SendMessage and _WinAPI_PostMessage with $WM_PASTE may be MVP like @Nine and @Subz can help on this.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now