ASawyer Posted July 11, 2007 Share Posted July 11, 2007 I am trying to create a simple hotkey. The code works fine if I compile and run it, but I want to run it, have it sit there until I press Windows i, and the have it run. When I compile this, and run it, it immediately runs, and also complains about the return statement at the end. Can someone tell me what I'm doing wrong? Thanks, Alan #i:: $OF = FileOpen("Import.csv",0) if $OF = -1 Then msgbox(0,"Failure","Failed to open file") Exit EndIf while 1 $LineIn = FileReadLine($OF) if @error = -1 then ExitLoop msgbox(0,"LineIn = ", $LineIn) WEnd FileClose($OF) Return Link to comment Share on other sites More sharing options...
mrbond007 Posted July 11, 2007 Share Posted July 11, 2007 I am trying to create a simple hotkey. The code works fine if I compile and run it, but I want to run it, have it sit there until I press Windows i, and the have it run.use the _IsPressed() function (it's located in the help file) Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight Link to comment Share on other sites More sharing options...
someone Posted July 11, 2007 Share Posted July 11, 2007 I am trying to create a simple hotkey. The code works fine if I compile and run it, but I want to run it, have it sit there until I press Windows i, and the have it run. When I compile this, and run it, it immediately runs, and also complains about the return statement at the end. Can someone tell me what I'm doing wrong? Thanks, Alan #i:: $OF = FileOpen("Import.csv",0) if $OF = -1 Then msgbox(0,"Failure","Failed to open file") Exit EndIf while 1 $LineIn = FileReadLine($OF) if @error = -1 then ExitLoop msgbox(0,"LineIn = ", $LineIn) WEnd FileClose($OF) Return Theres a few things wrong in your code... in order for any code to continue indefinitely you need some sort of loop. In this case you want to use something like, While 1 sleep(100) Wend Did you want to use a i for a hotkey or Win+i ? Either way you can use hotkeyset and don't have to use _IsPressed(). Also the reason your getting an error about Return is you can only use Return in a Func/Endfunc, not just anywhere in your code. Make sure you use the full version of Scite offered in the downloads section as it will help you catch a lot of errors in your code. Read up on loops and look at the example in the help file for HotKeySet(). That should help alot. While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
James Posted July 11, 2007 Share Posted July 11, 2007 Have you looked at HotKeySet()? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
ASawyer Posted July 11, 2007 Author Share Posted July 11, 2007 Thanks, I am embarrassed to say but I created the code and when I went to see how to make it a hotkey, I accidently went to someones else site to look up the syntax. I have now looked in the proper place and am using the hotkeyset and it works great. Sorry for confusing everyone. Alan Link to comment Share on other sites More sharing options...
James Posted July 11, 2007 Share Posted July 11, 2007 (edited) Great.Glad we sort of helped.Edit: Yay, 2000th Post. Edited July 11, 2007 by JBr00ks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
ASawyer Posted July 11, 2007 Author Share Posted July 11, 2007 You guys helped a lot. And for the record, I had looked at both that other product and AutoIt, and I chose AutoIt. I really have not used the other product, but I guess I was thinking of hotkeys??? That's the best excuse I can come up with, and also that I'm old.. Alan 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