Jump to content

Strange Hotkeyset problem


Recommended Posts

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

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

Link to comment
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 :(
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...