Multiple Commands on 1 Script

Get help with using AutoHotkey and its commands and hotkeys
RPGcfh
Posts: 3
Joined: 20 Apr 2020, 20:01

Multiple Commands on 1 Script

22 Apr 2020, 01:55

Hi,

Sorry I am a newbie at this, I have been trying to get my code to work. I have a different program that has its own hot key and requires me to hit window+C to activate, but I notice that when my Mousemove to the coordinate, my program does not activate on window+C. I've added a bunch of sleeps because it takes time for my mouse to get to a certain coordinate. Sorry for it being messy, again I am a newbie. I've spent a lot of time and cannot figure it out. Is it my layout of the code, is there a more efficient way?

#MaxThreadsPerHotkey 10

F1::

toggle:=!toggle
While toggle{
MouseGetPos, PosX, PosY
MouseMove, 364, 941 ;move mouse to coordinate
Sleep 1000
Send, {Lwin down}{c down} ;activate my program, but it always fails to activate my other program's hotkey
Sleep 500
Send, {Lwin up}{c up} ;release buttons so my keys don't get stuck?
Sleep 1000
Send, {LButton Down}
MouseMove, 817, 984
Send {LButton Up} ;to drag from coordinate to coordinate
Sleep 1500
Mouseclick, left, , , 1; click to activate
Sleep 1500
MouseMove, 430, 1024 ;to move to coordinate
Sleep, 1000
Send, ^v
Sleep, 1000
Send, {Enter}
}
Return

Thanks in advance!
User avatar
Scr1pter
Posts: 1200
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Multiple Commands on 1 Script

22 Apr 2020, 07:07

Hi,

I guess by "activate program" you mean to bring it in foreground/focus.
You can use WinActivate and WinWaitActive for that.
(Check the AHK documentation).
https://www.autohotkey.com/docs/commands/WinActivate.htm

If your cursor does not move quickly enough,
you can add a 0.
MouseMove, 817, 984, 0

Also, why do you move the cursor and then activate the program?
The other way around makes more sense to me.

Cheers!
Please use [code][/code] when posting code!
Keyboard: Logitech G15 FE - Mice: Logitech G9 FE, G502 FE, G602, Jelly Comb Touchpad - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.32.00

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], braunbaer, dw0rd1337, hasantr, manbat42, TAC109 and 40 guests