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

    • BetaLeaf
      By BetaLeaf
      As the title says, when a script that is stored on a Google Drive File Stream drive is ran or compiled, it fails to work at all.
      Basically, Google Drive File Stream creates a G:\ drive where you can access all your files. The difference between this and Google Backup and Sync is your files are downloaded as needed rather than they always be downloaded and taking up storage. 
      How to Reproduce Bug
      1. Download and Install Google Drive File Stream
      2. Sign into Google Drive File Stream with a G Suite account. 
      3. Create a AutoIt Script and save it to Google Drive File Stream. (See attached file)
      4. Attempt to run or compile this AutoIt Script. 
       
      AutoIt appears to act like the script is (incorrectly) empty and ends immediately. (You can kind of tell based on file sizes from a successful and failed compile).
      I've also attached a Process Monitor log file. Hopefully someone can figure this out, because having to move the script out of the drive just to run or compile it is super annoying and I lose version revisioning Google Drive provides me.
      test.au3
      Logfile.PML
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • ternal
      By ternal
      Hi,
      The FAQ proposed as a solution to keys getting stuck  to do this command
      ControlSend("", "", "", "text", 0) However this sends "text" to the last active control if I am not mistaken.I have tried this with
      controlsend("", "", "", "{altup}{shiftup}{ctrlup}", 0) This is already a lot better but still fails 1/10
      I cannot allow the script to send "text" to the last active control, and its a bit silly to let it send to somewhere where its harmless no?
      Are there any other methods of unstucking keys?
    • 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
×