How to do a click-drag-release with Simulated Keys

x64 Replacement/Alternative to Microsoft's IntelliMouse application.
Forum rules
Please read the forum rules before posting for the first time.
The more information you can provide, the quicker and more accurately someone can help.
NOTE: To reduce spam, new users can not post links, files or images until they have at least 4 posts.
Post Reply
Zartanian
New User
Posts: 3
Joined: Sun May 15, 2022 11:47 pm

How to do a click-drag-release with Simulated Keys

Post by Zartanian »

Please fill in this template when posting!
XMBC Version: v2.19.2
Installed or Portable version:Installed
Windows Version: Windows 10 Pro version 21H2 build 19044.1645
Mouse Information (brand/model): built-in touch pad
Relevant Computer Information (CPU, RAM etc): Intel i7-4600M 16GB DDR3 RAM
Did the problem occur after an upgrade of XMBC? (If so, from what version?): no
Did the problem occur after a Windows update/upgrade? (If so, from what version?): no
How long have you used XMBC?: 2 years
What language and keyboard layout do you use in Windows?: English (United States)

Clear description of the problem - try and include as much information as possible, including what button and mappings you are having problems with (if applicable).: I am attempting, and sadly failing, to find a way of setting up an automatic click-drag-release within a macro made in the "Simulated Keys" section. Short version (which I will explain in more detail below) is that I am attempting to build a macro to auto-play an idle game of mine when I am afk or asleep. There are many different moving parts needed however, so it is proving quite difficult.

For the most part, the game can be played via only the arrows, and clicking through 2 menus. However, there is a random event that appears at random (as name implies) and when it appears, it stops all forward progress possible, pretty much pausing the game, until you click and drag a slider bar. Now, luckily, this slider bar always appears in the exact same location, however I cannot find a way of adding a click-drag-release to the macro. my idea is that for each loop, it starts by clicking and dragging where the slider bar is, so if it appeared during the last loop it can be passed, and progress can continue. I have a feeling that this ability is actually here, but I just am not seeing it myself, or not recognizing it for what it is. the game in question is Idle Slayer from Steam, if that is at all important. I already have many seperate macros created for the game, so I know XMBC works in it, so that's not an issue itself. Help is appreciated.

User avatar
phil
Site Admin
Posts: 6983
Joined: Sun Apr 06, 2003 11:12 pm

Re: How to do a click-drag-release with Simulated Keys

Post by phil »

Ive done something similar again that involved moving ad clicking so I suspect it will be possible, but it will depend very much on how the application/game handles it - and its quite complex/involved.... In my case I had to click different (known) positions, rather than drag.... but

But something like this might work, or at least get you on the right track.

{LOCKXY}{MSAVE:1}{LMBD}{MSET:<X>,<Y>}{WAITMS:90}{WAITMS:90}{MADD:200,0}{LMBU}{MREST:1}{UNLOCKXY}

NOTE: The MSAVE/MRESET is to put the cursor back where it was after the macro finishes.
MSET sets the cursor to the initial X/Y (if you want to do this relative to the window INSTEAD of the whole screen use {ASET:X,Y})

Let me know if that helps/works!
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)

Zartanian
New User
Posts: 3
Joined: Sun May 15, 2022 11:47 pm

Re: How to do a click-drag-release with Simulated Keys

Post by Zartanian »

phil wrote:
Mon May 16, 2022 8:29 am
Ive done something similar again that involved moving ad clicking so I suspect it will be possible, but it will depend very much on how the application/game handles it - and its quite complex/involved.... In my case I had to click different (known) positions, rather than drag.... but

But something like this might work, or at least get you on the right track.

{LOCKXY}{MSAVE:1}{LMBD}{MSET:<X>,<Y>}{WAITMS:90}{WAITMS:90}{MADD:200,0}{LMBU}{MREST:1}{UNLOCKXY}

NOTE: The MSAVE/MRESET is to put the cursor back where it was after the macro finishes.
MSET sets the cursor to the initial X/Y (if you want to do this relative to the window INSTEAD of the whole screen use {ASET:X,Y})

Let me know if that helps/works!
Hey, that worked a charm, thanks! Ended up causing an issue further down the macro chain though, I think due to however long an action takes. Long story short, in the game your character jumps higher depending on how long you hold the jump button, via experimentation i found that holding it for 80ms has the perfect hieght to collect everything while not going over the bonus chests, with 600ms between jumping and landing to jump again. This works perfectly, every time. However, when filling in that 600ms with 2 attacks and a boost, suddenly the jump height is now randomized (which is not a feature of the game, jump height is always due to the length of time a button is held). I assume that this is due to however many ms it takes for a button press to actually be done within the macro, as the attack button and jump button are the same. Below is the code I have so far for this aspect of it, if you could possibly help me with it?

{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}

this holds the jump for 80ms, making it the proper height, and spends the 600ms of wait between jumping and landing to fire 2 shots (UP) and 2 boosts (RIGHT). the 4 150ms waits are supposed to be the 600ms in total for it to work, and it no longer does. If you would rather I make a new post for this aspect, I will, but I figured I could just reply here since you are helping already.

User avatar
phil
Site Admin
Posts: 6983
Joined: Sun Apr 06, 2003 11:12 pm

Re: How to do a click-drag-release with Simulated Keys

Post by phil »

No need for a new post as its quite related!

But I'm not sure I can help much with that - sounds like you need to adjust the timings - how did you integrate the second macro ({HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}) with the stuff I suggested?

Is it in one sequence?
like {LOCKXY}{MSAVE:1}{LMBD}{MSET:<X>,<Y>}{WAITMS:90}{WAITMS:90}{MADD:200,0}{LMBU}{MREST:1}{UNLOCKXY}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}

If so, maybe adjust the order of things...
{LOCKXY}{MSAVE:1}{LMBD}{MSET:<X>,<Y>}{WAITMS:90}{WAITMS:90}{MADD:200,0}{LMBU}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{MREST:1}{UNLOCKXY}

Difficult to know without having the thing to test it on really!
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)

Zartanian
New User
Posts: 3
Joined: Sun May 15, 2022 11:47 pm

Re: How to do a click-drag-release with Simulated Keys

Post by Zartanian »

phil wrote:
Mon May 16, 2022 5:46 pm
No need for a new post as its quite related!

But I'm not sure I can help much with that - sounds like you need to adjust the timings - how did you integrate the second macro ({HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}) with the stuff I suggested?

Is it in one sequence?
like {LOCKXY}{MSAVE:1}{LMBD}{MSET:<X>,<Y>}{WAITMS:90}{WAITMS:90}{MADD:200,0}{LMBU}{MREST:1}{UNLOCKXY}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}

If so, maybe adjust the order of things...
{LOCKXY}{MSAVE:1}{LMBD}{MSET:<X>,<Y>}{WAITMS:90}{WAITMS:90}{MADD:200,0}{LMBU}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{MREST:1}{UNLOCKXY}

Difficult to know without having the thing to test it on really!
Okay, so, for clarification, the timing thing is something that I have already figured out. with the above snippet of the macro (which is repeated 8 seperate times), the timing via testing is hold for 80ms, wait 600ms, hold 80ms. that works completely on its own. so this {HOLDMS:80}{UP}{WAITMS:600} when set to loop has the perfect timing. However, when replacing the {WAITMS:600} with {UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150} (to use up the 600ms wait time with the other needed actions) it breaks and becomes quite random instead. Below is the entirety of the macro, as opposed to just snippets, if you would like to see it. be warned however, for it is quite long. I had only shared a snippet of it before, as it's a snippet used many times in the full macro, with other things inserted at certain intervals. In regards to the below code, if you were to do a find/replace to turn all instances of "{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}" into "{HOLDMS:80}{UP}{WAITMS:600}" then the macro as is works fine, however without the added attacks and boosts. Hence my belief of the timing being broken by however many MS each button press takes by default.

Tl;DR: This works: {HOLDMS:80}{UP}{WAITMS:600} but this, which should take the same amount of time, does not: {HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}.

{ASET:230,350}{LMBD}{WAITMS:100}{MADD:407,0}{WAITMS:100}{LMBU}{WAITMS:100}{ASET:407,350}{LMBD}{WAITMS:100}{MADD:-407,0}{WAITMS:100}{LMBU}{WAITMS:100}{ASET:465,441}{MSAVE:1}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{LMB}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{ASET:586,234}{MSAVE:2}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{LMB}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{ASET:426,434}{MSAVE:3}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{LMB}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{ASET:581,354}{MSAVE:4}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{LMB}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{MREST:1}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{LMB}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{MREST:2}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{LMB}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{MREST:3}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{LMB}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{MREST:4}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{LMB}{HOLDMS:80}{UP}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}{UP}{WAITMS:150}{RIGHT}{WAITMS:150}

User avatar
phil
Site Admin
Posts: 6983
Joined: Sun Apr 06, 2003 11:12 pm

Re: How to do a click-drag-release with Simulated Keys

Post by phil »

OK... I presume you have already tried reducing the 150's to 140's? Because each key is going to take some time (and if you have the default set of 5ms delay between simulated keys (advanced settings), its going to take at least 6ms I'd imagine.

Timing in Windows (at user level) is completely inaccurate because you are at the whim of the windows scheduler - which is not predictable or accurate - not a lot can be done about that. The smaller the delays, the more inaccurate it will be... Which may explain why the 600 works but 4 150's does not (there is also overhead for each command as I said).

I don't think I can help, other that to suggest adusting the delays till it works! It will potentially be different on every CPU too, and if other background tasks are going on (make sure XMBC CPU priority is high (or above normal) too which will at least mean XMBC is given preferential treatment by the scheduler) NOTE: the RealTime CPU priority option may not be working any more since Windows 10 (I think) and anyway it never was actually real time (because Windows is not a real time OS)!
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)

Post Reply