0manko Posted February 6, 2016 Share Posted February 6, 2016 Hello, I'm currently working on a project which include a bot that will reply and do stuff for me through FB messenger. I got most of the stuff working fine buti'm giving up trying to do line break via CTRL+enter / Shift+enter via controlsend So here's the problem in facing : I've tried several methods with controlsend and i got no luck, the {shift} doesn't seem to work with {enter} key, instead of going nextline it just send the line as if the shift key was never pressed. Here are some of the different code i tried none of it make a different, all failed. expandcollapse popupfunc newline() ControlFocus($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ControlClick($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "", "", 0, 0) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line one",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "^{Enter}") Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line two",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "^{Enter}") Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line three",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") EndFunc func newline2() ControlFocus($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ControlClick($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "", "", 0, 0) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line one",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{LSHIFT}{Enter}") Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line two",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{LSHIFT}{Enter}") Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line three",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") EndFunc func newline3() ControlFocus($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ControlClick($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "", "", 0, 0) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line one",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{SHIFTDOWN}") Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{SHIFTUP}") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line two",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{SHIFTDOWN}") Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{SHIFTUP}") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "line three",1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") EndFunc I've also tried making a notepad file of multiple line and copy to clipboard then controlsend paste it, but instead of having 3 sentence i'm getting one long sentence. The only way i get to make anewline is through On Screen Keyboard with Shift + Enter or pressing manually typing it buti hope that there's some simpler way to achieve it with controlsend. CTRL+Enter will also make a new line but I can't get it to work either ... Link to comment Share on other sites More sharing options...
Jfish Posted February 6, 2016 Share Posted February 6, 2016 You are sending three lines ... you want to format your string to use multiple lines. Look at this: $multiLineString="Line One" & @crlf & _ "Line 2" & @crlf & _ "Line 3" MsgBox(0,'multiline',$multiLineString) Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
0manko Posted February 7, 2016 Author Share Posted February 7, 2016 Thanks Jfish, i've tried your method and it still did not produce the result i was hoping for, instead of sending 3 continuous lines i got 3 separate lines, the best way i could achieve it is still using CTRL+enter style which i failed to do so func newline4() ControlFocus($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ControlClick($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "", "", 0, 0) $multiLineString="Line One" & @crlf & _ "Line 2" & @crlf & _ "Line 3" ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $multiLineString,1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{enter}") EndFunc Link to comment Share on other sites More sharing options...
0manko Posted February 7, 2016 Author Share Posted February 7, 2016 Thanks Jfish, i've tried your method and it still did not produce the result i was hoping for, instead of sending 3 continuous lines i got 3 separate lines, the best way i could achieve it is still using CTRL+enter style which i failed to do so func newline4() ControlFocus($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ControlClick($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "", "", 0, 0) $multiLineString="Line One" & @crlf & _ "Line 2" & @crlf & _ "Line 3" ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $multiLineString,1) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{enter}") EndFunc Link to comment Share on other sites More sharing options...
Jfish Posted February 7, 2016 Share Posted February 7, 2016 @CRLF is a carriage return with a line feed. @CR is just a carriage return. Try @CR instead. I am not sure what triggers a new line in FB messenger but so some research to figure out how you need to format your string. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
0manko Posted February 9, 2016 Author Share Posted February 9, 2016 Once again same result, i've tried alot of method but none of it trigger line break. Any other suggestion to make linebreak/ctrl+enter to work ? Link to comment Share on other sites More sharing options...
JohnOne Posted February 9, 2016 Share Posted February 9, 2016 Analyze a multiline string copied from the app, to determine which char is used for end of line. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
0manko Posted February 9, 2016 Author Share Posted February 9, 2016 32 minutes ago, JohnOne said: Analyze a multiline string copied from the app, to determine which char is used for end of line. Thanks for the suggestion,it seems that this may actually work. Is there any easy method i can used to analyze the string ? i saved the multiline text from the FB messenger to the notepad, after that i copy and paste back everything in the notepad and the linebreak remains in the messenger. But soon after i add another line using enter in the notepad everything clump into a sentence back instead of multiline. I'm assuming that there's a linebreak element in there and is there anyway to determine and replicate it? Link to comment Share on other sites More sharing options...
0manko Posted February 9, 2016 Author Share Posted February 9, 2016 (edited) Update: Things are getting weird again, so i copied and paste the same thing from the messenger, to the notepad, then back to the messenger again and it works perfectly. But once i added something in between the text it paste it again it went to one full straight line anyidea what's happening ? Edited February 9, 2016 by 0manko accidental copy/paste Link to comment Share on other sites More sharing options...
JohnOne Posted February 9, 2016 Share Posted February 9, 2016 Copy the text from the app to clipboard. $aSplit = StringSplit(ClipGet(), "") For $char In $aSplit ConsoleWrite(Asc($char) & @CRLF) Next What you get? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
0manko Posted February 9, 2016 Author Share Posted February 9, 2016 3 minutes ago, JohnOne said: Copy the text from the app to clipboard. $aSplit = StringSplit(ClipGet(), "") For $char In $aSplit ConsoleWrite(Asc($char) & @CRLF) Next What you get? line one line two line three 51 108 105 110 101 32 111 110 101 13 10 108 105 110 101 32 116 119 111 13 10 108 105 110 101 32 116 104 114 101 101 13 10 13 10 Link to comment Share on other sites More sharing options...
JohnOne Posted February 9, 2016 Share Posted February 9, 2016 That suggests that @CR is used for new line... Quote CR 13 0d 015 Carriage Return From help file AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted February 9, 2016 Share Posted February 9, 2016 Try $multiLineString="Line One" & Chr(13) & "Line 2" & Chr(13) & "Line 3" AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
0manko Posted February 9, 2016 Author Share Posted February 9, 2016 I've tried controlsend, clipput, both failed :/ Btw i'm using IE with the URL https://www.messenger.com/ and inspect element did not help much, their HTML are really weird Link to comment Share on other sites More sharing options...
JohnOne Posted February 9, 2016 Share Posted February 9, 2016 And the above string? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
0manko Posted February 9, 2016 Author Share Posted February 9, 2016 1 minute ago, JohnOne said: And the above string? i'm using this $multiLineString="Line One" & Chr(13) & "Line 2" & Chr(13) & "Line 3" and just edited abit into my code func copytoclip() $multiLineString="Line One" & Chr(13) & "Line 2" & Chr(13) & "Line 3" ClipPut($multiLineString) EndFunc Func testsend() $multiLineString="Line One" & Chr(13) & "Line 2" & Chr(13) & "Line 3" ControlFocus($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ControlClick($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "", "", 0, 0) Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $multiLineString) sleep (100) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") EndFunc Link to comment Share on other sites More sharing options...
0manko Posted February 9, 2016 Author Share Posted February 9, 2016 Update: this is getting even more confusing ...... This code copy and paste it like normal CTRL+V and it works fine: Func Test1 () $aSplit = ClipGet() Sleep (200) ControlFocus($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ControlClick($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "", "", 0, 0) Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "^v") sleep (100) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") EndFunc This send text using controlsend and it goes to separate line (both clipboard hold the same stuff i just copied a moment ago): Func Test2 () $aSplit = ClipGet() Sleep (200) ControlFocus($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ControlClick($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "", "", 0, 0) Sleep(250) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $aSplit) sleep (100) ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") EndFunc Is there anyway to just make ctrl+Enter/Shift+enter to work Link to comment Share on other sites More sharing options...
0manko Posted February 13, 2016 Author Share Posted February 13, 2016 Final update, i finally got this solved I can finally triggered a new line with this simple code, not sure why controlsend() failed to do {ctrl/shift} but just using send() works Send("{CTRLDOWN}") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") Send("{CTRLUP}") JohnOne 1 Link to comment Share on other sites More sharing options...
JohnOne Posted February 13, 2016 Share Posted February 13, 2016 Weird. Well done. 0manko 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
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