Advertisement
mgis90

psxfin_swap.ahk

Feb 18th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; psxfin_swap.ahk                           by Mgis     pub 2016-02-18
  2. ; ==>> note: not yet tested!
  3. ;---------------------------------------------------------------
  4. ;swaps controllers in their slots
  5. ;every binding remains the same (eg to each controller)
  6. ;but the controllers appear to game as if swapped in PSX console sockets
  7. ;---------------------------------------------------------------
  8. ;zamienia miejscami gracza 1 z graczem 2
  9. ;wszystkie konfiguracje klawiatury i joypadów zostają takie same
  10. ;jakbyśmy tylko joye podłączyli do konsoli na odwrót
  11. ;---------------------------------------------------------------
  12. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  13. #LTrim  ; Allows continuation sections to be indented. Positional. May be turned off via #LTrim Off
  14. #KeyHistory 0  ; Disable keyboard and mouse event history.
  15. #Warn
  16. StringTrimRight,ScriptFullPathNoExtension,A_ScriptFullPath, 4
  17. ;_________________________________________________
  18. ; --------- CONFIGURE THESE DIRECTORIES: ---------
  19. file_dir:="D:\gry\Crash_x5"
  20. file_ini:="D:\gry\Crash_x5\psx.ini"
  21. file_log:=ScriptFullPathNoExtension . ".log"
  22. MsgBox, % file_log
  23. recyclenotdelete=1      ;set to: recycle 1, delete 0
  24. ; --------- YOU CAN LEAVE THE REST BELOW ---------
  25. ;_________________________________________________
  26. SetWorkingDir %file_dir%  ; Ensures a consistent starting directory.
  27. Menu,Tray,icon,D:\gry\Crash_x5\psxfin.exe
  28.  
  29. GoSub,LoadFile
  30. GoSub,replacetext
  31. ExitApp
  32. return  ;autoexec
  33.  
  34.  
  35. LoadFile:
  36. if not FileExist(file_ini)
  37. {
  38.     Msgbox,16,,Target file psx.ini not found!`nScript will now exit.
  39.     ExitApp
  40. }
  41. FileRead,filecontents,%file_ini%
  42. if ErrorLevel
  43. {
  44.     MsgBox,16,,There was an error when loading the file.`nScript will now exit.
  45.     ExitApp
  46. }
  47. return  ;LoadFile
  48.  
  49.  
  50. replacetext:
  51. /*
  52. Key1 <-> Key2
  53. Joy1 <-> Joy2
  54. JoystickDevice1 <-> JoystickDevice2
  55. */
  56. what := Array(Key,Joy,JoystickDevice)
  57. ;             1 2 3     this numbers from loop index
  58. order:= Array(3,1,2)
  59. /*
  60. ; Replace all spaces with pluses:
  61. ;StringReplace, NewStr, OldStr, %A_SPACE%, +, All
  62. ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]
  63. ;UseErrorLevel - store in ErrorLevel the number of replaced. UseErrorLevel implies "All".
  64. */
  65. Loop, % what.MaxIndex()
  66. {
  67.     ;dla każdego słowa które trzeba zamienić
  68.     slowo := what[A_Index]
  69.     Loop, 3
  70.     {
  71.         ;dla każdej zamiany 1 <-> 2 wykonaj te 3 operacje (kopiuj,podstaw jedno,podstaw z kopii)
  72.         ;  Replace, z tekstu do tekstu,              Key1         ,     Key3
  73.         StringReplace,filecontents,filecontents, % slowo . A_Index, % slowo . order[A_Index], UseErrorLevel
  74.         FileAppend, % slowo . A_Index . "`t-->`t" . slowo . order[A_Index] . "`t" . ErrorLevel,%file_log%
  75.         Sleep 100
  76.     }
  77.     Sleep 100
  78. }
  79.  
  80. /*
  81. ###  Controller1Type <-> Controller2Type  ###
  82. Controller1Type --> Controller3Type
  83. Controller2Type --> Controller1Type
  84. Controller3Type --> Controller2Type
  85. */
  86. StringReplace,filecontents,filecontents,Controller1Type,Controller3Type, UseErrorLevel
  87.     FileAppend,Controller1Type`t-->`tController3Type`t%ErrorLevel%,%file_log%
  88. StringReplace,filecontents,filecontents,Controller2Type,Controller1Type, UseErrorLevel
  89.     FileAppend,Controller2Type`t-->`tController1Type`t%ErrorLevel%,%file_log%
  90. StringReplace,filecontents,filecontents,Controller3Type,Controller2Type, UseErrorLevel
  91.     FileAppend,Controller3Type`t-->`tController2Type`t%ErrorLevel%,%file_log%
  92.  
  93. ;----------------------------------------
  94. ; now delete and write to file
  95. ;----------------------------------------
  96. if recyclenotdelete
  97.     FileRecycle,%file_ini%
  98. else
  99.     FileDelete,%file_ini%
  100. if ErrorLevel
  101.     MsgBox,48,,Something failed to be deleted: %ErrorLevel%
  102.  
  103. FileAppend,%filecontents%,%file_ini%
  104. /*
  105. [MainWindow]
  106. XPosition=17
  107. YPosition=155
  108. [Cards] ^ END OF SECTION
  109.  
  110. XPosition=10            ;jedna lub wiecej cyfr --> 10
  111. YPosition=10
  112. */
  113. IniWrite,10,%file_ini%,MainWindow,XPosition
  114. IniWrite,10,%file_ini%,MainWindow,YPosition
  115.  
  116. return  ;replacetext
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement