Sign in to follow this  
Followers 0
sd333221

HotKeySet("", "") <- Help

8 posts in this topic

#1 ·  Posted (edited)

In my script i got this

->  HotKeySet("A", "laugh")

Func laugh()
MsgBox(4096, "Hahaha", "Hahahaha", 10)
EndFunc

But i want my computer still to recognice that the key A was pressed,

when i am in word and i type A with the script running the MsgBox appears

but he doesn't write A. I tried this

->  HotKeySet("A", "laugh")

Func laugh()
MsgBox(4096, "Hahaha", "Hahahaha", 10)
Send("A")
EndFunc

but it doesn't work.

I need ur help guys.

Thanks for ur answers!

PS: I get this Error: Recursion level has been exceeded - AutoIT will quit to prevent stack overflow.

Edited by sd333221

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

may help...

AdlibEnable('_CheckAPressure', 10)

While 1
   Sleep(1000)
WEnd

Exit
Func _CheckAPressure()
   If _IsPressed(0x41) Then;0x41 means 'A'
      MsgBox(0, 'Hahahah', 'I love you.')
   EndIf
EndFunc

Func OnAutoItstart()
   Global $DllUser32 = DllOpen('user32')
EndFunc

Func OnAutoItExit()
   DllClose($DllUser32)
EndFunc

Func _IsPressed($hexKey)
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
   
   Local $aR
   $aR = DllCall($DllUser32, "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      Return 1
   Else
      Return 0
   EndIf
EndFunc  ;==>_IsPressed

Btw, of course you have overstack error... Sending an 'A' when 'A' starts the function itself...

Edited by ezzetabi

Share this post


Link to post
Share on other sites

In my script i got this

->  HotKeySet("A", "laugh")

Func laugh()
MsgBox(4096, "Hahaha", "Hahahaha", 10)
EndFunc

But i want my computer still to recognice that the key A was pressed,

when i am in word and i type A with the script running the MsgBox appears

but he doesn't write A. I tried this

->  HotKeySet("A", "laugh")

Func laugh()
MsgBox(4096, "Hahaha", "Hahahaha", 10)
Send("A")
EndFunc

but it doesn't work.

I need ur help guys.

Thanks for ur answers!

PS: I get this Error: Recursion level has been exceeded - AutoIT will quit to prevent stack overflow.

<{POST_SNAPBACK}>

o.O

on my computer it works pretty well o.O

Share this post


Link to post
Share on other sites

In my script i got this

->  HotKeySet("A", "laugh")

Func laugh()
MsgBox(4096, "Hahaha", "Hahahaha", 10)
EndFunc

But i want my computer still to recognice that the key A was pressed,

when i am in word and i type A with the script running the MsgBox appears

but he doesn't write A. I tried this

->  HotKeySet("A", "laugh")

Func laugh()
MsgBox(4096, "Hahaha", "Hahahaha", 10)
Send("A")
EndFunc

but it doesn't work.

I need ur help guys.

Thanks for ur answers!

PS: I get this Error: Recursion level has been exceeded - AutoIT will quit to prevent stack overflow.

<{POST_SNAPBACK}>

Do the following...

HotKeySet("A", "laugh")

Func laugh()
    MsgBox(4096, "Hahaha", "Hahahaha", 10)
    HotKeySet("A")
    Send("A")
    HotKeySet("A", "laugh")
EndFunc

Nothing against ezzetabi's code, but this is much smaller.

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

#5 ·  Posted (edited)

Do the following...

HotKeySet("A", "laugh")

Func laugh()
    MsgBox(4096, "Hahaha", "Hahahaha", 10)
    HotKeySet("A")
    Send("A")
    HotKeySet("A", "laugh")
EndFunc

Nothing against ezzetabi's code, but this is much smaller.

JS

<{POST_SNAPBACK}>

I thought letters by themselves can't be set as hotkeys.

Just made a quick script to test it and it didn't work either.

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

Now they can.


FootbaG

Share this post


Link to post
Share on other sites

sd333221 said:

"...and i type A with the script running the MsgBox appears but he doesn't write A...."

JS offered this code:

HotKeySet("A", "laugh")

Func laugh()
    MsgBox(4096, "Hahaha", "Hahahaha", 10)
    HotKeySet("A")
    Send("A")
    HotKeySet("A", "laugh")
EndFunc
Even with the code above, might not the "A" be lost?

Would this be better?

HotKeySet("A", "laugh")

Func laugh()
    HotKeySet("A")
    Send("A")
    HotKeySet("A", "laugh")
    MsgBox(4096, "Hahaha", "Hahahaha", 10)
EndFunc

...then you do not have window focus issues... depending on the app and the computer, the app might not be ready to take the "A" right after the msgbox. If you put the msgbox ahead of the "send A", then while the computer is switching focus between the AutoIt msgbox and the app - where would the "A" be sent?

...just a thought...


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

Share this post


Link to post
Share on other sites

GetAsyncKeyState of user32 is made for detecting a key pressure without stealing focus or remove the key from the queue... anyway, do as you want guys.

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