Jump to content
Sign in to follow this  
LiLShinta

Hotkeys

Recommended Posts

LiLShinta

I have this code:

Global $ConfigFile  = @ScriptDir & "\bpm.ini"


Global $Init        = IniReadSection($ConfigFile, "Main Prefs")
Global $var        = $Init[1][0]

Global $HK1       = "{F8}"
Global $HK2       = "{F4}"
Global $HK3       = "{F6}"
Global $HK4       = "{F7}"
Global $HK5       = "{F9}"
Global $bool           = False

HotKeySet($HK1, "start")
HotKeySet($HK2, "quit")
HotKeySet($HK5,"pause")
HotKeySet($HK3, "add")
HotKeySet($HK4, "less")


Func add()
            Local $Ini1 = $var2 + 1
            IniWrite($ConfigFile, "Main Prefs", "bpm", $Ini1)
EndFunc
        
Func less()
            Local $Ini1 = $var2 - 1
            IniWrite($ConfigFile, "Main Prefs", "bpm", $Ini1)  
EndFunc

Func pause()
    $bool= Not $bool
    Beep(500, 1000)
    while $bool
        sleep(10)
        ConsoleWrite("Paused!"&@CRLF)
    WEnd
EndFunc

While 1
    Sleep(100)
    IniWrite($ConfigFile, "Main Prefs", "bpm", 101)
WEnd
    
Func quit() 
Exit
EndFunc
    

Func start()
    $Init   = IniRead($ConfigFile, "Main Prefs", "bpm", "")
    Local $beat1 = $Init / 4.5     
    Local $beat2 = 60000 / $beat1
    
    If _IsPressed("79") Then
        $beat3 = $beat2 + 150
    ElseIf _IsPressed("7A") Then
        $beat3 = $beat2 - 150 
    Else
        $beat3 = $beat2
    EndIf
         
    Opt("SendKeyDelay", $beat3+10) 
    $i = 0
    Do
    Beep(500, 1000) 
    Until $i = 60
    
EndFunc

anyone there please help me here... my target is:

1. to beep at a given instance.

2. to have the hotkeys which will terminate the script -->which is $HK2 = F4

3. to have a function that when hotkey $HK3 and $HK4 is pressed will increase/decrease the normal bpm which is 101.

4. I also want a function that will terminate my function start...coz when I hit $HK1=F8, it will start my sciprt and beep, is there a way to terminate my function start() ?

also I want it to be, when i pressed $Hk1 which is F8, it will start the function start() again but with increase number of bpm to be read from the $configfile...

Edited by LiLShinta

Share this post


Link to post
Share on other sites
martin

I have this code:

Global $ConfigFile  = @ScriptDir & "\bpm.ini"


Global $Init        = IniReadSection($ConfigFile, "Main Prefs")
Global $var        = $Init[1][0]

Global $HK1       = "{F8}"
Global $HK2       = "{F4}"
Global $HK3       = "{F6}"
Global $HK4       = "{F7}"
Global $HK5       = "{F9}"
Global $bool           = False

HotKeySet($HK1, "start")
HotKeySet($HK2, "quit")
HotKeySet($HK5,"pause")
HotKeySet($HK3, "add")
HotKeySet($HK4, "less")


Func add()
            Local $Ini1 = $var2 + 1
            IniWrite($ConfigFile, "Main Prefs", "bpm", $Ini1)
EndFunc
        
Func less()
            Local $Ini1 = $var2 - 1
            IniWrite($ConfigFile, "Main Prefs", "bpm", $Ini1)  
EndFunc

Func pause()
    $bool= Not $bool
    Beep(500, 1000)
    while $bool
        sleep(10)
        ConsoleWrite("Paused!"&@CRLF)
    WEnd
EndFunc

While 1
    Sleep(100)
    IniWrite($ConfigFile, "Main Prefs", "bpm", 101)
WEnd
    
Func quit() 
Exit
EndFunc
    

Func start()
    $Init   = IniRead($ConfigFile, "Main Prefs", "bpm", "")
    Local $beat1 = $Init / 4.5     
    Local $beat2 = 60000 / $beat1
    
    If _IsPressed("79") Then
        $beat3 = $beat2 + 150
    ElseIf _IsPressed("7A") Then
        $beat3 = $beat2 - 150 
    Else
        $beat3 = $beat2
    EndIf
         
    Opt("SendKeyDelay", $beat3+10) 
    $i = 0
    Do
    Beep(500, 1000) 
    Until $i = 60
    
EndFunc

anyone there please help me here... my target is:

1. to beep at a given instance.

2. to have the hotkeys which will terminate the script -->which is $HK2 = F4

3. to have a function that when hotkey $HK3 and $HK4 is pressed will increase/decrease the normal bpm which is 101.

4. I also want a function that will terminate my function start...coz when I hit $HK1=F8, it will start my sciprt and beep, is there a way to terminate my function start() ?

also I want it to be, when i pressed $Hk1 which is F8, it will start the function start() again but with increase number of bpm to be read from the $configfile...

You have some loops where the script will get stuck, like this one

Do
    Beep(500, 1000) 
    Until $i = 60

You could change this to something like

Do
    Beep(500, 1000) 
    Until $i = 60 Or $skip = True; Add $skip as global, see later

Another case is your pause function. If $bool is true there is no way out of the loop.

So you could have another Hot Key calling a function like this

Func endloops()
    $bool = False
    $skip = True
EndFunc

Then set $skip = false at the start of your pause function.

Also, in your start() function, you are testing for F10 or F11. Since you need to press F8 to call this function it is unlikely either of those keys will be pressed. You could have yet more hot keys for the adjustment of $beat3, and simply set $beat1 and $beat2 globally at the start of the script.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
LiLShinta

how about on my target on increasing/decreasing the value of $init as I hit either $HK3 or $HK4...

ahm... is it posible to write that in console as this one?

Global $Init    = 102;I set first $Init to default value of 102

;hotkeys
Global $HK1       = "{F8}"
Global $HK2       = "{F4}"
Global $HK3       = "{F6}"
Global $HK4       = "{F7}"
Global $HK5       = "{F9}"
Global $HK6       = "{F10}"

;bool value
Global $bool           = False
Global $skip           = false


HotKeySet($HK1, "start")
HotKeySet($HK2, "quit")
HotKeySet($HK3, "add")
HotKeySet($HK4, "less")
HotKeySet($HK5,"pause")
HotKeySet($HK6,"endloops")

While 1
    Sleep(100)
    ConsoleWrite($Init & @CRLF)
WEnd


Func add()
            Local $ini = $Init + 1
            ConsoleWrite($ini & @CRLF)
EndFunc
        
Func less()
            Local $ini = $Init - 1
            ConsoleWrite($ini & @CRLF) 
EndFunc

Func endloops()
    $bool = False
    $skip = True
EndFunc

Func pause()
    $bool= Not $bool
    Beep(500, 1000)
    while $bool
        sleep(10)
        ConsoleWrite("Paused!"&@CRLF)
    WEnd
EndFunc

Func quit() 
Exit
EndFunc
    

Func start()
    $Init   = ConsoleRead();what should be here??
    Local $beat1 = $Init / 4.5    
    Local $beat2 = 60000 / $beat1
     
    Opt("SendKeyDelay", $beat2 + 10)
    $i = 0
    Do
    Send("{SPACE}")
    Until $i = 60 Or $skip = True; changed
EndFunc

is it posible to us console instead of reading from ini to change the default value of $Init ???

thanks.

Edited by LiLShinta

Share this post


Link to post
Share on other sites
martin

how about on my target on increasing/decreasing the value of $init as I hit either $HK3 or $HK4...

Change your functions

Func add()
            Local $ini = $Init + 1
            ConsoleWrite($ini & @CRLF)
EndFunc
        
Func less()
            Local $ini = $Init - 1
            ConsoleWrite($ini & @CRLF)
EndFunc

to

Func add()
            $Init += 1
            ConsoleWrite($Init & @CRLF)
EndFunc
        
Func less()
            $Init -= 1
            ConsoleWrite$Init & @CRLF)
EndFunc

ahm... is it posible to write that in console as this one?

Not sure I understand what you mean there but perhaps I have already answered it.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
LiLShinta

Func add()
            $Init += 1
            ConsoleWrite($Init & @CRLF)
EndFunc
        
Func less()
            $Init -= 1
            ConsoleWrite$Init & @CRLF)
EndFunc
ahmm how can I read now the value of $Init from console so it will be my input on funx start()..

Func start()
    $Init   = ConsoleRead()  ;what should be here??
    Local $beat1 = $Init / 4.5    
    Local $beat2 = 60000 / $beat1
    
    Opt("SendKeyDelay", $beat2 + 10)
    $i = 0
    Do
    Send("{SPACE}")
    Until $i = 60 Or $skip = True; changed
EndFunc

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  

×