Jump to content

LEFT Alt get stuck on script


Recommended Posts

hey guys ,

I started a script , and now the script is done im stuck with the alt key , sometimes the script runs totaly fine .... but some others it just stucks.... like i need to Alt+f+e and the next thing the script does is keep pressing alt like if it there was someone pressing it... like if i make "shiftdown" without making shiftup.....

Ive tryed the follow examples.

send("!")

sleep(200)

send("f")

sleep(200)

send("e")

or

send("!f")

sleep(200)

send("e")

Still does the same thing... its not always... its random.....

Any ideas ?

Link to comment
Share on other sites

ohhh thanks guys so correct me if im wrong... all i have to do is past the followed Code into the beggin of the script ?

#include "MISC.au3"
;Send the string $ss after the Shift Alt and Ctrl keys are released. Optionally give a warning after 1 sec if any of those keys still down.
;Requires misc.au3 to be included in the script for the _IsPressed function.
Func _SendEx($ss,$warn = "")
    Local $iT = TimerInit()
    
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
        if $warn <> "" and TimerDiff($iT) > 1000 Then
            MsgBox(262144, "Warning", $warn)
        EndIf
      sleep(50)
    WEnd
    Send($ss) 
    EndFunc;==>_SendEx
Link to comment
Share on other sites

  • 2 weeks later...

Ive been away and only now had a chance to get it working.

But unfortunately it keeps happening randomly but when it happens it wasn't supposed to get a message box ?

i replaced all the alt , ctrl and shiftup & downs ,could it be because its doing it to fast ?

Thanks all for your support

Link to comment
Share on other sites

  • 3 weeks later...

I'm having a similar problem with the _SendEx function's message box. I found myself not getting the message box with the following code (And, yes, I built the code to specifically test the _SendEx out before I place it in my major scripts):

#Include <Misc.au3>

;##### Sticky mod key fix #####
Func _SendEx($ss)
    Local $iT = TimerInit()
    
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
        If TimerDiff($iT) > 100 Then
            MsgBox(262144, "Warning", "Shift, Ctrl and Alt Keys need to be released to proceed!")
        EndIf
    WEnd
    Send($ss)
    
EndFunc ;==>_SendEx

;###### End Sticky mod key fix #####

Run("notepad.exe")
WinWaitActive("Untitled")
_SendEx("hi how are you?")
_SendEx("^a")
_SendEx("^c")
_SendEx("{DEL}")
_SendEx("{CTRLDOWN}v")

It did work, however, when I added another line after the CTRLDOWN line:

#Include <Misc.au3>

;##### Sticky mod key fix #####
Func _SendEx($ss)
    Local $iT = TimerInit()
    
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
        If TimerDiff($iT) > 100 Then
            MsgBox(262144, "Warning", "Shift, Ctrl and Alt Keys need to be released to proceed!")
        EndIf
    WEnd
    Send($ss)
    
EndFunc ;==>_SendEx

;###### End Sticky mod key fix #####

Run("notepad.exe")
WinWaitActive("Untitled")
_SendEx("hi how are you?")
_SendEx("^a")
_SendEx("^c")
_SendEx("{DEL}")
_SendEx("{CTRLDOWN}v")
_SendEx("{SPACE} I work... I think")

Why is the second example making the warning pop up while the first example is sans warning?

Link to comment
Share on other sites

I'm having a similar problem with the _SendEx function's message box. I found myself not getting the message box with the following code (And, yes, I built the code to specifically test the _SendEx out before I place it in my major scripts):

#Include <Misc.au3>
   
;##### Sticky mod key fix #####
   Func _SendEx($ss)
       Local $iT = TimerInit()
       
       While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
           If TimerDiff($iT) > 100 Then
               MsgBox(262144, "Warning", "Shift, Ctrl and Alt Keys need to be released to proceed!")
           EndIf
       WEnd
       Send($ss)
       
   EndFunc;==>_SendEx
   
;###### End Sticky mod key fix #####
   
   Run("notepad.exe")
   WinWaitActive("Untitled")
   _SendEx("hi how are you?")
   _SendEx("^a")
   _SendEx("^c")
   _SendEx("{DEL}")
   _SendEx("{CTRLDOWN}v")

It did work, however, when I added another line after the CTRLDOWN line:

#Include <Misc.au3>
   
;##### Sticky mod key fix #####
   Func _SendEx($ss)
       Local $iT = TimerInit()
       
       While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
           If TimerDiff($iT) > 100 Then
               MsgBox(262144, "Warning", "Shift, Ctrl and Alt Keys need to be released to proceed!")
           EndIf
       WEnd
       Send($ss)
       
   EndFunc;==>_SendEx
   
;###### End Sticky mod key fix #####
   
   Run("notepad.exe")
   WinWaitActive("Untitled")
   _SendEx("hi how are you?")
   _SendEx("^a")
   _SendEx("^c")
   _SendEx("{DEL}")
   _SendEx("{CTRLDOWN}v")
   _SendEx("{SPACE} I work... I think")

Why is the second example making the warning pop up while the first example is sans warning?

Because the first example has

_SendEx("{CTRLDOWN}v")

as the last line. When the function is called the control key, shift key and Alt keys are not down so the function proceeds to the line where it calls Send with the passed parameter which in this case is to hold down the Ctrl key and press v.

When you then add another Send request the Ctrl key is already down, so the functoion waits a certain time then pops up the warning message.

The _SendEx function is no use if you have previously held down one of the modify keys because it is designed to wait until they are released.

The _SendEx function is to get round the problem that occurs when you have a HotKey combination, such as !G say, and the function called uses Send. In these cases Send can start sending characters before the user has released the Alt key, but the Alt key might well be released by the time that Send has finished and that is when the Alt key gets 'stuck'.

I'll add a note to the sticky to point this out to people.

BTW your version of _SendEx is missing a parameter, it must be a very old version or maybe copied from a post and not fromn the sticky.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks for answering my question so quickly, martin! I think I have a better understanding of _SendEx now. I've been running into the modify key sticking problem for the hotkeys that are called using Send and found the _SendEx solution in the FAQ. I hope that _SendEx will get rid of that problem so I don't have panicked employees coming after me saying their computer froze up while using the scripts.

*crosses fingers*

Edit - yes, I've actually swiped that version from another post and must of not replaced it with the newer version before posting the example code... sorry.

Edited by yolib
Link to comment
Share on other sites

... all i have to do is past[e] the follow[ing]ed Code into the beggin[g] of the script? ...

Minor point, while User Defined Functions (UDF) can be placed at the beginning, middle or end of a script; placing them at the end is most common and easier to read IMO. See the help file under the key word Default for a sample script that places the UDF at the end.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...