# Help with SetHotKey

## Recommended Posts

Hey ya!

I want 2 scripts for:

1. "Pressing J and doing until I press J again"

2. "Pressing N and do the script 1 time. If i press N again it should do it 1 time again... And so on!

I just need these Basics, i dont understand the structure.

I tried with:

If getInput"J" then $i = 1 While$i = 1

send ("hey")

If get Input"J" then $i = 0 WEnd but i need the command for this "getInput"J"" Pls Help me! ##### Link to post ##### Share on other sites Hey ya! I want 2 scripts for: 1. "Pressing J and doing until I press J again" 2. "Pressing N and do the script 1 time. If i press N again it should do it 1 time again... And so on! I just need these Basics, i dont understand the structure. I tried with: If getInput"J" then$i = 1

While $i = 1 send ("hey") If get Input"J" then$i = 0

WEnd

but i need the command for this "getInput"J""

Pls Help me!

If you look at the example in the helpfile for HotKeySet you will see how to toggle a function, run a function whenever a key is pressed and how to exit the script.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

##### Share on other sites
• Moderators

I can't make heads or tails of what exactly you are trying to accomplish. Can you post your script and tell us what it is for 'In complete detail'?

Also: http://www.autoitscript.com/forum/index.ph...topic=19439&hl= You've already posted a topic on this subject hadn't you?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites
• Moderators

Although I feel that HotKeySet() would be better for this, if you used keys like F1 / F2, here is an example of how I'm interpreting your request.

While 1
If _IsPressed("4A") Then
While 1
Sleep(100)
If _IsPressed("4E") Then
_GoToMainScript()
ExitLoop
EndIf
If _IsPressed("4A") Then
ExitLoop
EndIf
WEnd
EndIf

If _IsPressed("4E") Then _GoToMainScript()
Sleep(10)
WEnd

Func _GoToMainScript()
;Do once script
EndFunc

Func _IsPressed($s_hexKey,$v_dll = 'user32.dll')
Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
Return 0
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

@smoke old topic was for general question

i thought to make it clearer just to look on the command "sethotkey" and "hotkeyset"

i think iam too stupid, could someone make me this basic? where i just have to fill my password in?

its for a chatroom, its sometimes full and i want to write a login bot what to toogle on/off

and for N i want specifie a sentense "Hey XXXXXX" and so on. thats where i need it for.

could someone tell me, how to insert "Pressing2 keys at the same time --> for example: ALT+F4

pls i know some basics of scripting but i dont understand the example in help file =(

##### Share on other sites
• Moderators

Hmmm, I did exactly as you requested in your first post, if you press 'J' it will send you to the next loop, where you can put in whatever you want to do., and while there, you can put whatever send commands you want, and if you Press 'N' while there you can go to your do once script. All you have to do is fill in the blanks.

Now, the help file again explains doing things like Alt+F4, look at the 'Send Commands' in help.

HotKeySet("!{F4}", "Testing")

While 1
Sleep(1000)
Wend

Func Testing()
EndFunc

These things can be found here: http://www.autoitscript.com/autoit3/docs/a...ix/SendKeys.htm

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

@smoke old topic was for general question

i thought to make it clearer just to look on the command "sethotkey" and "hotkeyset"

i think iam too stupid, could someone make me this basic? where i just have to fill my password in?

its for a chatroom, its sometimes full and i want to write a login bot what to toogle on/off

and for N i want specifie a sentense "Hey XXXXXX" and so on. thats where i need it for.

could someone tell me, how to insert "Pressing2 keys at the same time --> for example: ALT+F4

pls i know some basics of scripting but i dont understand the example in help file =(

mk:@MSITStore:C:\Program%20Files\AutoIt3\beta\AutoIt3.chm::/html/functions/Send.htm

does that link do anything for you?

##### Share on other sites

$i = 0 Global$Paused
HotKeySet("{PAUSE}", "TooglePause")
HotKeySet("n", "Hi")
Func TooglePause()
$Paused = NOT$Paused
While $Paused sleep(100) WEnd EndFunc Func Hi() send ("hi") send ("{ENTER}") EndFunc Do send ("{TAB}") send ("XXXXXX") send ("{ENTER}") sleep("1500") send ("{ENTER}{ENTER}{ENTER}{ENTER}") Until$i = 10

ok thats working now, but how to start it "paused" that i have to start it with {PAUSE} first?

and: what is the command for Alt+F4 ?

send ("{Alt"},"F4") ???

Edited by TheRaZoR
##### Share on other sites

$i = 0 Global$Paused
HotKeySet("{PAUSE}", "TooglePause")
HotKeySet("n", "Hi")
Func TooglePause()
$Paused = NOT$Paused
While $Paused sleep(100) WEnd EndFunc Func Hi() send ("hi") send ("{ENTER}") EndFunc Do send ("{TAB}") send ("XXXXXX") send ("{ENTER}") sleep("1500") send ("{ENTER}{ENTER}{ENTER}{ENTER}") Until$i = 10

ok thats working now, but how to start it "paused" that i have to start it with {PAUSE} first?

and: what is the command for Alt+F4 ?

send ("{Alt"},"F4") ???

try

Send("!{F4}")
it's explained in the helpfile.... Edited by cameronsdad
##### Share on other sites

how to start this script "paused"? that i have to start it with "{PAUSE}" first?

##### Share on other sites
• Moderators

Try Send("{PAUSE}") right under the HotkeySets.

HotKeySet("{PAUSE}", "TooglePause")
HotKeySet("n", "Hi")
Send("{PAUSE}")

Does that work?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

i forgot to write in here ^^ i did that already xD

pls could someone give me the shortcut for mouse 3,4,5 keys?

Edited by TheRaZoR
##### Share on other sites
• Moderators

Afraid to post an answer in here, everytime I post what you want, you find a way to shoot holes in it...

What do you want to do with those buttons, make them do something or if they are pressed do something? You're not very specific.

_IsPressed

--------------------------------------------------------------------------------

Check if key has been pressed

#Include <Misc.au3>

_IsPressed($s_hexKey[,$v_dll = 'user32.dll'])

Parameters

$s_hexKey key to check for$v_dll Optional: Handle to dll or default to user32.dll

Return Value

Success: Returns 1 if true.

Failure: Returns 0 if false.

Remarks

01 Left mouse button

02 Right mouse button

04 Middle mouse button (three-button mouse)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...