Baoulettes

HomePassMii - 1.0.4

Jan 18th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance force
  2. #NoEnv                  ; Recommended for performance and compatibility with future AutoHotkey releases.
  3. SendMode Input          ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%
  5. ; 29/08/2015 1.0.0 by Baoulettes aka Joffrey Panisset
  6. ; 10/09/2015 1.0.1 by Baoulettes aka Joffrey Panisset
  7. ; 25/11/2015 1.0.2 by Baoulettes aka Joffrey Panisset
  8. ; 25/12/2015 1.0.3 by Baoulettes aka Joffrey Panisset
  9. ; 18/01/2016 1.0.4 by Baoulettes aka Joffrey Panisset
  10. ; COM.ahk Standard Library
  11. ; by Sean
  12. ; http://www.autohotkey.com/forum/topic22923.html
  13. ; NBAHomePass & mac adress list by Nba_Yoh
  14. ; Logo & UI by Baoulettes
  15. ; Unauthorized copy or use of this source is forbidden.
  16. ; List of authorized persons :
  17. ; Nba_Yoh because I use his soft (need his approve that why compiled version isn't provided.)
  18. ; Myself : Baoulettes / Joffrey Panisset.
  19. ; This code is used for learned process Only.
  20. ; In any case it is intended to make ANY profit on it !
  21.  
  22. #include %A_ScriptDir%/Lib/COM.ahk
  23.  
  24. Process, Close, NbaHomePass.exe ; To prevent ANY conflict later.
  25.  
  26. ;Creating Ressources Directory :
  27. fileCreateDir, %A_ScriptDir%\ressources\
  28.  
  29. ;Installing required files :
  30. FileInstall, D:\Softwares\AutoHotKey\Software\HomePassMii\Ressources\Logo.png, %A_ScriptDir%\ressources\Logo.png
  31. FileInstall, D:\Softwares\AutoHotKey\Software\HomePassMii\Ressources\UnCons.png, %A_ScriptDir%\ressources\UnCons.png
  32.  
  33. ;Variable Set:
  34. SoftwareName    =   HomePassMii
  35. SoftwareVersion =   1.0.4
  36. winh            =   340
  37. winw            =   900
  38. consoleh        =   %winh%:+10
  39. consolew        =   600
  40. emptysize       =   0
  41.  
  42.  
  43. Gui, 1:Add, Picture, x-1 y0 w296 h60 BackGroundTrans, %A_ScriptDir%\ressources\Logo.png
  44. Gui, 1:Add, Picture, x300 y0 w%consolew% h%consoleh% vPicPHC, %A_ScriptDir%\ressources\UnCons.png
  45. Gui, 1:Add, Text, x13 y69 w270 h20 +Center, How to use :
  46. Gui, 1:Add, Text, x13 y89 w270 h20 +Center, 1: Launch the application with administrator rights
  47. Gui, 1:Add, Text, x13 y109 w270 h20 +Center, 2: Change if you want MAC Address to be shuffled or not
  48. Gui, 1:Add, Text, x13 y129 w270 h20 +Center, 3: Set time for the connection and delay (In Secondes !)
  49. Gui, 1:Add, Text, x13 y149 w270 h20 +Center, 4: Press Start to launch the process !
  50. Gui, 1:Add, GroupBox, x0 y59 w300 h120 , How to use
  51. Gui, 1:Add, Text, x23 y199 w130 h20 +Right, Shuffled MAC list :
  52. Gui, 1:Add, DropDownList, x173 y199 w100 h20 r2 vShuffled, True||False
  53. Gui, 1:Add, Text, x23 y229 w130 h20 +Right, * Reconnection Delay :
  54. Gui, 1:Add, DropDownList, x173 y229 w100 h20 r11 vReconnectionDelay, 5||10|15|20|30|35|40|45|50|55|60
  55. Gui, 1:Add, Text, x23 y259 w130 h20 +Right, * Connection Duration :
  56. Gui, 1:Add, DropDownList, x173 y259 w100 h20 r21 vConnectionDuration, 100|200||300|400|500|600|700|800|900|1000|1500|2000|3000|4000|5000|6000|7000|8000|9000
  57. Gui, 1:Add, Text, x23 y289 w250 h20 +Center, * Time in secondes !
  58. Gui, 1:Add, GroupBox, x0 y179 w300 h127 , Parameters
  59. Gui, 1:Add, Button, x3 y308 w290 h30 gStart, Start
  60. Gui, 1:Show, h%winh% w%winw%, %SoftwareName% - %SoftwareVersion%
  61. Return
  62.  
  63. Start:
  64. Process, Close, NbaHomePass.exe ; In case someone click Start Again.
  65. Process, Close, %pid% ; In case someone click Start Again.
  66. GuiControl, Move, PicPHC, x300 y0 w%emptysize% h%emptysize%
  67. Gui, Submit, nohide
  68. StringLower Shuffled, Shuffled
  69. FileDelete, %A_ScriptDir%\ressources\Start.bat
  70. FileAppend,
  71. (
  72.     %A_ScriptDir%\ressources\NbaHomePass.exe %A_ScriptDir%\ressources\macs.txt %Shuffled% %ConnectionDuration% %ReconnectionDelay%
  73. ), %A_ScriptDir%\ressources\Start.bat
  74. Run, %A_ScriptDir%\ressources\Start.bat, %A_ScriptDir%\ressources\,, pid
  75. Gui, +lastfound
  76. Gui, +hwndghwnd
  77. Gui_1_ID := WinExist()
  78. Set_Parent_by_id(Gui_1_ID, 1) ; Window_ID, Gui_Number
  79. Gui, +LastFound +%WS_CLIPCHILDREN%
  80. GuiWindow := WinExist()
  81. DetectHiddenWindows, On
  82. WinWait, ahk_pid %pid%
  83. ConsoleWindow := WinExist()
  84. VarSetCapacity(ConsoleRect, 16)
  85. DllCall("GetClientRect", "uint", ConsoleWindow, "uint", &ConsoleRect)
  86. ConsoleWidth := NumGet(ConsoleRect, 8)
  87. ConsoleHeight:= NumGet(ConsoleRect, 12)
  88. WS_POPUP := 0x80000000
  89. WS_CAPTION := 0xC00000
  90. WS_THICKFRAME := 0x40000
  91. WS_EX_CLIENTEDGE := 0x200
  92. WS_CHILD := 0x40000000
  93. WS_CLIPCHILDREN := 0x2000000
  94. SWP_NOACTIVATE := 0x10
  95. SWP_SHOWWINDOW := 0x40
  96. SWP_NOSENDCHANGING := 0x400
  97. WinSet, Style, % -(WS_POPUP|WS_CAPTION|WS_THICKFRAME)
  98. WinSet, Style, +%WS_CHILD%
  99. WinSet, ExStyle, -%WS_EX_CLIENTEDGE%
  100. DllCall("SetParent", "uint", ConsoleWindow, "uint", GuiWindow)
  101. DllCall("SetWindowPos", "uint", ConsoleWindow, "uint", 0, "int", 300, "int", 0, "int", consolew, "int", consoleh, "uint", SWP_NOACTIVATE|SWP_SHOWWINDOW|SWP_NOSENDCHANGING)
  102. return
  103.  
  104. Set_Parent_by_id(Window_ID, Gui_Number) ; title text is the start of the title of the window, gui number is e.g. 99
  105. {
  106.   Gui, %Gui_Number%: +LastFound
  107.   Return DllCall("SetParent", "uint", WinExist(), "uint", Window_ID) ; success = handle to previous parent, failure =null
  108. }
  109.  
  110. NET_Connect(bEnable = False, sConnection = "Local Area Connection")
  111. {
  112. ;COM_Init()
  113.    COM_CoInitialize()
  114.    psh := COM_CreateObject("Shell.Application")
  115.    ;pns := COM_Invoke(psh, "Namespace", 3, CSIDL_Connections:=0x0031)
  116.    pns := COM_Invoke(psh, "Namespace",, CSIDL_Connections:=0x0031)
  117.    pitems := COM_Invoke(pns, "Items")
  118.  
  119.    Loop, % COM_Invoke(pitems, "Count")
  120.    {
  121. ;      pid := COM_Invoke(pitems, "Item", 3, A_Index-1)
  122.       pid := COM_Invoke(pitems, "Item",, A_Index-1)
  123.       If (COM_Invoke(pid, "Name") = sConnection)
  124.       {
  125.          bRes := True
  126.          Break
  127.       }
  128.       COM_Release(pid)
  129.    }
  130.  
  131.    If !bRes
  132.    ExitApp
  133.  
  134.    pverbs := COM_Invoke(pid, "Verbs")
  135. ;   pvb := COM_Invoke(pverbs, "Item", 3, nVB:=0)
  136.    pvb := COM_Invoke(pverbs, "Item",, nVB:=0)
  137.  
  138.    If pvb
  139.    {
  140.       sVerbName := COM_Invoke(pvb, "Name")
  141.       If (bEnable && InStr(sVerbName, "&a")) || (!bEnable && InStr(sVerbName, "&b"))   ; &a and &b can be Language dependent.
  142.       COM_Invoke(pvb, "DoIt")
  143.       WinWait, %sConnection% ahk_class #32770,, 1
  144.       WinWaitClose
  145.       COM_Release(pvb)
  146.    }
  147.  
  148.    COM_Release(pverbs)
  149.    COM_Release(pid)
  150.    COM_Release(pitems)
  151.    COM_Release(pns)
  152.    COM_Release(psh)
  153.    COM_CoUninitialize()
  154. }
  155.  
  156. GuiEsape:
  157. 1:GuiEsape:
  158. GuiClose:
  159. 1:GuiClose:
  160. Exiting:
  161. 1:Exiting:
  162. OnExit
  163. Process, Close, NbaHomePass.exe ; Need better method? but who would run two instance of this?
  164. Process, Close, %pid% ; May be a bit forceful? No effect if it already closed.
  165. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment