Sign in to follow this  
Followers 0
LiLShinta

SendKeys with BPM...

7 posts in this topic

i have this code...

$HK1                            = "{F6}"
$HK2                            = "{F7}"
$HK3                            = "{F8}"
$HK4                            = "{F5}"
$HK5                            = "{F4}"

$Init = 128

HotKeySet($HK4, "start")

       If  _IsPressed($HK1) Then
    $Init1 = $Init + 1
    EndIf
    
    If  _IsPressed($HK2) Then
        $Init1 = $Init - 1
    EndIf
    
    If  _IsPressed($HK3) Then
        $Init1 = $Init
    EndIf
    
    If  _IsPressed($HK5) Then
        Exit
    EndIf
    
Func start()
    
        
    $bpm = $Init1 / 60000   
    Sleep($bpm)
    Send("{SPACE}")
    
EndFunc

is this correct?? my target is to send Space in a given beat per min?? also does my calculation for bpm correct?

and if I want to increase the beat was my hotkey right??

Share this post


Link to post
Share on other sites



_IsPressed() Key Codes:

Your issue: You can't use standard key codes for _IsPressed() Use these.

01 Left mouse button

02 Right mouse button

04 Middle mouse button (three-button mouse)

05 Windows 2000/XP: X1 mouse button

06 Windows 2000/XP: X2 mouse button

08 BACKSPACE key

09 TAB key

0C CLEAR key

0D ENTER key

10 SHIFT key

11 CTRL key

12 ALT key

13 PAUSE key

14 CAPS LOCK key

1B ESC key

20 SPACEBAR

21 PAGE UP key

22 PAGE DOWN key

23 END key

24 HOME key

25 LEFT ARROW key

26 UP ARROW key

27 RIGHT ARROW key

28 DOWN ARROW key

29 SELECT key

2A PRINT key

2B EXECUTE key

2C PRINT SCREEN key

2D INS key

2E DEL key

30 0 key

31 1 key

32 2 key

33 3 key

34 4 key

35 5 key

36 6 key

37 7 key

38 8 key

39 9 key

41 A key

42 B key

43 C key

44 D key

45 E key

46 F key

47 G key

48 H key

49 I key

4A J key

4B K key

4C L key

4D M key

4E N key

4F O key

50 P key

51 Q key

52 R key

53 S key

54 T key

55 U key

56 V key

57 W key

58 X key

59 Y key

5A Z key

5B Left Windows key

5C Right Windows key

60 Numeric keypad 0 key

61 Numeric keypad 1 key

62 Numeric keypad 2 key

63 Numeric keypad 3 key

64 Numeric keypad 4 key

65 Numeric keypad 5 key

66 Numeric keypad 6 key

67 Numeric keypad 7 key

68 Numeric keypad 8 key

69 Numeric keypad 9 key

6A Multiply key

6B Add key

6C Separator key

6D Subtract key

6E Decimal key

6F Divide key

70 F1 key

71 F2 key

72 F3 key

73 F4 key

74 F5 key

75 F6 key

76 F7 key

77 F8 key

78 F9 key

79 F10 key

7A F11 key

7B F12 key

7C-7F F13 key - F16 key

80H-87H F17 key - F24 key

90 NUM LOCK key

91 SCROLL LOCK key

A0 Left SHIFT key

A1 Right SHIFT key

A2 Left CONTROL key

A3 Right CONTROL key

A4 Left MENU key

A5 Right MENU key

BA ;

BB =

BC ,

BD -

BE .

BF /

C0 `

DB [

DC \

DD ]

Share this post


Link to post
Share on other sites

yup i have changed it...

$HK1 =  "{F8}"

HotKeySet($HK1, "start")

    If  _IsPressed(74) Then
    $Init1 = $Init
    EndIf
    
    If  _IsPressed(73) Then
        Exit
    EndIf

        If  _IsPressed(75) Then
    $Init1 = $Init + 1
    EndIf
    
    If  _IsPressed(76) Then
    $Init1 = $Init - 1
    EndIf
    
Func start()
    
    $bpm = 960/$Init1
    
    For $i = 1 to 100
        Sleep($bpm)
    Send("{SPACE}")
       Next
    
    
EndFunc

but i still got error...when i hit F8 it always says Line -1 error variable being used not declared...

how can i fix this? and also...does my start function correct??my target there is to send space in every beats...and what if i want to raise the beats by pressing F5(75) will it works?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Add this to the top of your script:

#Include <Misc.au3>

also put $init1 = 0 and $init = 0

Edited by flip209

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

how about this one??

Global $ConfigFile          = @ScriptDir & "\bpm.ini"
Global $Init                        = IniRead($ConfigFile, "Main Prefs", "bpm", 101) 
;initial value is 101

Global $HK1             = "{F8}"
Global $HK2             = "{F4}"

Global $HK3             = "{F6}"
Global $HK4             = "{F7}"
Global $HK5             = "{F9}"


HotKeySet($HK1, "start")
HotKeySet($HK2, "quit")
HotKeySet($HK3, "add")
HotKeySet($HK4, "less")
HotKeySet($HK5, "restart") ----> what should be my func code here??

While 1
    Sleep(100)
    IniWrite($ConfigFile, "Main Prefs", "bpm", 101)
WEnd
    
Func    quit()  
    Exit
EndFunc
    
func add()
    $Ini1 = $Init + 1
    IniWrite($ConfigFile, "Main Prefs", "bpm", $Ini1)
EndFunc

func less()
    $Ini1 = $Init - 1
    IniWrite($ConfigFile, "Main Prefs", "bpm", $Ini1)
EndFunc

Func start()
    Local $beat1 = $Init / 4        
    Local $beat2 = 60000 / $beat1

    Opt("SendKeyDelay", $beat2) 
    Send("{SPACE 100}") 
    
EndFunc

what should be my func code on restart...i wish it to pause the script and return the initial value of $init to 101...help pls?

Edited by LiLShinta

Share this post


Link to post
Share on other sites

anyone??

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Because you have the bpm value being written every 100ms as 101, $init will still be 101.

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

This is what I think you want.

Global $ConfigFile          = @ScriptDir & "\bpm.ini"
Global $Init                        = IniRead($ConfigFile, "Main Prefs", "bpm", 101);initial value is 101

Global $HK1             = "{F8}"
Global $HK2             = "{F4}"

Global $HK3             = "{F6}"
Global $HK4             = "{F7}"
Global $HK5             = "{F9}"


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

While 1
    Sleep(100)
WEnd

func restart()
    IniWrite($ConfigFile, "Main Prefs", "bpm", 101)
    $Init=101
EndFunc
    
Func    quit()  
    IniWrite($ConfigFile, "Main Prefs", "bpm", $Init);saves $Init value to file then exits.
    Exit
EndFunc
    
func add()
    $Init = $Init + 1
;   IniWrite($ConfigFile, "Main Prefs", "bpm", $Init);uncomment if you want $Init saved to file each time
EndFunc

func less()
    $Init = $Init - 1
;   IniWrite($ConfigFile, "Main Prefs", "bpm", $Init);uncomment if you want $Init saved to file each time
EndFunc

Func start()
    Local $beat1 = $Init / 4        
    Local $beat2 = 60000 / $beat1

    Opt("SendKeyDelay", $beat2)
    Send("{SPACE 100}")
    
EndFunc

That way it will only write to the file when you tell it to. Hope it helps :P

Edited by TheDarkEngineer

Trust me to make SkyNet with AutoIt...

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