Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; psxfin_swap.ahk by Mgis pub 2016-02-18
- ; ==>> note: not yet tested!
- ;---------------------------------------------------------------
- ;swaps controllers in their slots
- ;every binding remains the same (eg to each controller)
- ;but the controllers appear to game as if swapped in PSX console sockets
- ;---------------------------------------------------------------
- ;zamienia miejscami gracza 1 z graczem 2
- ;wszystkie konfiguracje klawiatury i joypadów zostają takie same
- ;jakbyśmy tylko joye podłączyli do konsoli na odwrót
- ;---------------------------------------------------------------
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #LTrim ; Allows continuation sections to be indented. Positional. May be turned off via #LTrim Off
- #KeyHistory 0 ; Disable keyboard and mouse event history.
- #Warn
- StringTrimRight,ScriptFullPathNoExtension,A_ScriptFullPath, 4
- ;_________________________________________________
- ; --------- CONFIGURE THESE DIRECTORIES: ---------
- file_dir:="D:\gry\Crash_x5"
- file_ini:="D:\gry\Crash_x5\psx.ini"
- file_log:=ScriptFullPathNoExtension . ".log"
- MsgBox, % file_log
- recyclenotdelete=1 ;set to: recycle 1, delete 0
- ; --------- YOU CAN LEAVE THE REST BELOW ---------
- ;_________________________________________________
- SetWorkingDir %file_dir% ; Ensures a consistent starting directory.
- Menu,Tray,icon,D:\gry\Crash_x5\psxfin.exe
- GoSub,LoadFile
- GoSub,replacetext
- ExitApp
- return ;autoexec
- LoadFile:
- if not FileExist(file_ini)
- {
- Msgbox,16,,Target file psx.ini not found!`nScript will now exit.
- ExitApp
- }
- FileRead,filecontents,%file_ini%
- if ErrorLevel
- {
- MsgBox,16,,There was an error when loading the file.`nScript will now exit.
- ExitApp
- }
- return ;LoadFile
- replacetext:
- /*
- Key1 <-> Key2
- Joy1 <-> Joy2
- JoystickDevice1 <-> JoystickDevice2
- */
- what := Array(Key,Joy,JoystickDevice)
- ; 1 2 3 this numbers from loop index
- order:= Array(3,1,2)
- /*
- ; Replace all spaces with pluses:
- ;StringReplace, NewStr, OldStr, %A_SPACE%, +, All
- ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]
- ;UseErrorLevel - store in ErrorLevel the number of replaced. UseErrorLevel implies "All".
- */
- Loop, % what.MaxIndex()
- {
- ;dla każdego słowa które trzeba zamienić
- slowo := what[A_Index]
- Loop, 3
- {
- ;dla każdej zamiany 1 <-> 2 wykonaj te 3 operacje (kopiuj,podstaw jedno,podstaw z kopii)
- ; Replace, z tekstu do tekstu, Key1 , Key3
- StringReplace,filecontents,filecontents, % slowo . A_Index, % slowo . order[A_Index], UseErrorLevel
- FileAppend, % slowo . A_Index . "`t-->`t" . slowo . order[A_Index] . "`t" . ErrorLevel,%file_log%
- Sleep 100
- }
- Sleep 100
- }
- /*
- ### Controller1Type <-> Controller2Type ###
- Controller1Type --> Controller3Type
- Controller2Type --> Controller1Type
- Controller3Type --> Controller2Type
- */
- StringReplace,filecontents,filecontents,Controller1Type,Controller3Type, UseErrorLevel
- FileAppend,Controller1Type`t-->`tController3Type`t%ErrorLevel%,%file_log%
- StringReplace,filecontents,filecontents,Controller2Type,Controller1Type, UseErrorLevel
- FileAppend,Controller2Type`t-->`tController1Type`t%ErrorLevel%,%file_log%
- StringReplace,filecontents,filecontents,Controller3Type,Controller2Type, UseErrorLevel
- FileAppend,Controller3Type`t-->`tController2Type`t%ErrorLevel%,%file_log%
- ;----------------------------------------
- ; now delete and write to file
- ;----------------------------------------
- if recyclenotdelete
- FileRecycle,%file_ini%
- else
- FileDelete,%file_ini%
- if ErrorLevel
- MsgBox,48,,Something failed to be deleted: %ErrorLevel%
- FileAppend,%filecontents%,%file_ini%
- /*
- [MainWindow]
- XPosition=17
- YPosition=155
- [Cards] ^ END OF SECTION
- XPosition=10 ;jedna lub wiecej cyfr --> 10
- YPosition=10
- */
- IniWrite,10,%file_ini%,MainWindow,XPosition
- IniWrite,10,%file_ini%,MainWindow,YPosition
- return ;replacetext
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement