Jump to content
Sign in to follow this  

Hotkeyset / Send Func.

Recommended Posts


Hello!  I've been fervorously attempting to fix an issue I've been having with my latest Autoit script.....

I've been using AutoIt now for the past few years, and feel that I've got a (loose) grip on how it runs.  I understand the mechanics behind what I'm trying to code, but no matter what I try, I can't get this simple script to function!  I'm trying to generate a "Hotkeyset" function, so that when I press "=" it resumes my script, "-" to pause, and "x" to stop completely.  Pretty damn simple.  When I run my script normally, it works just fine, allowing me to hit "=" to start my script, "-" to pause etc.  HOWEVER, since I'm trying to automate a standalone file w/ just a few keypresses (making my day to day life MUCH easier), whenever I open up the .exe and start my Hotkeyset, it won't run!  Only until I click away from the file, THEN start it up, will it work.  Unfortunately, since it needs to repeatedly pause and start, a dilemma ensues. 

Here's a simplified version of my current layout.

Global $Paused

HotKeySet("-", "Pause") 
HotKeySet("x", "Stop")

$go = True
$Leave = False

While $go
   if($Leave) Then
Func Pause()
   $Leave = False

Func Stop() ;to allow the script to stop
Func Leave()
    $Leave = True

Like I said, it works when I click onto a different file, or folder, but ceases to work when I re-enter the file.  


If I take this exact script, open a new notepad file, and hit "=" to start my code, my keyboard simulates the "d" keypress every 1 second.  HOWEVER, if I swap over to my troublesome file, then my script stops communicating COMPLETELY.   To test this, I swapped back and forth between notepad, and my file, and no "d" keys were entered on the notepad, even though more than one second had passed collectively.

I "could" do without this script, but it would save me many a pain and agony down the line(isn't that what AutoIt is for?).  Many thanks in advance!

Share this post

Link to post
Share on other sites


Welcome to the AutoIt forum. :)

You speak of "automating a standalone file" - what app are you trying to automate? It may well be that it uses its own keyhandler and eats your keypresses - or it is resistant to automation in some way. If we knew the app we might even be able to suggest another way to do what you want - as I am sure sending multiple "d" keystrokes is not the limit of your ambition. ;)


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


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

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.