Advertisement
Baoulettes

HomePassMii - 1.0.4

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