AutoHotKey Macro not working - macros

Hi all i have this piece of code that cant get it to work, please need an hand.
portal(){
portalCommand:
BlockInput On
SendInput {i}
Sleep 2
MouseClick, right, 1775, 795
SendInput {i}
Sleep 2
MouseClick, left, 955, 380
BlockInput Off
return
}
The problem here i dont know why is not sending or it does to fast input I then Right Click input i again and left click, any sugestions please?

Per my comment:
portal(){
portalCommand:
BlockInput On
SendInput i
Sleep 2000
MouseClick, right, 1775, 795
SendInput i
Sleep 2000
MouseClick, left, 955, 380
BlockInput Off
return
}

i forgot to mention that im bad at programming is just a hobby and need it for a game to open inventory when task"{i}" is pressed about sleep you are right i have made my home work in the mean time and read about autohotkeys and stuff and i got the perfect working result thanks anyway :) here is my working code that is what i wanted and i will wxplain aftewards (sry for my english guys i think is not so good i have not study english just learned on the way:)
portal(){
portalCommand:
BlockInput On
;Pressing Space if any inventory is open
Send {space}
Sleep 50
;Opening Inventory
SendInput {i}
Sleep 200
;Move the mouse to a specific location
MouseMove, 1770, 790
Sleep 400
;Pressing Mouse Right Button
Send, {RButton}
Sleep 400
;Move the mouse to a specific location
MouseMove, 600, 370
Sleep 400
;Pressing Mouse Left Button
Send, {LButton}
BlockInput off
return
}
The give up code is a solution for me that actually works without any issue and it does send spacebar (that is the game setup to close any inventory opened) then sends "i" key to open the inventory of the character and goes to defined location making righ click on town portal scroll and after that goes back to defined location and left click on it to enter to the portal (that means going to town) the position is based on the monitor max resolution so the coordinates can be adjusted for anyone needs in case someone else need or whant to use this code ;)

Related

Solution to AHK sending too many events when holding down a mouse button?

When using three different methods of holding down the left mouse button:
Mouseclick, left, 0, 0, 1, , D, R
or
Send {LButton down}
or
Click down
the game I'm making a macro for logs me out complaining that I'm sending too many actions. I tested this by itself as a script, like:
F3::
Click down
return
So there's no chance other code is causing it.
I was wondering if there are any settings I can use (by settings I mean like CoordMode, Mouse, Screen) or any other solution to perhaps prevent whatever rapid event sending AHK is using to simulate a mouse button being held down. Is there any possible fix I can try? I'm open to testing any ideas.
Well, you could introduce a Sleep like so:
LButton::
while (GetKeyState("LButton", "P"))
{
MouseClick, left
Sleep, 100
}
return
Though I personally dislike binding the mouse click to behaviours via the same mouse click, as it can lead to results that are difficult to get out of.
Here's an example with a toggleable hotkey.
Insert::
SendInput, {LButton Down}
loop
{
Sleep, 100
if getkeystate("Insert", "p") ; Hold for a second as the Sleep will delay recognition.
{
SendInput, {LButton Up}
break
}
}
return
Edited per the comments:
Insert::
SendInput, {LButton Down}
KeyWait, Insert, D
SendInput, {LButton Up}
return

Counter-Strike AWP Quick Switch

I am trying to make a script where, when I press the mouse one time, it will wait 120 milliseconds, then double tab Q. The problem is when I make the bind hooked up to my mouse1 it is overriding Counter-Strike and it wont shoot. It just double taps Q. Can anyone help me?
Insert::
Suspend
Return
LButton::
Sleep, 1000
if (GetKeyState("LButton"))
Send, q
Sleep, 30
Send, q
I believe that you still want counter strike to detect the mouse click also.
To do so, add a ~ in front of LButton::.
Result : ~LButton::
~ tells autohotkey to not block the hotkey's native function.
See more about Hotkey prefix symbols here: http://ahkscript.org/docs/Hotkeys.htm#Symbols

Using hotkey in specific application, what is wrong with my code?

This works:
wheeldown::
WinGetTitle, Title, A
WinGetClass, Class, A
if (RegExMatch(Title, "Poker"))
{coordmode, mouse, window
MouseGetPos, StartX, StartY
mouseclick, left, 325, 341
MouseMove, StartX, StartY
}
else
send {wheeldown}
return
This doesn't work
a::
WinGetTitle, Title, A
WinGetClass, Class, A
if (RegExMatch(Title, "Poker"))
{coordmode, mouse, window
MouseGetPos, StartX, StartY
mouseclick, left, 510, 342
send {Backspace}
send {Backspace}
send {Backspace}
send {Backspace}
send {Backspace}
send, 1.25
MouseMove, StartX, StartY
}
else
send {a}
return
Why it not work :(
Error message comes when I try to use "a" in a different application. Says 71 hotkeys used in 1000ms or something.
Add this to the top of your script:
#MaxHotkeysPerInterval 300 ;default is 70
The error you get is common to scripts where the mousewheel is captured and used alot. Autohotkey treats the mousewheel as a hotkey and thinks that you shouldn't push a hotkey more than 70 times per second. Scrolling can call the hotkey more times then that depending on usage. This line will allow more than 70.
three things, strictly speaking when using a hot key that has multiple lines of code the first line doesn't immediately follow the double colons. So this:
a:: WinGetTitle, Title, A
WinGetClass, Class, A
should be this:
a::
WinGetTitle, Title, A
WinGetClass, Class, A
Secondly the command that you are trying to find is called an imperative by the name of "#IfWinActive" or "#If" your regex should be used with latter of those to commands. There is a lot to that so you will need to look at those in the docs.
Lastly in the using a hotkey which sends itself you need to prefix it with "$" so that this:
a::
becomes:
$a::
Hope that helps with the question for any one looking atthis year old post.

Holding control, shift and v, using only one key

I am using lightroom for this hotkey. I dont know why is this doesn't work for me.
::{control}{sleep 5}{shift}{sleep 5}v
And Alt+F+↓(5x) then Enter.
And Alt+F+↓(5x) then Enter.
I don't know what you mean by that, because I can't see anything like that in your script. So I will just ignore it and do what the thread title and your script says/implies.
The following script will simulate pressing Ctrl+Shift+V when you press the A key
SetKeyDelay, 5 ;wait 5 milliseconds between every keystroke
a::^+v
About your comment, I guess I know what you are on to, try this:
SetKeyDelay, 5 ;wait 5 milliseconds between every keystroke
2::
SendInput, !f
Sleep, 50
SendInput, {Down}{Down}{Down}{Down}{Down}{Enter}
Return

How Can I Use Upside Numpad?

I am using AutoHotkey. This Program I want to use left side numpad in my script but I couldn't use it.This case is important because I play a game and that game use left side numpad,not right side. (Right side numpad doesn't work in this game)
This is my code;
SendMode Input
~control::
Loop
{
if GetKeyState("e") ; If this statement is true, the user has physically released the F1 key.
break ; Break out of the loop.
send,{Numpad8}
Sleep 200
send,1
Sleep 200
}
return
Any idea?
Edit = I don't know how can I show this problem. How can you understand this Send command press left side's numpad or right side? I play Knight Online game and I can try these methods in the game.Code works or not.But could you try it ?
Here you have all the keys AutoHotkey handles:
http://www.autohotkey.com/docs/commands/Send.htm
Just change send,{Numpad8} to Send,{1}
You can also try to simulate a keypress this way (The last time I used AutoHotkey I had to do it):
Send, {1 down}
Sleep 100
Send, {1 up}
And also, you can try to send the keystrokes directly to the window this way:
wintitle = WINDOW TITLE
Controlsend,,{1 down}, %wintitle%
Sleep 100
Controlsend,,{1 up}, %wintitle%
THe window title can be the starting characters of the window. For example, if the window title is "This is a game", you can set as window title in your script "This is a".