TaranVH / 2nd-keyboard

ALL of Taran's scripts - not just for the 2nd keyboard.
https://www.youtube.com/watch?v=O6ERELse_QY
1.66k stars 534 forks source link

Creating Batch file to execute macros at startup #72

Open nachomartinb opened 5 years ago

nachomartinb commented 5 years ago

I would like to create a batch file so that windows automatically executes my .lua file with my macros on startup. I've tried using the task scheduler on win10 but it's useless. It didn't open the file. Could anyone explain me how to do it? Thanks in advance

Matesaktesak commented 5 years ago

You can use .bat or even ahk script and then add it into the Startup folder under Programs (in start menu rightclick on any program > more > show files location, then go a few folders up and there you will find it). If you need further help, just write back!

I have it set up that way and it works every time!

nachomartinb commented 5 years ago

You can use .bat or even ahk script and then add it into the Startup folder under Programs (in start menu rightclick on any program > more > show files location, then go a few folders up and there you will find it). If you need further help, just write back!

I have it set up that way and it works every time! The problem

You can use .bat or even ahk script and then add it into the Startup folder under Programs (in start menu rightclick on any program > more > show files location, then go a few folders up and there you will find it). If you need further help, just write back!

I have it set up that way and it works every time!

I've tried that, the problem is that I have to press play inside luamacros to start it, windows opens it but i don't know how to tell it to automatically press play so that the code works. I'm not sure I explained my problem.

Matesaktesak commented 5 years ago

Ok, now I get it... That is a bit harder... I don't use Lua any more but I'll try.

First, when you press play, do you have to press a key on the other keyboard?

If not, them you can just program an ahk script that will press {Tab} a few times and then {Enter} - so it will start it. (Or mouse over and click)

Other wise, if you send me the code, I'll try to modify it, so that it doesn't need that Startup keystroke. (I think that it uses it just to save the keyboards HID ID to a variable)

By the way, you really shouldn't use Lua macros, they are extremely buggy and have lots of issues.

nachomartinb commented 5 years ago

Ok, now I get it... That is a bit harder... I don't use Lua any more but I'll try.

First, when you press play, do you have to press a key on the other keyboard?

If not, them you can just program an ahk script that will press {Tab} a few times and then {Enter} - so it will start it. (Or mouse over and click)

Other wise, if you send me the code, I'll try to modify it, so that it doesn't need that Startup keystroke. (I think that it uses it just to save the keyboards HID ID to a variable)

By the way, you really shouldn't use Lua macros, they are extremely buggy and have lots of issues.

I mainly use my numpad for volume control since my main keyboard doesn't have those. I also assigned the numbers to each F button and in games i bind F keys to buy bings What sofware would you recommend? Luamacros worked fine for me

volume.zip

Matesaktesak commented 5 years ago

So you don't use AHK at all? I haven't yet tried it, but it looks like it shouldn't ask for a keypress to identify the device as it has the specific ID.

So it should be really easy to set up a startup script with AHK to press the play-button for you.

  1. you have to install Auto HotKey
  2. Make an .ahk file with contents like this:

;---- script ---- Run, C:\yourpath\volume.lua ; start the script

Sleep 5000 ; wait for 5seconds to let the program start

Send, {Tab 2} ; you need to specify the amount of presses to get to the play button (remove the 2 and set it to something else)

Sleep, 10 ; give it 10 ms to do it...

Send, {Enter} ; that should press the play

;----- end of script -----

Then add this file to the startup folder.

I hope it will work. Check out the tutorial on AHK on their website under documentation. I'm currently away from my computer but I'll try to make the script and send it to you, if you need it.

BTW. I use intercept and interception and ahk as in Tarans second video on the topic.

Matesaktesak commented 5 years ago

I don't know what time zone you are in, but I am willing to do a Discord or Skype call if you need help

Skronos commented 5 years ago

I have the same problem, I have to press play inside LuaMacros to start the script, but I have the code for my second keyboard to be assigned as "macros", but I still can't find a solution so that the script runs only inside LuaMacros. any solution?