pokwuk Posted April 7, 2009 Share Posted April 7, 2009 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 More sharing options...
monoceres Posted April 8, 2009 Share Posted April 8, 2009 Hi and welcome to the forums.This issue has been discussed several times before, martin even added it to the faq (stickied in this forum).#512706 Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
TerarinK Posted April 8, 2009 Share Posted April 8, 2009 Send("!fe") This send Alt plus "fe" 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E Link to comment Share on other sites More sharing options...
pokwuk Posted April 10, 2009 Author Share Posted April 10, 2009 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 More sharing options...
RobertBedrosian Posted April 10, 2009 Share Posted April 10, 2009 (edited) You also need to replace your Send commands with _SendEx when you use the Alt, Shift, or Ctrl keys. For example, if you coded Send("!{b}") replace it with _SendEx("!{b}") Edited April 10, 2009 by RobertBedrosian Link to comment Share on other sites More sharing options...
pokwuk Posted April 23, 2009 Author Share Posted April 23, 2009 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 More sharing options...
yolib Posted May 13, 2009 Share Posted May 13, 2009 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 More sharing options...
martin Posted May 13, 2009 Share Posted May 13, 2009 (edited) 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 May 13, 2009 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 More sharing options...
yolib Posted May 13, 2009 Share Posted May 13, 2009 (edited) 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 May 13, 2009 by yolib Link to comment Share on other sites More sharing options...
herewasplato Posted May 13, 2009 Share Posted May 13, 2009 ... 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 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