Hopelessly stuck Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Zlysium
Posts: 9
Joined: 18 Jun 2017, 17:39

Hopelessly stuck

18 Jun 2017, 18:03

I'm trying to make a script that will, after the user left clicks, will move the cursor to a predetermined location on the screen, left click there, and then move back to the original position. and not just one time but every time with a toggle to turn it on/off i don't know how to do most of that but what i've got so far is:

f12::

~LButton::
MouseGetPos, StartX, StartY
Sleep 100
click 800, 600
MouseMove, StartX, StartY


return



which clearly isn't working as intending. all help much appreciated <3

the idea for the click to be in the active window and the cursor to return to wherever the original click came from. i think i got that part figured out at least :)
Zlysium
Posts: 9
Joined: 18 Jun 2017, 17:39

Re: Hopelessly stuck

18 Jun 2017, 18:32

It wasn't working, as is, after increasing the sleep to 300 and adding another sleep 100 after mousemove it functioned perfectly! No idea why honestly but hey it works! Now i wonder is there a way to make the entire script only function in the chosen application and not work elsewhere? like IfWinActive ? i'm not certain how it works honestly. If the IfWinActive is called then presumably the chosen window must be active for ANY part of the script to function right? including the toggle?
Zlysium
Posts: 9
Joined: 18 Jun 2017, 17:39

Re: Hopelessly stuck

18 Jun 2017, 18:32

It wasn't working, as is, after increasing the sleep to 300 and adding another sleep 100 after mousemove it functioned perfectly! No idea why honestly but hey it works! Now i wonder is there a way to make the entire script only function in the chosen application and not work elsewhere? like IfWinActive ? i'm not certain how it works honestly. If the IfWinActive is called then presumably the chosen window must be active for ANY part of the script to function right? including the toggle? And TYVM
Zlysium
Posts: 9
Joined: 18 Jun 2017, 17:39

Re: Hopelessly stuck

18 Jun 2017, 18:37

Sorry further testing finds a fault, the click that calls the getPOS doesn't go through i guess? It's like it gets intercepted or something, i left click, everything works after that such as the click at 800/800 and the mouse returns to the start position, but the click that starts it all doesn't actually do anything outside of the script!
SirRFI
Posts: 279
Joined: 25 Nov 2015, 16:52

Re: Hopelessly stuck

18 Jun 2017, 18:46

Using the following will make the hotkeys work only in given process window - insert it before the hotkey.

Code: [Select all] [Download] GeSHi © Codebox Plus

#if (WinActive("ahk_exe your_process.exe"))



On side note: coords may be refering to active window, see here: CoordMode https://autohotkey.com/docs/commands/CoordMode.htm
Use [code=autohotkey] forum tag to share your code.
Click on (Accept this answer) on top-right part of the post if it has answered your question / solved your problem.
Zlysium
Posts: 9
Joined: 18 Jun 2017, 17:39

Re: Hopelessly stuck

18 Jun 2017, 18:50

I tried this to try and fix the original click not functioning as it's being used to get the position of the mouse
f12::Suspend, Toggle

LButton::
MouseGetPos, StartX, StartY
Click StartX, StartY
Sleep 200
click 958, 345
Sleep 200
MouseMove, StartX, StartY
return

and that doesn't work. Is there not a way to click at startx and y or am i just using the wrong command?
Zlysium
Posts: 9
Joined: 18 Jun 2017, 17:39

Re: Hopelessly stuck

18 Jun 2017, 19:12

After realizing i could just send 'click" since the mouse is already there. i tried that. but it doesn't work. it seems while the script is running left click doesn't function outside of calling the script itself to do its job. is there a way to have it do both? or does AHK intercepting it means it no longer gets to its intended destination?
Zlysium
Posts: 9
Joined: 18 Jun 2017, 17:39

Re: Hopelessly stuck

18 Jun 2017, 19:25

Now functioning fully after switching to using right click as the hotkey instead of left click, freeing up leftclick for normal use during.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bad husband, Bing [Bot], Class1, DarkKitten, geekgarage, Google [Bot], jhubler, Rastahammer and 41 guests