Jump to content
Sign in to follow this  
WoodGrain

Send Raw is driving me INSANE - What am I doing wrong or is this a bug?

Recommended Posts

WoodGrain

Hi All,

Could someone please PLEASE tell me what I'm doing wrong here?
I feel like I'm close to figuring this out, I think I've identified what is causing the issue.

Whenever I try to use the hotkey CTRL+SHIFT+T (or any other letter other than T for that matter) to paste the text to notepad, my CTRL and SHIFT keys are held down *IF* I release them *WHILE* the raw text is being written.

It seems to be that if I release the CTRL+SHIFT keys:

  • Before the Send Raw text starts to write to the screen: the CTRL and SHIFT keys ARE NOT held down, this is good
  • During the Send Raw text being written to the screen: the CTRL and SHIFT keys ARE held down perpetually until I physically press them on the keyboard, this is bad
  • After the Send Raw text has written all text to the screen: the CTRL and SHIFT keys ARE NOT held down, this is good

This is also the case if I were to use the Windows Key as the hot key instead of the CTRL+SHIFT, I would need to tap the WIN key physically on my keyboard if I released it while the raw tet was being sent to the screen (eg, WIN+T).

This issue also happens no matter which program I try to write the text to.

Here's some example code:
(I've put a bunch of "a's" in there to give enough time to test releasing the CTRL+SHIFT before/during/after the writing of them)

HotKeySet("^+t", "WriteTxt")

Func WriteTxt()
   WinWaitActive("Untitled - Notepad")
   $var = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
   send($var, 1)
EndFunc

While 1
   Sleep(500)
WEnd

Thanks guys!

Share this post


Link to post
Share on other sites
SadBunny

I can reproduce, but only the first time I use the hotkey after the script start. If I then press CTRL+SHIFT once it jiggles it loose and everything is fine again, after that the hotkey works fine. These kinds of problems happen often when combining hotkeys and send functions.

Problem seems to go away if I do what I always do with hotkey functions: un-set the hotkey when entering the function, then re-set it when it's done:

HotKeySet("^+t", "WriteTxt")

Func WriteTxt()
    HotKeySet("^+t")
    WinWaitActive("Untitled - Notepad")
    $var = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    Send($var, 1)
    HotKeySet("^+t", "WriteTxt")
EndFunc   ;==>WriteTxt

While 1
    Sleep(500)
WEnd

 


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
WoodGrain

Thanks SB!

I have found it to repeat on 2 computers I've used, but randomly.

Very interesting, I will try your suggestion to un-set/re-set - thanks!

Share this post


Link to post
Share on other sites
WoodGrain

Hmm, nope, same issue, after releasing the hotkey and re-setting it.
If I release the CTRL+SHIFT keys *while* the text is being written it still hold them down :(

Share this post


Link to post
Share on other sites
SadBunny

Yeah, it's just not all that reliable, which is why in every topic where send comes up as a means to automation, people suggest to try and find another way to automate.

As an added precautionary measure against conflicts, you could (should, IMHO :) ) also always make theese functions wait until you release all keys in the combo. Especially when you combine stuff with Send. So in this case:

#include <Misc.au3>

HotKeySet("^+t", "WriteTxt")

Func WriteTxt()
    HotKeySet("^+t")
    While _IsPressed(10) Or _IsPressed(11) Or _IsPressed(54) ; <-- wait as long as any key of the ^+t combo is still pressed
        Sleep(10)
    WEnd
    WinWaitActive("Untitled - Notepad")
    $var = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    Send($var, 1)
    HotKeySet("^+t", "WriteTxt")
EndFunc   ;==>WriteTxt

While 1
    Sleep(500)
WEnd

 

  • Like 1

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
WoodGrain

Oh, that's very helpful, thanks!
Trying again...

Share this post


Link to post
Share on other sites
WoodGrain

WINNER!!!
Thanks SB!

Obviously they can press the keys again while the text is being written, but that is extremely unlikely (tho I've found it is amazing what ppl can accomplish).

BTW, you mentioned "people suggest to try and find another way to automate", within AutoIT or via other programming?

Share this post


Link to post
Share on other sites
SadBunny

Cool :) 

2 minutes ago, WoodGrain said:

BTW, you mentioned "people suggest to try and find another way to automate", within AutoIT or via other programming?

It's mostly to do with things like pressing tab five times to get to a button, while there's also things like ControlSend or ControlClick etc. to directly interact with a control which is much more reliable and much less prone to accidental conflicts with the user.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
SadBunny
7 minutes ago, WoodGrain said:

Obviously they can press the keys again while the text is being written

Well, they could press it, but that's exactly why I unset the hotkey at the beginning of the function and then reset it at the end - while the function is running, the hotkey won't work, and the Send command halts the script until it is done (try adding opt("SendKeyDelay", 50) on top of your script to see it clearly - use the hotkey during the aaaa... sending and it won't do anything until the send is complete).


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
WoodGrain

Oh, I mean they could press and release CTRL and/or SHIFT while the send raw is writing, disregarding the full CTRL+SHIFT+T combination, this causes the key(s) to be pressed down indefinitely.

Share this post


Link to post
Share on other sites
SadBunny

Well, if it's about notepad or anything else using easy-to-automate windows controls, something like this would not be affected by ctrl/shift being held down:

ControlSend("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]", "some text to send")

 


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
JustSomeone

My 2 cents while reading this:

Autoit options SendKeyDelay and SendKeyDownDelay should be checked when using send(). Some programs do require a bit (say 50 ms down and 30 between keys) more time so they register an actual button being pressed. If you send for example "someverylongstring" you may end up with "smeerylongstrng" or similar. Again , it really depends to what program you are sending text/buttons etc :)

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  

  • Similar Content

    • Fortitude
      By Fortitude
      Hello!
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
       
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
    • Docfxit
      By Docfxit
      I would like to know if there is a way to make the send cmd send characters when using
      Graphical AutoIt Debugger By Stumpii,
      If Not WinActive("Setup - UltraVNC","Setup is preparing to install") Then WinActivate("Setup - UltraVNC","Setup is preparing to install") WinWaitActive("Setup - UltraVNC","Setup is preparing to install") Send("{ALTDOWN}f{ALTUP}") ;Finish The debugger when using step mode will execute the Send cmd line but the window doesn't receive the input.
      Thanks,
      Docfxit
    • dadalt95
      By dadalt95
      Hi!
      I want to get the signal in this website:
      https://binary-signal.com/pt/chart/eurusd
      I have tried using _IEBodyReadText  and some _StringBetween. What happens is that the text are being update every tick and _IEBodyReadText doesn't.
      To perform the update I used  _IEAction($oIE, "refresh") but it's not good because the website block me after some time due too many requests..
      Is there any other way to get this text every tick?
      PS: The text I want to get is WAIT, CALL or PUT.
       
      Here is the code:
      global $oIE = _IECreate ('https://binary-signal.com/pt/chart/eurusd', 0, 1 , 1 , 0) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') ;MsgBox ( 0, "asf", $result[0]) $espera=StringInStr($result[0], "WAIT") $compra=StringInStr($result[0], "CALL") $venda=StringInStr($result[0], "PUT") ;MsgBox($MB_SYSTEMMODAL, "", $espera) $n=0 $c=0 Captar() Func Captar() ;_IENavigate($oIE, "https://binary-signal.com/pt/chart/eurusd") ;MsgBox($MB_SYSTEMMODAL, "", $n) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') If (Not $compra=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "COMPRE") $n=1 $c=$c+1 ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "VENDA") $c=$c+1 $n=1 ;_IEAction($oIE, "refresh") ;MsgBox($MB_SYSTEMMODAL, "", $n) Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() Else ;MsgBox("", "", "ESPERE") $n=0 Sleep(1000) ;_IEAction($oIE, "refresh") Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') Captar() EndIf EndFunc  
    • PoojaKrishna
      By PoojaKrishna
      Hi friends,
      I'm trying to send SHIFTDOWN, to keep the Shift key pressed until I close the program or releases the key.
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key manually and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down Agin", "Shift key is pressed again, now type something: ") In the above program sequence,
      1. Send SHIFTDOWN from program, Works as we type in the text are in Capital letters
      2. Manually presses and releases the SHIFT button. SHIFT key is released as when we type, text is in small letters only.
      3. Again send SHIFTDOWN from program, but not working. When we type the letters are in small letters.
       
      If we send a SHIFTUP  before  sending the SHIFTDOWN again, then it is working correctly and the text appears in capital letters only. Can any one explain why this happens?
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTUP}") sleep(100) Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is pressed, now type something: ")  
      Thank you.
    • TheDcoder
      By TheDcoder
      Hello everyone, long time since I made a post in the H&S sub-forum
      I am working on a project where in a situation I would have to hold down an arrow key and release it in another statement/command, however when I wrote the code it isn't working exactly like I thought it would. Here is an example:
      Send("{UP down}") Sleep(10000) Send("{UP up}") This should hold the up arrow key for 10 seconds before releasing it again, but when I run this code the cursor in SciTE moves up only once
      If I hold the up arrow manually for 10 seconds it "repeats" and the cursor moves up several times until I release the key... Is this a known limitation of Send? Is there any other way I can accomplish this?
      Thanks for all the help and feedback in advance! TD
×