DisplayNoob

Help with F keys hotkeys

3 posts in this topic

Hello Members,

I working on a small tool that type in some text in a program and i use the F1 to F11 keys as Hotkey. That is working, but when i try to pause my script to use F1 or some other F key for a Windows function like to open help page from a program It is not working. So is there a way to pause my script and let the Windows F functions working again?

Thanks for the reply.

Share this post


Link to post
Share on other sites



Global $Paused = False

HotKeySet("{INS}", "Send_Hotkey")
HotKeySet("{F1}", "Send_Hotkey")
HotKeySet("{F2}", "Send_Hotkey")

$file = @ScriptDir & "\config.ini"

$F1_ini = IniRead($fileh, "key", "f1_button", "-")
$F2_ini = IniRead($fileh, "key", "f2_button", "-")

While 1
    Sleep(100)
WEnd

Func Send_Hotkey()
    Switch @HotKeyPressed
        Case "{INS}"
            $Paused = Not $Paused
            While $Paused
                Sleep(100)
                ToolTip('SCRIPT STOP | TEST"', 0, 0)
            WEnd
            ToolTip("")

        Case "{F1}"
            While 1
                Send ($F1_ini)
            WEnd

        Case "{F2}"
            While 1
                Send ($F2_ini)
            WEnd

    EndSwitch
EndFunc

I cant edit my first post. So this is how my script looks like.

Share this post


Link to post
Share on other sites

You need to unregister the hotkey when you pause the script

Global $Paused = False

HotKeySet("{INS}", "Send_Hotkey")
HotKeyRegister()

$file = @ScriptDir & "\config.ini"

$F1_ini = IniRead($file, "key", "f1_button", "-")
$F2_ini = IniRead($file, "key", "f2_button", "-")

While 1
    Sleep(100)
WEnd

Func HotKeyRegister()
    HotKeySet("{F1}", "Send_Hotkey")
    HotKeySet("{F2}", "Send_Hotkey")
EndFunc   ;==>HotKeyRegister

Func HotKeyUnregister()
    HotKeySet("{F1}")
    HotKeySet("{F2}")
EndFunc   ;==>HotKeyUnregister

Func Send_Hotkey()
    Switch @HotKeyPressed
        Case "{INS}"
            $Paused = Not $Paused
            HotKeyUnregister()
            While $Paused
                Sleep(100)
                ToolTip('SCRIPT STOP | TEST"', 0, 0)
            WEnd
            HotKeyRegister()
            ToolTip("")

        Case "{F1}"
            While 1
                Send($F1_ini)
            WEnd

        Case "{F2}"
            While 1
                Send($F2_ini)
            WEnd

    EndSwitch
EndFunc   ;==>Send_Hotkey

 

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