Jump to content
Sign in to follow this  
kana

Sending a specific set of keys

Recommended Posts

kana

If a Insert or Delete is pressed, how do I make it send a certain set of keys in an order.

Share this post


Link to post
Share on other sites
somdcomputerguy

These functions, HotKeySet, or, _IsPressed and Send, will probably help you accomplish what you're trying to do..


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
kana

If I'm making AutoIt to press a key, does it use the keyboard or can I do something else during those inputs?

Share this post


Link to post
Share on other sites
kana

Is there anything wrong with this?

HotkeySet("{N}","_func1")

Func _func1()

Send ("G")

Sleep(10)

Send("{TAB}")

Sleep(10)

Send ("G")

Sleep(10)

Send("{TAB}")

Sleep(10)

Send ("G")

Sleep(10)

Send("{TAB}")

Sleep(10)

Send ("G")

Sleep(10)

Send("{TAB}")

Sleep(10)

Send ("G")

Sleep(10)

Send("{TAB}")

Sleep(10)

Send ("G")

Sleep(10)

Send("{TAB}")

Sleep(10)

Send ("G")

Sleep(10)

Send("{TAB}")

Sleep(10)

EndFunc

Share this post


Link to post
Share on other sites
Melba23

kana,

Is there anything wrong with this?

Yes. ;)

- 1. Look again at the syntax for HotKeySet. You only need the { } around the special keys - normal keys do not require them.

- 2. You need something to keep the script active - at the moment you exit immediately. Try adding a While..WEnd loop and exit HotKey like this:

HotKeySet("n", "_func1") ; See the difference?
HotKeySet("{ESC}", "On_Exit")

While 1
    Sleep(10) ; You need this to prevent CPU overload
WEnd

Func On_Exit()
    Exit
EndFunc

Func _func1()
    ; code
EndFunc

All clear? :blink:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
kana

Is it case sensitive?

I had

//

While 1

WEnd

at the bottom from the earlier post

//Edited one below but it doesn't work outside of Windows except for chats

HotKeySet("G", "_func1")

HotKeySet("{ESC}", "On_Exit")

While 1

Sleep(10)

WEnd

Func On_Exit()

Exit

EndFunc

Func _func1()

Send ("G")

Sleep(100)

Send("{TAB}")

Sleep(100)

Send ("G")

Sleep(100)

Send("{TAB}")

Sleep(100)

Send ("G")

Sleep(100)

Send("{TAB}")

Sleep(100)

Send ("G")

Sleep(100)

Send("{TAB}")

Sleep(100)

Send ("G")

Sleep(100)

Send("{TAB}")

Sleep(100)

Send ("G")

Sleep(100)

Send("{TAB}")

Sleep(100)

Send ("G")

Sleep(100)

Send("{TAB}")

Sleep(100)

EndFunc

Share this post


Link to post
Share on other sites
kana

Never mind, I had to change the compatibility to Windows XP SP3... doesn't work with Windows 7 or something

Share this post


Link to post
Share on other sites
kana

For the left mouseclick, do I need the X/Y coordinates? Is there a command for just clicking the left mouse key?

Share this post


Link to post
Share on other sites
Melba23

kana,

Dog eaten your Help file? :blink:

"MouseClick - Perform a mouse click operation.

MouseClick ( "button" [, x, y [, clicks [, speed ]]] )

Parameters

button The button to click

x, y [optional] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

clicks [optional]

speed [optional] "

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
kana

Does the keyboard speed matter? It doesn't always do everything in the list.

//

HotKeySet("{INS}", "_func1")
HotKeySet("{ESC}", "On_Exit")
HotKeySet("{DEL}", "_func2")
HotKeySet("{HOME}", "_func3")

While 1
    Sleep(10) 
WEnd

Func On_Exit()
    Exit
EndFunc

Func _func1()
   Send("3")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
   Sleep(10)
   Send("{TAB}")
   Sleep(10)
   Send("G")
EndFunc

Func _func2()
    Send(2)
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
    Sleep(10)
    Send("{TAB}")
    Sleep(10)
    Send("W")
    Sleep(10)
    Mouseclick("left")
EndFunc

Func _func3()
    Send("{DEL}")
    Sleep(360)
    Send("{INS}")
EndFunc
Edited by Jos
added Code tags

Share this post


Link to post
Share on other sites
Melba23

kana,

Try increasing the Sleep time a bit.

M23

P.S. When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button. :blink:

And if you could edit your previous posts to use code tags to make the thread shorter that would be really kind of you! ;)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Melba23

kana,

I have no idea as I imagine it depends on the particular system. Have you tried? :blink:

M23

P.S. And are you going to edit your previous posts with code tags to shorten them? ;)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
somdcomputerguy

@kana - have you read any of the help file? The arguments for the Sleep function are milliseconds. So 1000 is equal to one second, 500 would be half a second, 10000 or 10 * 1000 would be ten seconds..


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.