virginharvester Posted April 20, 2018 Share Posted April 20, 2018 (edited) sorry for my bad english,i like to test this script :// beginBool bIsHotkeyPressed ; = FalseInt Property iHotkey = 184 Auto ; R-Alt by default Event OnInit() RegisterForSingleUpdate(0.25)EndEvent Event OnUpdate() If bIsHotkeyPressed != Input.IsKeyPressed(iHotkey) ; Only run code when the status changes bIsHotkeyPressed = !bIsHotkeyPressed ; Set bool to whatever it isn't If bIsHotkeyPressed ; == True Debug.Trace("Hotkey Pressed") Else ; If bIsHotkeyPressed == False Debug.Trace("Hotkey Released") EndIf EndIf RegisterForSingleUpdate(0.25)EndEvent// end note : i got this from https://www.creationkit.com/index.php?title=IsKeyPressed_-_Input but it require SKSE, so, where i must put it in, its require creation kit? what tab i must put in? i mean it do not have object reference to trigger the events, so i dont understand how to put this script without object to put the script Edited April 20, 2018 by virginharvester Link to comment Share on other sites More sharing options...
FrankFamily Posted April 20, 2018 Share Posted April 20, 2018 (edited) Genrally you'd put this stuff in a script in a quest with the start game enabled checkbox checked. Also it's better to use https://www.creationkit.com/index.php?title=RegisterForKey_-_Form + https://www.creationkit.com/index.php?title=OnKeyDown_-_Form instead of checking constantly if the key is pressed.And yeah you of course need ck to bind scripts to objects. Edited April 20, 2018 by FrankFamily Link to comment Share on other sites More sharing options...
virginharvester Posted April 20, 2018 Author Share Posted April 20, 2018 thanks for reply,so i must create new quest to put this script?and what about SKSE, do i need include something so CK knot it SKSE? Link to comment Share on other sites More sharing options...
FrankFamily Posted April 20, 2018 Share Posted April 20, 2018 (edited) Yes you need a new quest to add the script to, doesn't need a name, category or anything just start game enabled flag and ID ofc.About skse, afaik you will need to download if you haven't already the script sources for skse in order to compile the script so the CK knows those skse functions you are calling exist and that's it. Edited April 20, 2018 by FrankFamily Link to comment Share on other sites More sharing options...
virginharvester Posted April 20, 2018 Author Share Posted April 20, 2018 thanks again for reply, i have test it but encounter some problem this is script : Scriptname HotkeyScript Function RegisterForKey(Int KeyCode) NativeEvent OnKeyDown(Int KeyCode) Debug.Trace("A registered key has been pressed") If KeyCode == 42 Debug.Trace("R-Shift is registered and has been pressed") EndIfEndEvent(the script compile succeed without error)this is quest data tabID : HotkeyScriptquest name : Hotkey Questpriority : 100type : nonstart game enable check, run once check, save it, run the game, when i press r-shift, the script not respond,any wrong with my doing?note : i have latest SKSE instaled (oldrim) Link to comment Share on other sites More sharing options...
FrankFamily Posted April 20, 2018 Share Posted April 20, 2018 (edited) Well, you are not calling registerforkey, there you are defining a function instead. You need to call it just like registerforsingleupdate within onupdate in your original script, passing 42 as the parameter keycode, i.e: Event Oninit() RegisterForKey(42)EndEvent In the wiki check the examples not just the syntax section Edited April 20, 2018 by FrankFamily Link to comment Share on other sites More sharing options...
virginharvester Posted April 21, 2018 Author Share Posted April 21, 2018 thanks again for reply,but still not work,i have modified with other script,but still not work. Scriptname HotkeyScript Function Init() RegisterForKey(42) Debug.MessageBox("The mod has been installed")EndFunctionEvent OnPlayerLoadGame() Debug.Trace("player loaded a save, do some fancy stuff")endEventFunction RegisterForKey(Int KeyCode) NativeEvent OnKeyDown(Int KeyCode) Debug.Trace("A registered key has been pressed") If KeyCode == 42 Debug.Trace("R-Shift is registered and has been pressed") Debug.Trace("The keycode '"+keyCode+"' has been pressed.") EndIfEndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 21, 2018 Share Posted April 21, 2018 Try building off of the following. A most basic variation of what you're trying to do. Scriptname HotkeyScript Extends Quest Event OnInit() RegiserForKey(42) EndEvent Event OnKeyDown(Int KeyCode) If KeyCode == 42 Debug.Notification("Hey, you pressed the key with a DXScanCode value of "+KeyCode) EndIf EndEvent Link to comment Share on other sites More sharing options...
virginharvester Posted April 21, 2018 Author Share Posted April 21, 2018 yesssss, it workssssthank alot anyone Link to comment Share on other sites More sharing options...
Recommended Posts