Sign in to follow this  
Followers 0
BrainDrain

HotKeySet("[")

14 posts in this topic

Hi,

i try to write a script to close the brackets "({[" by a script.

Why does the following script not work?

If I use the part with "(" only everything is fine.

But if I use the lines with "[" and "{" too I have some ''funny'' results

like Keyboard is blocked afterwards.

Any help is welcome.

HotKeySet("(","WriteCloser_1")
HotKeySet("[","WriteCloserEk")
HotKeySet("{{}","WriteCloser_3")

While 1
    Sleep(500)
WEnd

Func WriteCloser_1()
    HotKeySet("(")
    Send("(")
    Send(")")
    Send("{LEFT}")
    HotKeySet("(","WriteCloser_1")
EndFunc

Func WriteCloserEk()
    HotKeySet("[")
    Send("[")
    Send("]")
    Send("{LEFT}")
    HotKeySet("[","WriteCloserEk")
EndFunc

Func WriteCloser_3()
    HotKeySet("{{}")
    Send("{{}")
    Send("{}}")
    Send("{LEFT}")
    HotKeySet("{{}","WriteCloser_3")
EndFunc

Share this post


Link to post
Share on other sites



Hi, and Welcome!

try this:

HotKeySet("(","WriteCloser_1")
HotKeySet("[","WriteCloserEk")
HotKeySet("{{}","WriteCloser_3")

While 1
    Sleep(500)
WEnd

Func WriteCloser_1()
    HotKeySet("(")
    Send("(")
    Send(")")

EndFunc

Func WriteCloserEk()
    HotKeySet("[")
    Send("[")
    Send("]")

EndFunc

Func WriteCloser_3()
    HotKeySet("{{}")
    Send("{{}")
    Send("{}}")

EndFunc

accomplishes the same thing without the last 2 steps.

Share this post


Link to post
Share on other sites

Hi billo,

thank you for your answer,

but it does not working too.

If I open a editor (Notepad++ in my case)

The keybord is blocked after pressing the "[" key.

Share this post


Link to post
Share on other sites

Ah,

I see what you mean...answered too fast.

try this:

HotKeySet("{F1}", "_F1")
HotKeySet("{F2}", "_F2")
HotKeySet("{F3}", "_F3")

While 1
    Sleep(500)
WEnd

Func _F1()

Send("(")
Send(")")

EndFunc

Func _F2()

Send("{")
Send("}")

EndFunc

Func _F3()

Send("[")
Send("]")

EndFunc

Share this post


Link to post
Share on other sites

Hi billo,

thank you for your answer,

but it does not working too.

If I open a editor (Notepad++ in my case)

The keybord is blocked after pressing the "[" key.

BrainDrain,

I notice you're using a hotkey of "{{}" That hotkey would be very hard to press. You don't have two keys with the '{' character on them. Therefore it will never be hit. Also I would recommend you search the forum for _IsPressed(). Actually it is in the helpfile as a UDF include these days I believe. Check it out. It will be potentially much more helpful. You simply want to re-act to certain combinations of key presses not react to a specific hotkey.

I hope this helps you on your journey,

Jarvis


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

Thank you for your answers.

@billo of course I can use F1 F2 F3 but that is not what I want.

I'd like to use the "{" and "[" as usual and autoIt should close the brackets and put the cursor between them.

Perhaps I'll find a solution in JSThePatriot hint.

Share this post


Link to post
Share on other sites

Nice tip!

another one for my box of stuff...

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("DB", $dll) Then
        Send("{]}")
    Send("{LEFT}")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

Thanks JS

Share this post


Link to post
Share on other sites

Nice tip!

another one for my box of stuff...

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("DB", $dll) Then
        Send("{]}")
    Send("{LEFT}")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

Thanks JS

Happy to be of service...I hope it helps the OP as well!

Regards,

Jarvis


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

On a UK keyboard, and probably many others, you don't want

HotKeySet("{{}","WriteCloser_3")

you want

HotKeySet("+[","WriteCloser_3")

and no need for _IsPressed.

HotKeySet("+[", "WriteCloser_3")

While 1
    Sleep(90)
WEnd

Func WriteCloser_3()
    HotKeySet("+[")
    Send("{")
    Send("}")
    HotKeySet("+[", "WriteCloser_3")
EndFunc ;==>setcurly

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

Hello ,

thank you again.

@martin: On a german keybord the "[" and "{" brackes need the ALT GR key that is {RALT} for AutoIt.

But {RALT} can't be used for a Hotkey in Combination with another key.

Or am I wrong?

HotKeySet("{RALT}0") but it does not work (like I have expected).

So I have to use the _IsPressed solution.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Alt Gr is actually Ctrl+Alt.

#Include <Misc.au3>
$dll = DllOpen("user32.dll")

HotKeySet("^!0", "WriteCloser_3")

While 1
    Sleep(90)
WEnd

Func WriteCloser_3()
    HotKeySet("^!0")
    Do
    Until _IsPressed("11", $dll) <> 1
    Send("{")
    Send("}")
    HotKeySet("^!0", "WriteCloser_3")
EndFunc ;==>setcurly

This works fine on my swedish keyboard. The _IsPressed() is there because the Ctrl key just got stuck for me without it.

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

Thank you AdmiralAlkex

that is exactly what I was looking for.

except it's "^!7" for opening bracket :-)

It's working on my german keybord as well.

Share this post


Link to post
Share on other sites

Looks like you are use brackets very ofthen, - developer? Sorry that is not topic answer, but man, do you like typing? If yes, just pass through all of "Solo on the keyboard" exercises, and you will not need hotkeys for putting special simbols and brackets. You will type fast and clear. :(

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