Author Topic: script wait until joy8 is pressed  (Read 14683 times)

davhuit

  • Full Member
  • ***
  • Posts: 173
Re: script wait until joy8 is pressed
« Reply #19 on: April 08, 2014, 08:22:26 PM »
Okay, seems I manage to finalize the script, here's the final (working) version :

Code: (autoit) [Select]
;set the hotkey
HotKeySet("{Space}", "Start")

;display a bmp image as a splash screen
Local $sDestination = "image_1280-720.bmp"
SplashImageOn("Splash Screen", $sDestination, 1280, 720, 0, 0, 1)

;wait for the hotkey to be pressed
While 1
    Sleep(0)
WEnd

;execute this action when the hotkey is pressed
Func Start()
    SplashOff()
    Run("cmd /c start C:\PinballArcadeUnleashed\PinballArcade.exe", "C:\PinballArcadeUnleashed\", @SW_HIDE)
    Exit
EndFunc

Seems it only require "Exit" to close the script :D

If some peoples find some flaws in this script or have a better idea to do the same thing, feel free to comment because I'm not sure if it's a proper one (I don't know much about AutoIt and produced this script with some google search and by taking part of some other scripts).

Edit : I found a problem. If the path have a space in it with the "cmd", it fails, so I modified it this way :

Code: (autoit) [Select]
;set the hotkey
HotKeySet("{ESC}", "Start")

;display a bmp image as a splash screen
Local $sDestination = "xpadder_hitman_blood_money.bmp"
SplashImageOn("Splash Screen", $sDestination, 1280, 720, 0, 0, 1)

;wait for the hotkey to be pressed
While 1
    Sleep(0)
WEnd

;execute this action when the hotkey is pressed
Func Start()
    SplashOff()
    Run("cmd /c start PinballArcade.exe", "C:\PinballArcade Unleashed\", @SW_HIDE)
    Exit
EndFunc

(renamed my directory "PinballArcadeUnleashed" to "PinballArcade Unleashed" to test and it's now working even with a space in the path).

To stop the splash screen and run the game with my 360 controller, I just changed "space" to "esc" in the autoit script as I have xpadder running in background with the "ESC" always binded to LT+Right Stick Button for MGalaxy (even when I play PC retail games, I never saw yet a game which required to use LT+Right Stick Button yet so that's never been a problem so far.

And for games which don't support the gamepad (games for which I wanted a splash screen), xpadder is configured to auto-load their own profiles when the .exe is loaded and the window active. If you use ALT+TAB to go back to the desktop, xpadder switch back to the default profile and if you use ALT+TAB to go back to the game window, xpadder switch back to the game profile, so that's pretty nice.
« Last Edit: April 09, 2014, 03:53:29 PM by davhuit »

davhuit

  • Full Member
  • ***
  • Posts: 173
Re: script wait until joy8 is pressed
« Reply #18 on: April 08, 2014, 07:37:56 PM »
Thanks.

Though I searched a bit and I found that AutoIt offer a native function that display a splashscreen (which might be better/easier to use as it can be modified) :

http://www.autoitscript.com/autoit3/docs/functions/SplashImageOn.htm
http://www.autoitscript.com/autoit3/docs/functions/SplashOff.htm

Would someone be able to make a script that use this function to display a splashscreen and then run a program when a key is pressed?

I managed to display the splash screen but not to write a function which make the splashscreen dissapear then run the program once a keyboard key is pressed.

For the key, I think this function is required for the key press : https://www.autoitscript.com/autoit3/docs/functions/HotKeySet.htm

Edit : I managed to do that, for now :

Code: (autoit) [Select]
;set the hotkey
HotKeySet("{Enter}", "Start")

;display a splash screen
Local $sDestination = "image.jpg"
SplashImageOn("Splash Screen", $sDestination, 250, 50)

;wait for the hotkey to be pressed
While 1
    Sleep(100)
WEnd

;take this action when the hotkey is pressed
Func Start()
    SplashOff()
EndFunc

Now, I just need to manage to run the program after the "SplashOff" (and also to exit/kill the autoit script once the game is loaded).

Edit 2 :

Code: (autoit) [Select]
;set the hotkey
HotKeySet("{Enter}", "Start")

;display a splash screen
Local $sDestination = "image.jpg"
SplashImageOn("Splash Screen", $sDestination, 250, 50)

;wait for the hotkey to be pressed
While 1
    Sleep(0)
WEnd

;take this action when the hotkey is pressed
Func Start()
    SplashOff()
    Run ("C:\Windows\regedit.exe")
EndFunc

Works fine with Regedit but when I put the path of a game executable, it seems to load it but then stuck (the game works fine). Maybe the basic "Run" function is not adapted for everything?

Edit 3 :

Code: (autoit) [Select]
;set the hotkey
HotKeySet("{Enter}", "Start")

;display a splash screen
Local $sDestination = "image.png"
SplashImageOn("Splash Screen", $sDestination, 250, 50)

;wait for the hotkey to be pressed
While 1
    Sleep(0)
WEnd

;take this action when the hotkey is pressed
Func Start()
    SplashOff()
    Run("cmd /c start C:\Games\PinballArcadeUnleashed\PinballArcade.exe", "C:\PinballArcadeUnleashed\", @SW_HIDE)
EndFunc

This one works fine but not sure if the command line is really a proper one, so if some people have some thoughts about it :)

Now, just need to find how to close the script once the game is loaded because, right now, it load the game each time enter is pressed as the script is still active.
« Last Edit: April 08, 2014, 08:27:00 PM by davhuit »

h3xl3y

  • Newbie
  • *
  • Posts: 40
Re: script wait until joy8 is pressed
« Reply #17 on: April 06, 2014, 02:43:04 PM »

davhuit

  • Full Member
  • ***
  • Posts: 173
Re: script wait until joy8 is pressed
« Reply #16 on: April 06, 2014, 01:45:30 PM »
@h3xl3y : Can you share the program or where you found it?

I would be interested in it (I have some games that don't support gamepad that I added to Steam Big Picture and xpadder automatically load/unload the required profile when I load/close the game but that would be nice to have a splash screen displayed before to remember the controls (the spacebar is not a problem for me, as I have a xpadder profile loaded by default with the "ESC" key binded, I can also bind another key with a combo key never used in a game. "ESC" is binded to "LT" (hold) + right click stick", so I can put "LT" (hold) + "left click stick for "spacebar".

Aeliss

  • Hero Member
  • *****
  • Posts: 900
Re: script wait until joy8 is pressed
« Reply #15 on: March 24, 2014, 03:02:59 PM »
Yep, from my memory there isn't yet front end with this functionnality and on system like n64, I m sure I m not alone who don't remember the command.

h3xl3y

  • Newbie
  • *
  • Posts: 40
Re: script wait until joy8 is pressed
« Reply #14 on: March 24, 2014, 02:54:17 PM »
Is good if you can make them automatic but i am planning to use "Note" menu for systems info and i already have created the splash screen for almost all systems i want to use.

Aeliss

  • Hero Member
  • *****
  • Posts: 900
Re: script wait until joy8 is pressed
« Reply #13 on: March 24, 2014, 02:21:29 PM »
Nice ^^.
And I think we aren't alone interested by this util.

Just 3 suggestions.
Have you an exemple for the more classic "emulated" controller, I m really bad with photoshop (I had too much problem just for convert the system image to icon file).
I really like the h3xl3y design, the background is perhaps "too much" but the button and numeric pad visual presentation is perfect for me.
I think it will be useful to export the result in rtf format too (to use it directly on mGalaxy, I don't think all users can make the rtf file with the png), I have take a look on a rtf file with an image and I think It isn't hard to make. Or more harder, integrate your application inside mGalaxy and make it generating your png with ini/xml file inside the system folder.

And yes I m interested by your app :) and ofc I can help if you are interested by my request and if it s need to much time (for convertion, I m a noob for picture)
« Last Edit: March 24, 2014, 02:24:09 PM by Aeliss »

mgalaxy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1167
    • Email
Re: script wait until joy8 is pressed
« Reply #12 on: March 24, 2014, 07:29:42 AM »
Aeliss,

I had some spare time this WE and wrote a little application to help generate such a diagram.
If it does interest you I'll post it here!
You get a base image of an XBOX360 controller, you then fill the fields and choose a picture of the "emulated" controller...the application export the resulting image to a png file.
Here is a sample of the output file:
« Last Edit: March 24, 2014, 07:44:45 AM by mgalaxy »

Aeliss

  • Hero Member
  • *****
  • Posts: 900
Re: script wait until joy8 is pressed
« Reply #11 on: March 22, 2014, 09:49:27 AM »
Yep, I m totally agree with you. But in fact, it s not the splash function that draws me, because I use the "note" window function in mGalaxy to remember the command but your image.
It s really nice, I realy like the design, I think I will take your image and edit it for all other system.

h3xl3y

  • Newbie
  • *
  • Posts: 40
Re: script wait until joy8 is pressed
« Reply #10 on: March 22, 2014, 09:08:19 AM »
The Spash.exe loads a image.png that is in the same folder with the exe.
each system need to have in folder a Splash.exe and a png image
the png i made in Photoshop for each system i want to know the controls  ;)

i did this because if you don't use a system for a while you forget how you set the controls
and there are systems that have many more buttons than NES

if you want i can make a short video to see it in action

Aeliss

  • Hero Member
  • *****
  • Posts: 900
Re: script wait until joy8 is pressed
« Reply #9 on: March 22, 2014, 05:40:52 AM »
It s an application just to made a splash screen and your have made yourself the screen, or this application made all itself for all emul ?

h3xl3y

  • Newbie
  • *
  • Posts: 40
Re: script wait until joy8 is pressed
« Reply #8 on: March 21, 2014, 07:39:20 PM »
Ok, i got it resolved
Thanks for the link

h3xl3y

  • Newbie
  • *
  • Posts: 40
Re: script wait until joy8 is pressed
« Reply #7 on: March 21, 2014, 05:07:01 PM »
It's a aplication i found on some forum.
I don't have the code for it so cannot modify it.

i will look at that example to see if i can use it, thanks

Aeliss

  • Hero Member
  • *****
  • Posts: 900
Re: script wait until joy8 is pressed
« Reply #6 on: March 21, 2014, 03:08:35 PM »
Ha nice ^^, usefull.
But I think It will be easier to modify the splash screen, it s a special application (coded by you ?)  or a script ?

Take a look here perhaps, if you use autoit > http://www.autoitscript.com/forum/topic/133663-udf-ispressed360au3-xbox360-controller/

h3xl3y

  • Newbie
  • *
  • Posts: 40
Re: script wait until joy8 is pressed
« Reply #5 on: March 21, 2014, 01:27:19 PM »
I have made a Splash screen that appears when i launch a game that stays paused until i press Space on keyboard and then launches the emulator.
At least that is how it did work until mGalaxy5.2
before i had Space key set on Start button (x360 pad) trough Xpadder
but now i take the x360 pad launch the game and need to press Space on keyboard before play the game.
so that is why i need to detect joy key press

here is a example of Splash screen i made