Sign in to follow this  
Followers 0
coolness

How Do I Program Multiple Hotkey Funtions?

8 posts in this topic

Here is the script that I do have. it will allow me to choose one hotkey to auto write one message. but when I try to duplicate that sectoin of code, and change [f1} to {F2} in the secound string, it says its a duplicate funtion. please help, if you can.

run("notepad.exe")

HotKeySet( "{F1}", "_Open")

While 1

Wend

Func _Open ()

send("Yes f1 wrote this.")

send("{enter}")

EndFunc ;==>_Open

that script works just fine.

this one doesn't work.

run("notepad.exe")

HotKeySet( "{F1}", "_Open")

While 1

Wend

Func _Open ()

send("Yes f1 wrote this.")

send("{enter}")

EndFunc ;==>_Open

HotKeySet( "{F2}", "_Open")

While 1

Wend

Func _Open ()

send("Yes f2 wrote this.")

send("{enter}")

EndFunc ;==>_Open

Could someone please tell me what I'm doing wrong?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You only need one _Open function, you have 3 :).

Wops, sorry.. well i'll correct your script:

HotKeySet( "{F1}", "_Open1")
HotKeySet( "{F2}", "_Open2")
run("notepad.exe")

Func _Open1()
send("Yes f1 wrote this.")
send("{enter}")
EndFunc;==>_Open

Func _Open2()
send("Yes f2 wrote this.")
send("{enter}")
EndFunc;==>_Open

While 1
Sleep(200)
WEnd
Edited by viking

Share this post


Link to post
Share on other sites

Mind using the normal forum font?

anyway, to answer your question:

run("notepad.exe")
HotKeySet( "{F1}", "_Open1")
HotKeySet( "{F2}", "_Open")
While 1
sleep(10000)
Wend
Func _Open ()
send("Yes f2 wrote this.")
send("{enter}")
EndFunc;==>_Open

Func _Open1 ()
send("Yes f1 wrote this.")
send("{enter}")
EndFunc;==>_Open

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

Thanks cd, it worked. Do you know what I would add to the script, to end on Esc hotkey?

Share this post


Link to post
Share on other sites

HotKeySet("{ESC}", "Terminate")
Func Terminate()
Exit
EndFunc

Simple as that ;-)

Share this post


Link to post
Share on other sites
Thanks viking. I had to change func name, but it worked great. I mentioned earlyer about being able to run multiple hotkeys. I can run f1-f12 as hotkeys. However I would like to add a ctrl+whatever alt+whatever, as hotkeys too. example ctrl+q or ctrl+qw Or Alt+Q or Ctrl+QW. could someone tell me how to add that to the script?

Share this post


Link to post
Share on other sites

Look in the helpfile under Send.

Share this post


Link to post
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
Sign in to follow this  
Followers 0