Jump to content
Sign in to follow this  
Markken

Need help to edit my code

Recommended Posts

Markken

My code didn't work with Crtl Key...... Please help to edit........................

I wrote the code that I am descripting. It can be called Key Mapping (Not Replacing). It means if I press a key, another key also performs. For example; when I press Key "1", Key "q" also performs at the same time. The keys below are the keys mapping that I want:

"1" mapping with "q"

"2" mapping with "w"

"3" mapping with "e"

"4" mapping with "r"

They work proberly if I dont hold Crtl Key, but the key: q, w, e, r don't run when I am holding Crtl Key and trying to press 1, 2, 3, 4.

So please help me to write the code that I can holp down Crtl Key and be pressing 1, 2, 3, 4, and then q, w, e, r also perform at the same time.

.....................................

Below is my code (That doesn't work with Ctrl)

#include "misc.au3"

_Singleton(@ScriptName)

; set hotkeys

HotKeySet("{ESC}", "Terminate")

HotKeySet(Chr(Asc('1')), "No1")

HotKeySet(Chr(Asc('2')), "No2")

HotKeySet(Chr(Asc('3')), "No3")

HotKeySet(Chr(Asc('4')), "No4")

While GUIGetMsg() <> -3

Sleep(1000)

WEnd

; send broken alphabets

Func No1()

HotKeySet("1")

Send("1")

Send("q")

HotKeySet(Chr(Asc('1')), "No1")

EndFunc

Func No2()

HotKeySet("2")

Send("2")

Send("w")

HotKeySet(Chr(Asc('2')), "No2")

EndFunc

Func No3()

HotKeySet("3")

Send("3")

Send("e")

HotKeySet(Chr(Asc('3')), "No3")

EndFunc

Func No4()

HotKeySet("4")

Send("4")

Send("r")

HotKeySet(Chr(Asc('4')), "No4")

EndFunc

Func Terminate()

Exit 0

EndFunc

Share this post


Link to post
Share on other sites
JFee

_IsPressed might be a better way to do this instead of hotkeys.

Also, next time could you wrap your code in the CODE tags? (There is a button when you are creating or editing a post). Thank you for posting your code though muttley


Regards,Josh

Share this post


Link to post
Share on other sites
Cha0sBG

#include "misc.au3"

_Singleton(@ScriptName)

; set hotkeys
HotKeySet("{ESC}", "Terminate")

HotKeySet(Chr(Asc('1')), "No1")
HotKeySet(Chr(Asc('2')), "No2")
HotKeySet(Chr(Asc('3')), "No3")
HotKeySet(Chr(Asc('4')), "No4")

While GUIGetMsg() <> -3
Sleep(1000) 
WEnd

; send broken alphabets

Func No1()
HotKeySet("1")
Send("1" & "{CTRL}") 
Send("q" & "{CTRL}")
HotKeySet(Chr(Asc('1')), "No1")
EndFunc

Func No2()
HotKeySet("2")
Send("2" & "{CTRL}") 
Send("w" & "{CTRL}")
HotKeySet(Chr(Asc('2')), "No2")
EndFunc

Func No3()
HotKeySet("3")
Send("3" & "{CTRL}") 
Send("e" & "{CTRL}")
HotKeySet(Chr(Asc('3')), "No3")
EndFunc

Func No4()
HotKeySet("4")
Send("4" & "{CTRL}") 
Send("r" & "{CTRL}")
HotKeySet(Chr(Asc('4')), "No4")
EndFunc

Func Terminate()
Exit 0
EndFunc

Hope This Works muttley

Edited by Cha0sBG

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Share this post


Link to post
Share on other sites
Markken

#include "misc.au3"

_Singleton(@ScriptName)

; set hotkeys
HotKeySet("{ESC}", "Terminate")

HotKeySet(Chr(Asc('1')), "No1")
HotKeySet(Chr(Asc('2')), "No2")
HotKeySet(Chr(Asc('3')), "No3")
HotKeySet(Chr(Asc('4')), "No4")

While GUIGetMsg() <> -3
Sleep(1000) 
WEnd

; send broken alphabets

Func No1()
HotKeySet("1")
Send("1" & "{CTRL}") 
Send("q" & "{CTRL}")
HotKeySet(Chr(Asc('1')), "No1")
EndFunc

Func No2()
HotKeySet("2")
Send("2" & "{CTRL}") 
Send("w" & "{CTRL}")
HotKeySet(Chr(Asc('2')), "No2")
EndFunc

Func No3()
HotKeySet("3")
Send("3" & "{CTRL}") 
Send("e" & "{CTRL}")
HotKeySet(Chr(Asc('3')), "No3")
EndFunc

Func No4()
HotKeySet("4")
Send("4" & "{CTRL}") 
Send("r" & "{CTRL}")
HotKeySet(Chr(Asc('4')), "No4")
EndFunc

Func Terminate()
Exit 0
EndFunc

Hope This Works muttley

Thanks alot, but this still doesn't work. :)

Or you have other ways; please help.... Thanks

Edited by Markken

Share this post


Link to post
Share on other sites
Markken

_IsPressed might be a better way to do this instead of hotkeys.

Also, next time could you wrap your code in the CODE tags? (There is a button when you are creating or editing a post). Thank you for posting your code though muttley

Oh.... I don't have much knowledge of its code. if _IsPressed might work, please help me to write this code. Thanks

Share this post


Link to post
Share on other sites
Cha0sBG

Open A New AutoIt Script And Press F1 Then The Help File Will Open ==> Go To "Index" And Search For _IsPressed ^^


Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Share this post


Link to post
Share on other sites
Cha0sBG

Never Mind Found A Way...


Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.