Sign in to follow this  
Followers 0
Wb-FreeKill

Strange Hotkeyset problem

5 posts in this topic

Im trying to make a simple program witch when some keystroke is pressed, writing a sentence no matter what is pressed..

But sometimes when pressing "a" it runs the func two times.. "b" does the same

Try this out:

#include <GUIConstants.au3>

HotKeySet ( "a" , "_a")
HotKeySet ( "b" , "_b" )

Global $Count = 1

GUICreate("GUI",500,500)
GUICtrlCreateEdit("",5,5,490,470)
$Label = GUICtrlCreateLabel("0",10,480,100,20)

GUISetState()
$InputBox = InputBox("Intelligent WordPad","Input sentence here..","I am an idiot")
If @Error Then Exit



While 1
    $msg = GUIGetmsg()
Select  
    
    Case $msg = $GUI_EVENT_CLOSE 
        Exit

EndSelect
WEnd    

Func _a()
HotKeySet ( "a")    
_write()
HotKeySet ( "a" , "_a" )
EndFunc

Func _b()
HotKeySet ( "b")
_Write()
HotKeySet ( "b" , "_b" )
EndFunc

Func _Write()
    $SenLen = StringLen($InputBox)
    $SplitSen = StringSplit($InputBox,"")
    
    If $Count-1 = $SenLen Then
    ;Done writing
    Else    
        Send($SplitSen[$Count])
        $Count = $Count + 1
        GUICtrlSetData($Label,$Count)
        Msgbox(0,"",$Count)
    EndIf   
EndFunc

Share this post


Link to post
Share on other sites



Is this what you are wanting? I am not quite sure what you are getting at. Also make sure you initiate the HotKeySet after the InputBox or people cant type in it.

#include <GUIConstants.au3>

Global $Count = 1

GUICreate("GUI",500,500)
GUICtrlCreateEdit("",5,5,490,470)
$Label = GUICtrlCreateLabel("0",10,480,100,20)

GUISetState()
$InputBox = InputBox("Intelligent WordPad","Input sentence here..","I am an idiot")
If @Error Then Exit

HotKeySet ( "a" , "_a")
HotKeySet ( "b" , "_b" )

While 1
    $msg = GUIGetmsg()
Select  
    
    Case $msg = $GUI_EVENT_CLOSE
        Exit

EndSelect
WEnd    

Func _a()
HotKeySet ( "a")    
_write()
HotKeySet ( "a" , "_a" )
EndFunc

Func _b()
HotKeySet ( "b")
_Write()
HotKeySet ( "b" , "_b" )
EndFunc

Func _Write()
    $SenLen = StringLen($InputBox)
    $SplitSen = StringSplit($InputBox,"")
    
    While 1
        If $Count-1 = $SenLen Then
            ExitLoop
        Else    
            Send($SplitSen[$Count])
            $Count = $Count + 1
            GUICtrlSetData($Label,$Count)
            Msgbox(0,"",$Count)
        EndIf
    WEnd
EndFunc

I am not sure I understood your wants. Also check into _IsPressed() function by Ezzetabi.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Hmm not actually what i wanted.. what you did, when pressing a button, is write the word. I want that no mater witch button is pressed, it have to write the next letter in the sentence..

Share this post


Link to post
Share on other sites

Okay so you want to basically capture every key on the keyboard and when any key is pressed it makes the next character in the string show up? I would say you are going to need _IsPressed() for that, but we will see what we can do. Give me a bit and I will come up with something.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Okay so you want to basically capture every key on the keyboard and when any key is pressed it makes the next character in the string show up? I would say you are going to need _IsPressed() for that, but we will see what we can do. Give me a bit and I will come up with something.

JS

<{POST_SNAPBACK}>

Great thanks! ill see what ur come up with :(

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