Jump to content

Is there an easy way to set a hotkey for your script?


square65
 Share

Recommended Posts

I'm new and therefore not yet knowledgeable enough to know how to search for answers to my questions. I did try for several minute but found absolutely nothing even close to my question.

I open up the SciTE-Lite editor and write some code.

I can test it with Tools->Go (F5)

How do I set a hotkey for the macro..? And what do I need open to execute it?

All I've been able to find are ways to dynamically set the hotkey in code and running the script file manually to execute the script once.

Thanks. I'm sure my confusion is due to having absolutely no idea how this works.

Link to comment
Share on other sites

  • Moderators

square65,

Welcome to the AutoIt forums. :)

You will need to have a script running permanently to recognise the HotKey, you cannot just start it from scratch. And then it is up to you whether you use the same script to do whatever it is you want to happen when the HotKey is pressed or whether you launch another separate script. Perhaps if you gave us a bit more information on what exactly you want to do we could offer you some more focused advice. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

I'm creating a script that executes some series of actions in windows when a hotkey is pressed. Something like clicking, typing some text, etc.

So would I do something like:

While 1
WEnd

And have a function that does what I want my macro do.

And have a HotKeySet up top that binds that function to my desired hotkey?

Link to comment
Share on other sites

  • Moderators

square65,

Then all you need to do is to set the HotKey to run your function while using a loop to keep the script alive. Something like this:

#include <MsgBoxConstants.au3>

; HotKey to exit - Escape
HotKeySet("{ESC}", "_Exit")

; HotKey to run the function - Ctrl-H
HotKeySet("^h", "_My_Func")

; Keep script alive
While 1
    Sleep(10) ; Important to give the CPU some breathing space
WEnd

; User function
Func _My_Func()
    ; A simple MsgBox as an example
    MsgBox($MB_SYSTEMMODAL, "Example", "Called by HotKey")
EndFunc

; Exit funtion
Func _Exit()
    Exit
EndFunc
All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...