I wrote some Apple script to take advantage of the extra buttons of my mouse (say invoke 'Back' from my web browser) and it runs fine inside AppleScript editor. Now I'd like to bind it to my mouse's 'Button 4'. Saving the script as 'script' or 'bundle' would only cause the button-click to open the editor instead of executing it. Saving it as 'Application' will do the work but it involves opening the application, doing its job, and exiting the application, so each time there's a flash. Any way to get rid of this flash? One way is to run the script in the background but I don't know how.
I use Butler for this kind of thing. You can assign a keystroke to your mouse button, then tell Butler to run your script on that keystroke.
I can't help but wonder if there's not built in support for that already with your mouse's software, though. I can't remember the last mouse I had that the 'Back' option wasn't built-in.
My suggestion would be to use a program that can run a script with keyboard shortcuts. Here's a free one. Then instead of running the script from a mouse button, you just assign the mouse button to perform the keyboard shortcut.
Related
With a game application (may have been minimized or hidden), I have a button that only shows up when I hover over it. I need to write an script (by c# or python) that can click that button without moving my cursor. I was able to simulate click event with SendMessage(hWnd, WM_LBUTTONDOWN, ...), but i don't know how to make that button show up.
I have seen a tool that can do it, I don't know how they do it.
My problem seems similar to this problem.
I won't need SendInput or mouse_event because it will move my cursor.
Any one can help? Is there another unrelated way?
I am trying to make a script to take the non functional ingame side buttons of my mouse and redirect them to keyboard keys. I successfully did that however there is a problem, every time I press the hotkey running the script my game minimizes. is there any way to stop this? thx
I have a 3 monitor setup which is connected to a PC. It displays a Google Chrome tab on each of the screens with some dashboard. It will auto log off every night from the website (I cannot control that). So I need to manually login to it, open the tabs, then move it to each of the monitors every night. I am trying to automate this task. I am trying to use Sikuli slides to do it. Right now I am able to login, open tabs, and click on buttons. But I am not able to drag the tabs to other monitors. It doesn't matter which tab is displayed in which monitor. The PC is running Windows 7. How can I get it done ? Any scripting language or tool which is available in windows is fine. Thanks in advance.
Edit: Added an image which describes my need
You're opening the same thing on the same computer on the same screens, so it will be in the same place every time.
AutoHotKey (AHK) can do click-and-drag from a start coordinate to an end coordinate:
https://autohotkey.com/docs/commands/MouseClickDrag.htm
Run AutoHotKey, right click on the icon in the taskbar notification area (systray) and click 'Window Spy', and it will bring up AHK's helper tool. Now you can click on the Chrome tabs and look in AHK to see the coordinates of the mouse pointer, so you can plug those into the command. And drag/drop the browser and look at the mouse coordinates there, too.
(And if you weren't using Windows 7, but instead 8 or 8.1 or 10, you could use Aero Snap with Win+RightArrow, Win+RightArrow and Win+UpArrow to move the active window to the edge of the center screen, then to the right screen, then to fullscreen it).
(Or you could use Alt-Space, M, Arrow Keys to script moving the focused window around).
This is what I did to fix it:
Used MouseRecorder to record the mouse movements and keystrokes including my username and password. Using this, I logged in, opened tabs, clicked on buttons and moved them to different monitors.
Problem with this is that it is not possible to load a saved macro and run using the commandline (or I could not figure out). So I used Mouse Controller to record the mouse movement to open MouseRecorder and click on run. [It cannot record key strokes]. Mouse controller has option to run from commandline with ability to accept the filename as argument.
I wrote a batch file to open and run MouseRecorder and scheduled to run every night using task scheduler.
I want to disable / block the mouse click and keyboard typing for 6 seconds after launching a .exe file while displaying a advsplash.
Currently I manage to run a .exe file, activate the splash, block the keyboard and run a second .exe, but then, I need to restart the computer to unlock the mouse/keyboard.
Any idea on how to disable it without restarting the machine ?
This sounds like something you should never do.
If you want to do UI automation Windows already has support for that, using SendInput or keybd_event is not a good idea. Some apps steal foreground focus, this is just a fact and if that happens at the wrong time you end up sending input to the wrong window.
What i want to know is how can you give input to a GUI app that is closed source and does not have any public API.
To be more concise, let's say you open solitaire and want through a program to play it. Or, to go even to the basics, you have an GUI app with a button and you want to click it through another program.
I know the question is a little vague, but that's the best I can phrase it. Please help me with some edits or some comments to make it more specific.
Investigate SendInput(). It can be used to simulate mouse movements and key presses.
To locate a Windows application using its GUI you can use EnumWindows() to locate a Window with a particular title. This will provide a Window handle. To give that window focus, you could:
obtain the window handle via EnumWindows()
use GetWindowRect() to get the co-ordinates of the window rectangle
move the mouse to within the bounds of the window using SendInput() and simulate a mouse click using SendInput()
I have done this once, and it is infuriatingly difficult to get right. Once you start your program sit on your hands: don't touch the mouse or the keyboard.
(I have no knowledge on how to do anything like this on Linux)
Assuming its an X11 app in Linux you could connect the process to one end of a named pipe and then echo X-Input events down the other end of the pipe.