Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Need Autohotkey help to hide mouse pointer  (Read 9282 times)

0 Members and 1 Guest are viewing this topic.

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 12:43:52 pm
  • ...
Need Autohotkey help to hide mouse pointer
« on: June 28, 2012, 12:26:35 pm »
The newest version of Demul (v0.57) moves the mouse pointer to the center of the screen when the game launches. (not when the emulator launches)
With the previous version (v0.56), I used mousemove to move the mouse pointer off-screen upon launching the emulator and it stayed put.
That script also launched the game and required a separate script for each game.

This time around I'm trying to avoid having a separate script for each game and just have Mala launch it.
The other issue was that it seems to have no exit key, but Closemul is working fine to close it.
So I just need to get rid of the mouse pointer.

The problem is that Mala won't launch the emulator until after the script exits, but it needs to move the mouse after the game has launched.

I experimented with nomousy.exe and a few scripts from the autohotkey forums.
http://www.autohotkey.com/community/viewtopic.php?t=2197
http://www.autohotkey.com/community/viewtopic.php?t=46209

The problem is that those must be running for the mouse to be invisible, but again the problem is that Mala will not launch the emulator until they exit, at which point the mouse pointer comes back.


So I think I need two autohotkey scripts (or some other alternative).

One that will hide the mouse pointer then exit, leaving the mouse pointer invisible and no scripts running.
Then another to bring it back then exit, leaving it visible.

I can put them in the pre and post commands of either Mala or Closemul and would also put the showmouse one in the startup folder in case things get kooky and I have to restart the computer to get it back.

Usually I can cobble together a shoddy script that will do what I want, but this one is a bit over my head.
Here is the sample that toggles it with a key press.  
Code: [Select]
; Example: Hides the mouse cursor when you press Win+C. To later show the cursor, press Win+C again.
; This script is from [url=http://www.autohotkey.com/forum/topic6107.html]www.autohotkey.com/forum/topic6107.html[/url]

OnExit, ShowCursor  ; Ensure the cursor is made visible when the script exits.
return

ShowCursor:
SystemCursor("On")
ExitApp

#c::SystemCursor("Toggle")  ; Win+C hotkey to toggle the cursor on and off.

SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
    static AndMask, XorMask, $, h_cursor
        ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
        , b1,b2,b3,--BINGO! Either that, or I was attempting to say "before" but it was too many letters to type--,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
        , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
    if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
    {
        $ = h                                          ; active default cursors
        VarSetCapacity( h_cursor,4444, 1 )
        VarSetCapacity( AndMask, 32*4, 0xFF )
        VarSetCapacity( XorMask, 32*4, 0 )
        system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
        StringSplit c, system_cursors, `,
        Loop %c0%
        {
            h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
            h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
            b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
                , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
        }
    }
    if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
        $ = b  ; use blank cursors
    else
        $ = h  ; use the saved cursors

    Loop %c0%
    {
        h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
        DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
    }
}





EDIT:  If I launch one of these scripts before starting Mala, it doesn't intefere with Demul launching, but if I add it to the command line, it hangs until the script exits.
          I'm thinking that I could make a script that hides the mouse while mala is running, but I still don't understand half of what's in this sample script.
« Last Edit: June 28, 2012, 07:03:48 pm by BadMouth »

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 12:43:52 pm
  • ...
Re: Need Autohotkey help to hide mouse pointer
« Reply #1 on: June 29, 2012, 10:57:08 am »
Since the script doesn't interfere with Mala if I launch it ahead of time,
I decided just to run a script at startup so the mouse pointer is invisible until a key combination is pressed to make it visible.
That way it will never be seen unless I am doing maintenance.

Wrapped my head around it enough that I think the cursor would be made invisible when the script is launched by changing

$ = h                                          ; active default cursors
To
$ = b                                          ; active default cursors

or add SystemCursor("Off") in there somewhere.

I will try it when I get home from work.  :-\
« Last Edit: June 29, 2012, 11:12:36 am by BadMouth »

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:June 25, 2023, 02:23:57 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Need Autohotkey help to hide mouse pointer
« Reply #2 on: June 29, 2012, 12:17:41 pm »
You might try having mala launch a BAT file (or better, a VBS file, because it won't show a command prompt window) instead of the emulator proper.

and in that file, launch nomousey.exe via a START command asynchronously.

then have it launch your emulator, via START, but wait till the emul closes

and finally run nomousey.exe again to restore the cursor before falling back into mala.

Just for reference, you can launch apps from a VBS script with


Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Exec "program.exe arg1 arg2 arg3 etc"


the exec method has a variety of options to control showing the window, launching minimized, and even waiting for the launched program to terminate before continuing the script.

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 12:43:52 pm
  • ...
Re: Need Autohotkey help to hide mouse pointer
« Reply #3 on: June 29, 2012, 02:24:18 pm »
You might try having mala launch a BAT file (or better, a VBS file, because it won't show a command prompt window) instead of the emulator proper.

and in that file, launch nomousey.exe via a START command asynchronously.

then have it launch your emulator, via START, but wait till the emul closes

and finally run nomousey.exe again to restore the cursor before falling back into mala.

Just for reference, you can launch apps from a VBS script with


Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Exec "program.exe arg1 arg2 arg3 etc"


the exec method has a variety of options to control showing the window, launching minimized, and even waiting for the launched program to terminate before continuing the script.

I'm using SGT's "all game in one list" workaround, so Mala is launching a batch file (.cmd) in place of mame and it in turn launches the appropriate emulator based on which folder the rom is found in.

I tried launching nomousy from that bat file, but it still behaved as I outlined above.
I didn't know about the START command.  Will have to look it up and edumacate myself.
After a quick google search, I'm pretty sure you hit the nail on the head with launching them asynchronously.

« Last Edit: June 29, 2012, 02:26:09 pm by BadMouth »

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:June 25, 2023, 02:23:57 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Need Autohotkey help to hide mouse pointer
« Reply #4 on: June 29, 2012, 02:33:59 pm »
Ah, yeah, if you're already making use of a batch file, just use the START command instead of executing the exe directly.

the START command has args that allow you to say:

"Start this program, but, don't wait for it to finish, just continue executing the bat file"

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 12:43:52 pm
  • ...
Re: Need Autohotkey help to hide mouse pointer
« Reply #5 on: June 29, 2012, 06:51:02 pm »
Thanks for the help!  :cheers:
It's launching and closing the way I want now.

Here is what I ended up with for that section of my batch file:

Code: [Select]
:atomiswave

cd \Emulators\demul057
start nomousy.exe /hide
closemul.exe demul.exe -run=atomiswave -rom=%1
nomousy.exe
exit


:naomi

cd \Emulators\demul057
start nomousy.exe /hide
closemul.exe demul.exe -run=naomi -rom=%1
nomousy.exe
exit

Unrealated to this, but Metal Slug 6 keeps crashing now part-way through the first level.    :banghead:
(and it's one of the main reasons that I'm going to the trouble of getting demul .57 set up)
I swear I played through the first level a half dozen times before and it was fine.

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:June 25, 2023, 02:23:57 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Need Autohotkey help to hide mouse pointer
« Reply #6 on: June 29, 2012, 06:56:44 pm »
Good news!

Hey, I did a little searching around but couldn't find "SGT's all in one" batch file idea you mentioned.

Sounds pretty dang interesting, as I've been wanting to potentially do something like that with multiple emus

You wouldn't have a link handy (or the bat file you're using)?

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 12:43:52 pm
  • ...
Re: Need Autohotkey help to hide mouse pointer
« Reply #7 on: June 29, 2012, 08:04:49 pm »
Good news!

Hey, I did a little searching around but couldn't find "SGT's all in one" batch file idea you mentioned.

Sounds pretty dang interesting, as I've been wanting to potentially do something like that with multiple emus

You wouldn't have a link handy (or the bat file you're using)?

It's stickied in the Mala forum, but I used different wording.  :P
http://forum.arcadecontrols.com/index.php?topic=68419.0

I think this is how all front-ends should function.  
Arcade games belong together in the same list without regard for what emulator they're running on!

An added benefit is that it pulls all the game info (including monitor rotation and controls information) from mame.xml
I was using this method in my old setup, but the new cab will only have Arcade games, so it won't even have the option to switch emulators.  :)
It will however have separate gamelists (and layouts!) for genres (shmups, beat 'em ups, fighters, run n gun, sports, etc)

Here is my cmd file so far.  It still has some remnants from the old setup.  
I'm not quite finished with it yet, but Model 2, Model 3, Naomi, Atomiswave, Daphne, & Taito Type X all show up in the same list as if they're in MAME.  ;D

Code: [Select]
if "%2" == "C:\Emulators\other_emus\pc" goto pc
if "%2" == "C:\Emulators\other_emus\cavesh3" goto cavesh3
if "%2" == "C:\Emulators\other_emus\daphne" goto daphne
if "%2" == "C:\Emulators\other_emus\m2" goto m2
if "%2" == "C:\Emulators\other_emus\m3" goto m3
if "%2" == "C:\Emulators\other_emus\atomiswave" goto atomiswave
if "%2" == "C:\Emulators\other_emus\naomi" goto naomi
if "%2" == "C:\Emulators\other_emus\Makaron" goto Makaron
if "%2" == "C:\Emulators\other_emus\Makaron2" goto Makaron2
if "%2" == "C:\Emulators\other_emus\taitox" goto taitox

mame64.exe %1

:pc
cd \Emulators\other_emus\pc_games
%1.lnk
exit

:cavesh3
cd C:\Emulators\cavemame
mame64.exe %1
exit

:daphne                
SET DAPHNE=C:\Emulators\Daphne\daphne.exe
cd ..\daphne
if "%1" == "astron" start/wait %daphne% astron vldp -framefile C:\Emulators\Daphne\framefile\astron.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "badland" start/wait %daphne% badlands vldp -framefile C:\Emulators\Daphne\framefile\badlands.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "begas" start/wait %daphne% bega vldp -framefile C:\Emulators\Daphne\framefile\bega.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "cliffhgr" start/wait %daphne% cliff vldp -framefile C:\Emulators\Daphne\framefile\cliff.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "cobram3" start/wait %daphne% cobra vldp -framefile C:\Emulators\Daphne\framefile\cobra.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "dlair" start/wait %daphne% lair vldp -framefile C:\Emulators\Daphne\framefile\lair.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "esh" start/wait %daphne% esh vldp -framefile C:\Emulators\Daphne\framefile\esh.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "galaxyr" start/wait %daphne% galaxy vldp -framefile C:\Emulators\Daphne\framefile\galaxy.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "istellar" start/wait %daphne% interstellar vldp -framefile C:\Emulators\Daphne\framefile\interstellar.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "lair2" start/wait %daphne% lair2 vldp -framefile C:\Emulators\Daphne\framefile\lair2.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "mach3" start/wait %daphne% mach3 vldp -framefile C:\Emulators\Daphne\framefile\mach3.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "rblaster" start/wait %daphne% roadblaster vldp -framefile C:\Emulators\Daphne\framefile\rb.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "sblazerp" start/wait %daphne% blazer vldp -framefile C:\Emulators\Daphne\framefile\blazer.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "spaceace" start/wait %daphne% ace vldp -framefile C:\Emulators\Daphne\framefile\ace.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "superdq" start/wait %daphne% sdq vldp -framefile C:\Emulators\Daphne\framefile\sdq.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "usvsthem" start/wait %daphne% uvt vldp -framefile C:\Emulators\Daphne\framefile\uvt.txt -fullscreen -blank_skips -blank_searches -preset 1
if "%1" == "gpworld" start/wait %daphne% gpworld vldp -framefile C:\Emulators\Daphne\framefile\gpworld.txt -fullscreen -blank_skips -blank_searches -preset 1


exit

:m2
cd \Emulators\model2
closemul.exe emulator_multicpu.exe zip %1
exit


:m3
cd \Emulators\supermodel
supermodel.exe %1.zip -res=1024,768 -fullscreen
exit

:atomiswave

cd \Emulators\demul057
start nomousy.exe /hide
closemul.exe demul.exe -run=atomiswave -rom=%1
nomousy.exe
exit


:naomi

cd \Emulators\demul057
start nomousy.exe /hide
closemul.exe demul.exe -run=naomi -rom=%1
nomousy.exe
exit

:Makaron

cd \Emulators\Makaron
closemul.exe NAOMI.exe %1.zip
exit

:Makaron2

cd \Emulators\Makaron
closemul.exe NAOMI.exe %1.dat
exit

:taitox
cd \Emulators\other_emus\taitox
%1.lnk
exit


Every "rom" in the other_emus folder is a dummy text file that I zipped.
This just makes it show up in the list and provides a path for the batch file to sort things by.
All the real roms are in their respective emulator folders to keep things together.

I have my modified xml which has everything useless stripped out (mahjong, poker, mechanical, etc) and has these added.
I had planned to post it, but it is too large to attach and I haven't bothered to find a place to upload it.

The one thing that threw me for a bit this time is that is that for all but mame games, it didn't appear that %2 was getting passed to the batch file, but if you right clicked on the game in Mala and selected properties, the path was actually missing.  It was some option that I had to uncheck in the advance features where you set the rom path, but I can't for the life of me find it in that thread again (it's in there somewhere).  I think maybe I had to uncheck "only working games" even though I had changed them to working in the xml and they show up in the list.  

Anyways, if it looks like it isn't passing %2, you can save a bunch of time by checking the game properties and seeing if the path is blank.
Sorry for the crappy explanation of that, but I don't have much time at the moment and I went through that thread twice looking for it already.
« Last Edit: June 29, 2012, 08:22:25 pm by BadMouth »

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:June 25, 2023, 02:23:57 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Need Autohotkey help to hide mouse pointer
« Reply #8 on: June 29, 2012, 10:09:16 pm »
Thanks.

I really like that idea.

I might recode it as a simple VBS script, but only if shelling to a cmd script causes a dos box to appear.

As a side note, I'd never heard of a CMD file before this. Had to go look up the differences. Turns out, apparently, the two are essentially the same. Never knew...

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 12:43:52 pm
  • ...
Re: Need Autohotkey help to hide mouse pointer
« Reply #9 on: July 02, 2012, 08:59:05 am »
Yeah, even if "minimized" is selected in MALA, it still shows the dos boxes for the other emulators.

I'll most likely end up using a loading image controlled by an AHK script to cover everything up.
Supermodel and some of the TaitoX games take a while to load. 
The Mala "starting" window flashes, but then it goes back to the front end for 3-5 seconds before the game launches. 
It can be confusing for guests.