Jump to content

Simple HotKey


Recommended Posts

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

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)
Link to comment
Share on other sites

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...