Sign in to follow this  
Followers 0
xNeoX

Bug in String Split

16 posts in this topic

A flaw in a protocol program of mine is extremely annoying, now I ahbe here following the code of operation should be posted if it tests you'll remember her as soon as their shift with the right taste great writes a letter from that date will be capitalized until everything

it expresses left shift. But as soon the F1 button and the display text can be displayed properly what this is the reason?

#include <File.au3>
MsgBox(0,"Info","Hello write something in teh Editor then press F1 you will see in a Msg Box what you´v worte")
run ("notepad.exe")
$str="" 
$bs=StringSplit(", ,+,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W

,X,Y,Z,0,1,2,3,4,5,6,7,8,9,!,?,&,ä,ü,_,.",",") 
$i=1; 
Func e() 
    HotKeySet(@HotKeyPressed) 
    Send(@HotKeyPressed) 
    $str=$str&@HotKeyPressed 
    HotKeySet(@HotKeyPressed,"e") 
EndFunc 


While $i<=$bs[0] 
HotKeySet($bs[$i],"e") 
$i=$i+1; 
WEnd
HotKeySet ("{F1}","Test")
Func Test()
MsgBox (0,"Outpoot",$str)
endfunc
while 1 
sleep (999)
wend

Share this post


Link to post
Share on other sites



A flaw in a protocol program of mine is extremely annoying, now I ahbe here following the code of operation should be posted if it tests you'll remember her as soon as their shift with the right taste great writes a letter from that date will be capitalized until everything

it expresses left shift. But as soon the F1 button and the display text can be displayed properly what this is the reason?

#include <File.au3>
MsgBox(0,"Info","Hello write something in teh Editor then press F1 you will see in a Msg Box what you´v worte")
run ("notepad.exe")
$str="" 
$bs=StringSplit(", ,+,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W


,X,Y,Z,0,1,2,3,4,5,6,7,8,9,!,?,&,ä,ü,_,.",",") 
$i=1; 
Func e() 
    HotKeySet(@HotKeyPressed) 
    Send(@HotKeyPressed) 
    $str=$str&@HotKeyPressed 
    HotKeySet(@HotKeyPressed,"e") 
EndFunc 


While $i<=$bs[0] 
HotKeySet($bs[$i],"e") 
$i=$i+1; 
WEnd
HotKeySet ("{F1}","Test")
Func Test()
MsgBox (0,"Outpoot",$str)
endfunc
while 1 
sleep (999)
wend

It is not bug, it just your syntax miss.

Read first to 'send' section in help file.

You could read to process keystroke '+'.

Share this post


Link to post
Share on other sites

This tells AutoIt to send a SHIFT keystroke, therefore Send("Hell+o") would send the text "HellO". Send("!+a") would send "ALT+SHIFT+a".

this?^^ im german so my english is not the best how can i fix this mistake?

Share this post


Link to post
Share on other sites

no thats just a part from the help files my problem is in the first poste

Share this post


Link to post
Share on other sites

^^ sobald man mit der rechten shift taste einen buchstaben groß schreibt wird ab diesem Zeitpunkt alles groß geschrieben bis man die linke shift taste drückt (in der msg box wird alles richtig dargestellt) du kannst es mal testen sollte zu starten sein

Share this post


Link to post
Share on other sites

I don't see the problem with StringSplit...the leading comma in your string will result in a blank element in your array (not a space).

$bs=StringSplit(', ,+,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,!,?,&,ä,ü,_,.',',')
For $X = 1 to $bs[0]
    ConsoleWrite($bs[$X] & @CRLF)
Next

Share this post


Link to post
Share on other sites

^^ sobald man mit der rechten shift taste einen buchstaben groß schreibt wird ab diesem Zeitpunkt alles groß geschrieben bis man die linke shift taste drückt (in der msg box wird alles richtig dargestellt) du kannst es mal testen sollte zu starten sein

Problem is, from the moment you press the right shift key all letters are capitalized until you press the left shift key (even then some are still capital)... Will look into it... nun sehe ich das Problem :), schaus mir mal an...

Gruß

Share this post


Link to post
Share on other sites

but why is caps lock active when i press RShift? in the box whitch is showen if i press F1 everything is right formated

Share this post


Link to post
Share on other sites

Push.... nobody any idea? q.q

Share this post


Link to post
Share on other sites

but why is caps lock active when i press RShift? in the box whitch is showen if i press F1 everything is right formated

It's a common problem with Send() command being executed when certain other keys, CTRL. ALT, (right) SHIFT key is held down.

Using a Send() replacement that martin devised, this should work:

#include <File.au3>
#include <misc.au3>

MsgBox(0,"Info","Hello write something in teh Editor then press F1 you will see in a Msg Box what you´v worte")
$pid = run ("notepad.exe")
$str=""
$bs=StringSplit(", ,+,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W

,X,Y,Z,0,1,2,3,4,5,6,7,8,9,!,?,&,ä,ü,_,.",",")

$i=1;

Func e()
    HotKeySet(@HotKeyPressed)
    ConsoleWrite(@HotKeyPressed & @crlf)
        _SendEx(@HotKeyPressed)
    $str=$str&@HotKeyPressed
    HotKeySet(@HotKeyPressed,"e")
EndFunc


While $i<=$bs[0]
HotKeySet($bs[$i],"e")
$i=$i+1;
WEnd
HotKeySet ("{F1}","Test")
Func Test()
MsgBox (0,"Outpoot",$str)
endfunc

While ProcessExists($pid)
  sleep (999)
WEnd

Func _SendEx($ss,$warn = "")
;http://www.autoitscript.com/forum/index.php?s=&showtopic=37289&view=findpost&p=512706
;by martin
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

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

hi thank you verry mutch no it works but can you explain the function _SendEx a bit ? Ididnt understand what _isPressed ("10) or..... is for.

another thing i noticed if you press lshift or rshift in combo with a key there is no outpoot until you stop pressing shift key

Edited by xNeoX

Share this post


Link to post
Share on other sites

Hi xNeoX,

in fact i did look into this a bit more... without coming up with a solution.

The _ispressed() UDF is a user32.dll call (low level check) and checks if SHIFT, ALT or CTRL (10,11,12) are pressed and waits until they are not pressed before performing the send()...

Regards

Share this post


Link to post
Share on other sites

ok thx is it possible to cancel this that any key i pressed in combo with shift is outpoot instantly? and do´nt wait for an "dont press shift"?

Share this post


Link to post
Share on other sites

ok thx is it possible to cancel this that any key i pressed in combo with shift is outpoot instantly? and do´nt wait for an "dont press shift"?

You can send a key dependending on any combination you like. The problem with Send can be that it doesn't allow for the state of a modifier key to change after the Send starts and before the Send finishes. If you have this

HotKeySet("+k","ff1")
HotKeySet("{ESC}","quit")
while 1
    sleep(50)
WEnd
func ff1()
    send("asdfghjklqwertyu")
EndFunc

func quit()
    Exit
EndFunc

If you release the shift key quickly after pressing 'k' the shift will stay locked down until you press and release it again.

As long as you understand what goes wrong and in what circumstances then you can work around it.


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.

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  
Followers 0