fry128 Posted May 22, 2008 Share Posted May 22, 2008 I'm trying to make a script that saves certain keystrokes as variables that are writable to a .ini file for later use, but I cant manage call these keystrokes through the variables. Say I'm trying to save the F1 key as $F1... I can make it write to a the .ini and pull it in a later script, but when it comes to send that variable with Send, I just cant get it to. :\ I hope someone could help me with this, I've spent a good 5 or so hours tinkering with it. :\ Any help is muchly appreciated. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 22, 2008 Developers Share Posted May 22, 2008 We call this a Keylogger and we have some strong ideas about it unless you want something like the Au3record, written by Larry, functionality that you get when you Install SciTE4AutoIt3. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
someone Posted May 22, 2008 Share Posted May 22, 2008 Not sure if you wanted to read a key from an ini or just store a key to send as a variable, so I did both. Very plain examples but I think this will help. For the ini, it is called hotkey.ini and looks like this; [Keys] F2=F2 For the autoit code; $F1 = "F1" $F2 = IniRead("hotkey.ini", "Keys", "F2", "not found") HotKeySet("{"& $F1 & "}", "ShowMessage") HotKeySet("{"& $F2 & "}", "ShowMessage2") ;;;; Body of program would go here ;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func ShowMessage() MsgBox(4096,"","You Pressed " & $F1) EndFunc Func ShowMessage2() MsgBox(4096,"Taken from ini...","You Pressed " & $F2) EndFunc Let me know if this is what you meant or not While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
fry128 Posted May 22, 2008 Author Share Posted May 22, 2008 Well to clarify, I dont want it to record keystrokes per se. I'm trying to write a script to help me with a game I'm playing. I can get it to ask me which keys I use in the game and it saves them to the file, I just cant get my second script to send them. :\ I get the whole iniread part, it brings back the right keys when I tell it to bring up a message box with the $F1 variable in it. It finds it and everything, I just cant get it to send the keystroke using Send ($F1). What am I doing wrong? :\ Link to comment Share on other sites More sharing options...
someone Posted May 22, 2008 Share Posted May 22, 2008 If I'm wrong I'm wrong someone PM me or otherwise let me know, but I guess I don't see the harm in what he is asking... like I said, if I'm wrong please let me know and I'll refrain from answering anything like this in the future. @fry, you can't just do Send($F1) you need to respect the formatting sending keystrokes needs... ala $F1 = "F1" Send("{"& $F1 & "}") While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
fry128 Posted May 22, 2008 Author Share Posted May 22, 2008 Well I can get the script not to error now, thats a start. For some reason it's still not sending F1, I think it may be the way I'm saving the keystroke? How I have it set up right now is I have another script that asks me which button is mapped to skill 1, so I have to manually put in "F1" because I cant get it to register F1 normally. Would there be another way to script this or register the key? Global $F1 = InputBox("Hero, Skill 1", "Please enter the key used to activate SKILL 1 for HERO. " , "Insert here!") iniwrite ("HeroSkill.ini", "heroskills", "$HeroS1", $F1) Link to comment Share on other sites More sharing options...
someone Posted May 22, 2008 Share Posted May 22, 2008 How I have it set up right now is I have another script that asks me which button is mapped to skill 1, so I have to manually put in "F1" because I cant get it to register F1 normally. Would there be another way to script this or register the key?.. I'm not quite sure what you mean... but that aside, this doesn't send F1?$F1 = "F1"Send("{"& $F1 & "}")Does it work outside the game? You need to seperate saving the keystroke and sending it, to see where the problem is. Also you need to know that sending keystrokes to games can be iffy, it doesn't always work. I recommend trying it outside the game first to see if your code is the problem or the game. While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
fry128 Posted May 22, 2008 Author Share Posted May 22, 2008 .. I'm not quite sure what you mean... but that aside, this doesn't send F1?$F1 = "F1"Send("{"& $F1 & "}")Does it work outside the game? You need to seperate saving the keystroke and sending it, to see where the problem is. Also you need to know that sending keystrokes to games can be iffy, it doesn't always work. I recommend trying it outside the game first to see if your code is the problem or the game.Well, the good news is I can get it to work partially now. The bad news is I may have to rewrite my script. If I need any more help, I'll post it in here.Thank you very very much for the help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now