SomeNerd

Multi-Line Copy/Paste Macro?

4 posts in this topic

#1 ·  Posted

;Send the string $ss after the Shift Alt and Ctrl keys are released.  Otherwise Autoit makes them stuck >.<
Func _SendEx($ss, $raw = 0)
   While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
      Sleep(50)
   WEnd
   If($raw=1)Then
      Send($ss,1)
   Else
      Send($ss)
   EndIf
EndFunc;==>_SendE

HotKeySet("^+v", "SC2Pasta") ; Cntrl+Shift+V

Func SC2Pasta()
   Local $clipboard = ClipGet()
   if(Not @error)Then
      Local $lines = StringSplit($clipboard, '\n', 1)
      For $i = 1 To $lines[0]
         _SendEX("+{ENTER}");
         _SendEX($lines[$i],1);
         _SendEX("{ENTER}");
      Next
   EndIf
EndFunc

Hello!

SO I'm pretty new to autoit syntax, and am trying to create a copy/paste function for a game which does not support return carriages in a single message.

What I'm trying to accomplish is:
-Get contents of clipboard

-Break contents up into individual lines

-Send each line as a message one by one in a loop.

I'm using _SendEx rather than send as a workaround for the shift and control keys getting stuck in the down state.  Currently it ALMOST works.  The problem arises in the For loop.   Game requires shift+enter key to open chat to send to all players.  Right now, the first line will send shift+enter correctly and paste the appropriate line from the clipboard.  However, subsequent iterations through the loop are sending only the enter key, not the shift+enter key.  Why is this?

Thanks in advance

Share this post


Link to post
Share on other sites



#2 ·  Posted

4 minutes ago, SomeNerd said:

 However, subsequent iterations through the loop are sending only the enter key, not the shift+enter key.  Why is this?

Since I can't seem to edit my own post, I feel I should clarify this with a reply -.-

subsequent iterations through the loop send enter, the correct line of text from the clipboard, and enter again.  The problem is that shift is not being held for the preceding enter, resulting in the message being sent to the wrong place.  I want shift+enter, line, enter.

Share this post


Link to post
Share on other sites

#3 ·  Posted

Okay /Thread problem was the While condition in sendex.  That's what I get for using examples from a third party.

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

4 hours ago, SomeNerd said:

trying to create a copy/paste function for a game

Welcome to AutoIt and the forum!
Seems you missed to read the forum rules on your way in. Please do so now! You will notice that game automation of any kind is not permitted here.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.