Sign in to follow this  
Followers 0
doug4117

Hot Key Functions

8 posts in this topic

I have an extremely simple program...it consists of a while/wend loop containing a Sleep statement. I have defined three Hot Key functions that I want to invoke at my leisure, one of which exits the script. The problem is that once I press one of the Hot Keys, the script invokes the Hot Key function repeatedly. I of course want the function to execute only once and then wait until I press the Hot Key again.

Can someone clarify what's going on?

Thanks,

Doug

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome to Autoit

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I have an extremely simple program...it consists of a while/wend loop containing a Sleep statement. I have defined three Hot Key functions that I want to invoke at my leisure, one of which exits the script. The problem is that once I press one of the Hot Keys, the script invokes the Hot Key function repeatedly. I of course want the function to execute only once and then wait until I press the Hot Key again.

Can someone clarify what's going on?

Thanks,

Doug

Welcome to the forums...

Rule 1: If you want help, post a working example of your problem.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I have an extremely simple program...it consists of a while/wend loop containing a Sleep statement. I have defined three Hot Key functions that I want to invoke at my leisure, one of which exits the script. The problem is that once I press one of the Hot Keys, the script invokes the Hot Key function repeatedly. I of course want the function to execute only once and then wait until I press the Hot Key again.

Can someone clarify what's going on?

Thanks,

Doug

and you now want us to guess what could be going on or you can show the portion of the script which has this issue ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks for the welcome, glad to be here.

I didn't post any code because, as I said, the program is extremely simple. However, below is the heart of the problem, I think.

HotKeySet("{F4}", "Start")
HotKeySet("5{APPSKEY}", "Restart")

The problem lies in the use of the APPSKEY+number key combination. If I use a function key instead, the function executes only once. In fact, as coded above, the function linked to by the APPSKEY hot key will execute automatically and repeatedly after the completion of the function linked to by the F4 function key.

--Doug

Share this post


Link to post
Share on other sites

you could look at the post i gave you above...

or post your full script so that we can get the same reaction as you are getting... to find an answer

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Here is the full code...it works great when I use function keys as the hotkeys. When I use the APPSKEYs (currently commented out) as hotkeys it malfunctions.

--Doug

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)


; Press Esc to terminate script
HotKeySet("{ESC}", "Terminate")

;HotKeySet("4{APPSKEY}", "Start")
;HotKeySet("5{APPSKEY}", "Restart")

HotKeySet("{F2}", "Start")
HotKeySet("{F4}", "Restart")

$X = 0
$Y = 0

While 1
    Sleep(1000)
WEnd

Func Start()
    $X = 439
    $Y = 328
    Login()
EndFunc

Func Restart()
    $X = 333
    $Y = 386
    Login()
EndFunc

Func Login()
WinActivate("Login - Microsoft Internet Explorer", "")

MouseMove($X,$Y)
MouseDown("left")
MouseUp("left")
Sleep(10)

Send("111")
Send("{CAPSLOCK}{TAB}{CAPSLOCK}")
Send("111")
Send("{TAB}{ENTER}")

EndFunc

Func Terminate()
    Exit 0
EndFunc

Share this post


Link to post
Share on other sites

well... it works with the function keys... use them

8)


NEWHeader1.png

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