Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

User Image
Jcee
205 discussion posts
So Im trying to make a function/macro that occurs when I press the space bar. There are 2 issues
1 I only want it to run when a specific game is the focus
2 Space-bar does something in the game, and I would like it to continue to work (so I need the function to disable itself, pass the hotkey through, and then re-enable)

Heres what I have sofar:

Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
int startX = BFS.Input.GetMousePositionX();
int startY = BFS.Input.GetMousePositionY();
BFS.Input.LeftClickMouse();
BFS.Input.SetMousePosition(960, 540);
BFS.General.Sleep(10);
BFS.Input.LeftClickMouse();
BFS.Input.SendKeys("");
BFS.General.Sleep(10);
BFS.Input.SetMousePosition(startX, startY);

}
}
Jun 5, 2015  • #1
User Image
DS1508
37 discussion posts
Try this:

Code

using System;
using System.Drawing;

// The 'windowHandle' parameter will contain the window handle for the:
//   - Active window when run by hotkey
//   - Window Location target when run by a Window Location rule
//   - TitleBar Button owner when run by a TitleBar Button
//   - Jump List owner when run from a Taskbar Jump List
//   - Currently focused window if none of these match
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
//if we failed to get the focused window, exit the function
if (windowHandle == IntPtr.Zero)
return;
//check if it's the correct window. using the Window-Title.
if ( BFS.Window.GetText(windowHandle).Contains("Firefox") )
{
int startX = BFS.Input.GetMousePositionX();
int startY = BFS.Input.GetMousePositionY();
BFS.Input.LeftClickMouse();
BFS.Input.SetMousePosition(960, 540);
BFS.General.Sleep(10);
BFS.Input.LeftClickMouse();
BFS.Input.SendKeys(" ");
BFS.General.Sleep(10);
BFS.Input.SetMousePosition(startX, startY);
}
else
{
BFS.Input.SendKeys(" ");
}

}
}
Jun 6, 2015  • #2
User Image
Jcee
205 discussion posts
Thanks.that.solves.1.of.the.problems.now.i.still.need.to.be.able.to.use.the.space.bar.outside.and.inside.of.firefox.or.whatever.program.i.choose
Jun 6, 2015 (modified Jun 6, 2015)  • #3
User Image
DS1508
37 discussion posts
Space is still send with this function. But it always executes this script.

It you want to use something like this in a game, i suggest you use another program. Don't know what's available. I own a Logitech Gaming Mouse and Keyboard with extra buttons, that i can assign scripts to. That works much better than redirecting normal keys.
Jun 6, 2015  • #4
User Image
Jcee
205 discussion posts
So there's no way to send the keypress past display fusion? I couldn't even type the spaces in my last post while the script was active (even outside of firefox) Like disabling the function for .1 seconds, send it, and re-enable the function?
Jun 6, 2015  • #5
User Image
DS1508
37 discussion posts
I don't know. I own DF just a few days. Maybe a Dev answers you.
Jun 7, 2015  • #6
Keith Lammers (BFS)'s profile on WallpaperFusion.com
To clarify, are you using the Spacebar as the hotkey that triggers this function? The problem with this is that when the script runs, it sends a space, but then DF picks that up again, and runs the script again, and so on, putting itself into a loop. At the moment, there's no way for the script to say "if whatever, just pass the hotkey through and exit the script." However, I'll see if this is something we could add.
Jun 8, 2015  • #7
User Image
Jcee
205 discussion posts
Yep that is exactly the issue.. Spacebar is the hotkey, that I want to trigger the script, however I would also need it to function normally. in, and outside of the specified program

So i don't need if-whatever pass it through, I need to ALWAYS pass it through. but only run the custom function If the game is the focus.

(IE in the game Im playing, pressing spacebar centers the camera on your character) (and the code, I want to add would center the mouse, click (on your character) and then move the mouse back to its original location.)

I figured it wasn't possible currently, and would envision it to be a checkbox right next to 'key combination' thats labeled 'Pass HotKey Through'
Jun 8, 2015  • #8
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Ok, I think we'd need to add a scripting function to disable hotkeys while the script is running, or something like that. I'll put this on our list for further investigation :)
Jun 9, 2015  • #9
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)