hide mouse with batchfile - windows

Hi i want to make a batfile that looks something like.
hide mouse
run /wait some.exe
show mouse
the issue i have is i am making a arcade cabinet. and i have a few games that do not hide the mouse pointer and it just sits dead center on the screen.
This isn't usually an issue as you can just move the mouse and hide it, but as its an arcade cabinet there is no mouse..
I have tried and app that hides the mouse pointer after a few seconds. but that causes other issues "it will often minimize the game when it hides the mouse" I could probably use AHK to force the window IF it happened. but that seems like a lot more work than just having a bat file for the few games that i wish to hide the mouse on..
this is the windows mouse pointer.. not an in game specific mouse.

given stephans's message i decided to use a seriese of batch files to kill the mouse hider app when the aplications it minimized start and then retart the app when those tasks end..
I was hoping for a more elegant solution but it seems to be the only way i can do this.
given it is now mostly AHK scripts being used to call bat files im not sure if i need to delete the question.
the process is possible to do in batch but for my needs it was better to run the bat from a ahk script as this kept it as elegant as possible.
for any one else..
the AHK reads.
run %rompath%pin.bat
Runwait, %rompath%%romname%%romextension%
ExitApp
;Required
CloseProcess:
WinKill, A
run %rompath%pinst.bat
return
pin.bat reads:
taskkill /f /im "AutoHideMouseCursor.exe"
and pinst.bat reads:
start "path to exe\AutoHideMouseCursor.exe"
The app i used to hide the mouse is AutoHideMouseCursor
if this question is best served to be deleted let me know.

Related

Understanding Autohotkey Controlsend command

ControlSend,, test, ahk_exe notepad.exe
The above works just fine but the following does not, it should englarge the text in notepad.
ControlSend,, ^{+}, ahk_exe notepad.exe
I have also, tried
ControlSend,, {Control down}+{Control up}, ahk_exe notepad.exe
I dont really care for notepad, I am just stuck with controlsend and I am trying understand it. Often it will lose focus to the target window after triggering the hotkey. Is there a special rule in Controlsend, that gets it to keep focus where it is, after triggering the command? For example sending the following to notepad, will activate it. I thought the whole point was to maintain focus where it is.
ControlSend,, ^s, ahk_exe notepad.exe
In the last example, A window is being created so it may be a bad example but many times this issues occurs when sending simple, standard hotkeys to programs
Thanks!
Using Notepad's Alt menu to trigger the zoom in command instead of trying to send a Control Plus lead me to this solution:
WinMenuSelectItem, ahk_exe notepad.exe, , View, Zoom, Zoom In
Many of the commands that you use shortcuts for (such as Zoom, save, and etc) can be triggered from this menu as well. This method also meets the requirement of not activating the Window when triggered.

Prevent windows from being dragged past the edge of screen

I would like to be able to stop windows from being dragged past the border of the screen. For example, open a window that is not maximized, click the top bar with the mouse and drag the window wherever you want. Now drag the window to the left/right/top/bottom of your screen and notice that part of the window goes off screen. I would like the window to bump up against the edge of the screen and go no further.
In the same way the cursor can't go over the edge on the left side, I would like to make a barrier so windows can't move over it either.
The main reason for doing this is because I am making a batch program in which I need it to not go off screen. This is annoying and I was hoping that someone here could be of some help.
Sorry if this is an obvious question, I tried a few searches but had no idea what terms to look up.
Thanks for any help in advance!
Sorry for the late response (I was researching this), but here is the answer:
There is no current way to do this easily. I'm sure you can edit windows src code and add that property, but the language it is made in is not in batch and it would be EXTREMELY hard to edit these files :(
Also, this would affect all windows, not only that specific program, meaning no easy shortcut for split screen. So no, you cannot do this.
On Windows 10 you can simply move a window near the edge of the screen and it will auto-fit on screen. You can also use shortcuts to do this. [Windows key] + [arrow left] or [arrow right]
you were able to change a setting in windows 7 to prevent this. I know that this is a feature if you are using multiple monitors but if using only one monitor there should be a way to change a setting. thank you Microsoft once again for making our lives complicated. the more you guy release a new windows the harder it is to use.
Finally i found real solution for this.
I was searching a real solution for my application.
There are many tricks but using reg we need to restart computer.
You can disable it from powershell. You need to call this file from your code.
Here is link.
Check download file at bottom called "DisableAeroSnap.ps1"
https://michlstechblog.info/blog/windows-disable-aerosnap-automatically-window-arranging-and-resizing-while-dragging/#more-951

Giving input to a GUI application through another program

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.

Why does my Windows app get focus when by rules it should not?

By now everyone writing for Windows probably knows that applications cannot (officially) steal focus from foreground processes, and why. But I have just managed to steal focus, inadvertently, and don't understand how this is even possible.
I have a Delphi app that user brings up with a hotkey (or by a mouse click, or by Alt+Tab), selects a piece of text and hits Enter. My app then minimizes (hides to the tray, even), and pastes the text user just selected into the active window. Nothing new here, plenty of similar projects out there - clipboard extenders, glossaries, macro programs, etc.
What is puzzling to me is that after doing all the above and then sleeping for 1500 ms, I restore my main form and it gets the focus back! It becomes the foreground window, even though it wasn't 1500 ms ago (tested; Windows 7 32-bit.).
In fact, I don't want this at all, so before restoring my main form I record which window has foreground and I give it back to that window after it's been given to me. I'm just curious why my app gets to be in the foreground when by rules it should not. Maybe I don't understand the rules as fully as I thought I did?
If you look at the documentation for SetForegroundWindow you see a list of conditions for the call to succeed, one of them is "The process received the last input event." So if the user does not do anything after pressing enter in your app you still have the right to steal focus. I don't know if Delphi calls SetForegroundWindow for you when the window is restored but it might be something to look into.
I don't know how you restore your window but using SW_SHOWNOACTIVATE with ShowWindow might help...

Create a Program that Sits in The Windows Taskbar and, When Activated, Stops the Screensaver From Starting

I don't really know where to begin. Let's start with the stupid questions:
What language should I use for this? What is suited for the task at hand?
Next, the real ones:
Is there a way to stop the screensaver from starting, short of changing the cursor position? If not, will changing the cursor position even work?
SetThreadExecutionState will prevent the screensaver from coming on or the machine from automatically going to sleep if you pass the ES_CONTINUOUS and ES_DISPLAY_REQUIRED flags.
I wrote an app awhile ago that does exactly what you are asking for. It runs as an icon in the System Tray, not the Taskbar, and uses a global message hook to disable the WM_SYSCOMMAND/SC_SCREENSAVE notification from reaching any applications. If that notification does not reach the DefWindowProc() function, the screen saver will never run.
Your program does not need to be visible in the task bar at all.
You don't even need a program at all, if you can disable the screensaver in the registry.
What you want to do can perhaps be achieved by sending a MOUSE_MOVE event to the desktop window. If you want to use C# (the only language I am current with right now), you can look at this article, but maybe a simple C program using the WinAPI is better suited for this task.
.NET will easily allow you to put an application in the system tray (checkout the NotifyIcon object in System.Windows.Forms.Controls).
I believe you can use the SetCursorPos (http://msdn.microsoft.com/en-us/library/ms648394(VS.85).aspx) API call to prevent the screen saver, just make sure you set them to the current location so you don't actually move the mouse.

Resources