Guest User

Untitled

a guest
Aug 13th, 2015
324
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; =============================================================
  2. ; ---------------------   Configs   ---------------------------
  3. ; =============================================================
  4.  
  5. #Include, Class_LV_Colors.ahk
  6.  
  7. #SingleInstance, force
  8. #NoEnv                          ; Recommended for performance and compatibility with future AutoHotkey releases.
  9. SendMode Input                  ; Recommended for new scripts due to its superior speed and reliability.
  10. SetWorkingDir %A_ScriptDir%         ; Ensures a consistent starting directory.
  11.  
  12. { ; RUN SCRIPT AS ADMIN
  13.     Loop, %0%  ; For each parameter:
  14.     {
  15.         param := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
  16.         params .= A_Space . param
  17.     }
  18.     ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
  19.    
  20.     if not A_IsAdmin
  21.     {
  22.         If A_IsCompiled
  23.             DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
  24.         Else
  25.             DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
  26.         ExitApp
  27.     }
  28. }
  29.  
  30. { ; Change Tray Icon
  31.     I_Icon = GoldenKey64x.ico
  32.     ICON [I_Icon]                                ;Changes a compiled script's icon (.exe)
  33.     if I_Icon <>
  34.         IfExist, %I_Icon%
  35.             Menu, Tray, Icon, %I_Icon%         ;Changes menu tray icon
  36. }
  37.  
  38. ; =============================================================
  39. ; -------------------   Guis & Menus  -------------------------
  40. ; =============================================================
  41.  
  42. Gui, Main: +AlwaysOnTop
  43. Gui, Main: Add, ListView, w340 gEvent vVLV R8 hwndHLV AltSubmit, Servidor|Char|ID|Password|Info
  44.  
  45. Gui, Login: +AlwaysOnTop -SysMenu +Owner
  46. Gui, Login: Add, Edit, vMasterPassword gValidatePassword Password*
  47.  
  48. Gui, NewAccount: +AlwaysOnTop -SysMenu +Owner
  49. Gui, NewAccount: Add, Text, x12 y9 w90 h20 +Right, Servidor:
  50. Gui, NewAccount: Add, Text, x12 y39 w90 h20 +Right, Char:
  51. Gui, NewAccount: Add, Text, x12 y69 w90 h20 +Right, ID:
  52. Gui, NewAccount: Add, Text, x12 y99 w90 h20 +Right, Password:
  53. Gui, NewAccount: Add, Text, x12 y129 w90 h20 +Right, Extra Info:
  54. Gui, NewAccount: Add, Edit, x112 y9 w100 h20 vServidor
  55. Gui, NewAccount: Add, Edit, x112 y39 w100 h20 vChar
  56. Gui, NewAccount: Add, Edit, x112 y69 w100 h20 vID
  57. Gui, NewAccount: Add, Edit, x112 y99 w100 h20 vPassword
  58. Gui, NewAccount: Add, Edit, x112 y129 w100 h20 vExtraInfo
  59. Gui, NewAccount: Add, Button, gAddAccountToFile x62 y159 w100 h30, Send
  60.  
  61. Menu, Options, Add, Add Account, AddAccountWindow
  62.  
  63. ; =============================================================
  64. ; -----------------------   Main   ----------------------------
  65. ; =============================================================
  66.  
  67.  
  68. LoadAccountsToWindow()
  69. LV_ModifyCol()
  70.  
  71. ; =============================================================
  72. ; ---------------------   Hotkeys   ---------------------------
  73. ; =============================================================
  74.  
  75. <^>!m::
  76. Gui, Login: Show, Center, Master
  77. return
  78.  
  79. ; =============================================================
  80. ; --------------------   Functions   --------------------------
  81. ; =============================================================
  82.  
  83. LoadAccountsToWindow() {
  84.     Gui, Main: Default
  85.     LV_Delete()
  86.     FileRead, Hold, file.txt
  87.     AccountsData := StrSplit(Hold,  "`n")
  88.    
  89.     Loop, % AccountsData.MaxIndex() {
  90.         AccountData := AccountsData[A_Index]
  91.         servidor := QuickRegEx(AccountData, "Servidor: (\w+)")
  92.         char := QuickRegEx(AccountData, "Char: (\w+)")
  93.         id := QuickRegEx(AccountData, "ID: (\w+)")
  94.         password := QuickRegEx(AccountData, "Password: (\w+)")
  95.         extra_info := QuickRegEx(AccountData, "ExtraInfo: (.*)")
  96.        
  97.         LV_Add("", servidor, char, id, password, extra_info)
  98.         LV_ModifyCol()
  99.     }
  100.    
  101. }
  102.  
  103. SetUpColors() {
  104.     Gui, Main: Default
  105.     CLV := New LV_Colors(HLV, True)
  106.     Loop, % LV_GetCount()
  107.     {
  108.         LV_GetText(ServerName, A_Index, 1)
  109.         if ServerName = Mkmt2
  110.         {
  111.             ; MsgBox, 1  TESTING
  112.             CLV.Row(A_Index, 0xFF6B6B)
  113.         }
  114.     }
  115. }
  116.  
  117. QuickRegEx(String, Patern, ReturnValue := 1) {
  118.     RegExMatch(String, Patern, RE_Match)
  119.     if (RE_Match%ReturnValue% != ""){
  120.         ReturnValue := RE_Match%ReturnValue%
  121.         return ReturnValue
  122.     } else {
  123.         return "null"
  124.     }  
  125. }
  126.  
  127.  
  128. ; =============================================================
  129. ; -------------------   SubRoutines   -------------------------
  130. ; =============================================================
  131.  
  132. Event:
  133. if (A_GuiEvent = "RightClick") {
  134.     Menu, Options, Show
  135. }
  136. if (A_GuiEvent = "DoubleClick") {
  137.     LV_GetText(id, A_EventInfo, 3)
  138.     LV_GetText(pw, A_EventInfo, 4)
  139.     Sleep, 2500
  140.     Send, %id%
  141.     Sleep, 50
  142.     Send, {Tab}
  143.     Sleep, 50
  144.     Send, %pw%
  145.     Sleep, 50
  146.     Send, {Enter}
  147. }
  148. return
  149.  
  150.  
  151. ValidatePassword:
  152. Gui, Login: Submit, NoHide
  153. if (MasterPassword = "12345") {
  154.     GuiControl, , MasterPassword
  155.     Gui, Cancel
  156.     Gui, Main: Show, Center, Contas
  157.     SetUpColors()
  158. }
  159. return
  160.  
  161.  
  162. AddAccountToFile:
  163. Gui, NewAccount: Submit
  164. FileAppend, % "`nServidor: " Servidor "`t Char: " Char "`t ID: " ID "`t Password: " Password "`t ExtraInfo: " ExtraInfo , file.txt
  165. Sleep, 200
  166. LoadAccountsToWindow()
  167. LV_ModifyCol()
  168. return
  169.  
  170.  
  171. AddAccountWindow:
  172. Gui, NewAccount: Show, Center , Adicionar Conta
  173. return
  174.  
  175.  
  176. ~Escape::
  177. GuiControl,, Texto,
  178. Gui, Cancel
  179. return
RAW Paste Data