Skip to content

Commit

Permalink
Added razer keyboard direct launch
Browse files Browse the repository at this point in the history
still needs the actaul razer profile
  • Loading branch information
TaranVH committed Jan 6, 2019
1 parent 90d77d9 commit ef03faa
Show file tree
Hide file tree
Showing 101 changed files with 610 additions and 225 deletions.
110 changes: 110 additions & 0 deletions INFO_and_PROFILES/ignore me/2nd_keyboard_if_using_Razer--BAD IDEA.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#NoEnv
SendMode Input
#InstallKeybdHook
#InstallMouseHook
#UseHook On

#SingleInstance force ;only one instance may run at a time!
#MaxHotkeysPerInterval 2000
#WinActivateForce ;https://autohotkey.com/docs/commands/_WinActivateForce.htm ;this may prevent taskbar flashing.
detecthiddenwindows, on

;;--------------------------------------------------------------------
;;;;;;SCRIPT THAT RECIEVES MESSAGES AND TURNS THEM INTO FUNCTIONS:;;;;
;;--------------------------------------------------------------------

;;Discussion:https://autohotkey.com/board/topic/18361-anyway-to-pass-params-to-script-while-running/

;;Where I got the script from:
; https://autohotkey.com/docs/commands/OnMessage.htm

#ifwinactive
OnMessage(0x4a, "Receive_WM_COPYDATA") ; 0x4a is WM_COPYDATA
return

Receive_WM_COPYDATA(wParam, lParam)
{
StringAddress := NumGet(lParam + 2*A_PtrSize) ; Retrieves the CopyDataStruct's lpData member.
CopyOfData := StrGet(StringAddress) ; Copy the string out of the structure.

;msgbox, %A_ScriptName%`nReceived the following string:`n`n%CopyOfData%

; So at this point, %CopyOfData% contains the following string:
; coolFunction("from Q",0)

; If only there was an easy way to use that string in such a way that the function is called... I believe this is known as dynamic code execution: https://www.autohotkey.com/docs/Functions.htm#dynamic or https://autohotkey.com/board/topic/51532-execute-string-in-ahk/
; But IDK how to get that working.

;#(%CopyOfData%) ;<--this doesn't work, but i guess it would if I used a mile of code from that thread I linked to. That ain't happening.

;callIt := CopyOfData ;<--unfortunately, this also doesn't work, even if we start off with `%coolFunction`%("from Q",0) ... which means that I need to do it the hard way, which you will see below.
;callIt = %CopyOfData% ;<- this don't work neither, dang it.

;/*
string = %CopyOfData%
theFunctionName := SubStr(String, 1, InStr(string, "(") - 1) ;<-- This assumes that your function name is to the left of a "(" and I think that's a pretty fair assumption.

parameter1 := SubStr(String, InStr(string, "(") + 1)
parameter1 := SubStr(parameter1, 1, InStr(parameter1, ",") - 1) ;this and the preceeding line will extract the parameters, assuming you properly put them inside of ( ) parentheses!


;Func.Call()

return true ; Returning 1 (true) is the traditional way to acknowledge this message.
}

;;DEFINE YOUR FUNCTIONS BELOW HERE

coolFunction(param1,param2 := 2) ;<--Just in case you forgot a 2nd parameter, this means that it'll be a 2.
{
msgbox, congrats! you made it to coolFunction`, with the parameters`n%param1%`nand`n%param2%
bueno = "bueno"
return bueno
}

anotherFunction(yeah,whatever)
{
msgbox, %yeah%`n%whatever%
sleep 10

}

^+s::
send ^s
reload

return

; Keyshower(f_path,"InstExplor")
; if IsFunc("Keyshower") {
; Func := Func("Keyshower")
; RetVal := Func.Call(f_path,"InstExplor")
; }




























22 changes: 22 additions & 0 deletions INFO_and_PROFILES/ignore me/E.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
StringToSend = fakeFunction("from E",0)
;; The above line is the only thing you should change. Write out the function you wish to call in exactly the same way you would with any function! Otherwise it won't work!! Note that it must have two parameters. (Unless you modify the code yourself.) If you don't want to use the 2nd parameters, just put a 0.

result := Send_WM_COPYDATA(StringToSend)
;The above line is what actaully calls the Send_WM_COPYDATA function, which is defined in the REDIRECTOR_RAZER.ahk script, which has been #include-d below. Yeah. You can define functions even below an "Exitapp" command.

;At this point, we are hoping to recieve "true" as our result. If it fails, we will recieve "fail".

if (result = 0)
wasIgnored()

if (result = "fail"){
failtastic(stringtosend,result) ;I want to have as little code in these small scripts as possible. failtastic(,) is therefore defined inside of the REDIRECTOR_RAZER.ahk script.
}

Exitapp


SetWorkingDir %A_ScriptDir% ;<--This is superior to the alternative on the following line:
;SetWorkingDir C:\AHK\2nd-keyboard\Razer\razer_direct_launch
;Because even though they both achieve the same result, the way I've done it means that you can move the entire folder wherever you want. The downside is that you'd still have to redefine all the script locations inside of razer synapse. yikes!
#Include %A_ScriptDir%/REDIRECTOR_RAZER.ahk ;<-- REDIRECTOR_RAZER.ahk must always be in the same folder as all the smaller scripts (like this one) that it is servicing.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
SetWorkingDir, C:\AHK\2nd-keyboard\ ;This line is actually optional. But it must go here if you need it.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;SetWorkingDir, C:\AHK\2nd-keyboard\ ;Or you could put the directory here. Whatevs.
Menu, Tray, Icon, shell32.dll, 283 ;changes the taskbar icon to something
;SetKeyDelay, 0 ;IDK exactly what this does.

Expand Down Expand Up @@ -52,9 +54,6 @@ SendMode Input
;; https://notepad-plus-plus.org/
;; You'll probably want the syntax highlighting: https://stackoverflow.com/questions/45466733/autohotkey-syntax-highlighting-in-notepad

;;;#if (getKeyState("F23", "P")) && (uselayer = 0) ;;you can use a varibable like so, but I don't.
;;;More info about #if thingies (important): https://github.com/TaranVH/2nd-keyboard/issues/65


;;;WARNING - THIS IS KINDA UNTESTED SINCE I STOPPED USING IT. LET ME KNOW IF YOU HAVE ANY ISSUES, BY LEAVING A GITHUB... ISSUE. https://github.com/TaranVH/2nd-keyboard/issues

Expand All @@ -63,9 +62,14 @@ SendMode Input
F23::return ;this line is mandatory for proper functionality

escape::tooltip, [F23] You might wish to not give a command to escape. Could cause problems. IDK.
F1::
;escape::return ;<--to disable a key, just use a "return," like so.

F1::msgbox, you pressed F1 on the extra keyboard
F2::
F3::
SoundBeep, 900, 400
tooltip, you pressed F2 AND get a beep sound!
return
F3::tooltip, you pressed F3 but do not get a beep.
F4::
F5::
F6::
Expand All @@ -74,7 +78,7 @@ F9::
F8::
F10::
F11::
F12::tooltip, [F23] %A_thishotKey%
F12::tooltip, you pressed the function key %A_thishotkey% on the [F23] keyboard
;;Note that the assignment on the above line will apply to ALL prior lines ending in "::"
;;...which you should know from the AHK tutorial I linked you to.

Expand Down Expand Up @@ -154,6 +158,7 @@ return

;;===================== MODIFIERS =========================;;

;;Keep these commented out, as they are!
;Lshift::tooltip, do not use
;Lctrl::tooltip, do not use
;Lwin::tooltip, do not use
Expand Down Expand Up @@ -275,6 +280,8 @@ F1::msgbox, You pressed F1 on your secondary keyboard while inside of Premiere P
; msgbox, You pressed F1 on your secondary keyboard while NOT inside of Premiere Pro
;;This is easier to understand, but it's not as clean of a solution.

;; #if (getKeyState("F23", "P")) && (uselayer = 0) ;;you can also use a varibable like so, but I don't.

;; Here is a discussion about all this:
;; https://github.com/TaranVH/2nd-keyboard/issues/65

Expand All @@ -286,6 +293,7 @@ F1::msgbox, You pressed F1 on your secondary keyboard while inside of Premiere P
;;IDK what you foreign language peoples are gonna have to do!
;;At the very least, you'll have some duplicate keys.


#if

;;*******************************************************************************
Expand Down
Loading

0 comments on commit ef03faa

Please sign in to comment.