Вложений: 1
Цитата:
Сообщение от Lexx09
(Сообщение 379798)
Выложи свой iCarMainScript.exe.
|
код
так же архивом залил.
Код:
#NoTrayIcon
#RequireAdmin
#pragma compile(Icon, "C:\Program Files (x86)\AutoIt3\Icons\MyAutoIt3_Yellow.ico")
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include
#include
#include
#include
#include
Global $iPID, $sOut, $sInterface, $aResult
Local $asConnection, $asAvailableNets, $sCurrentProfile
_Wlan_StartSession()
$sMessages = 0
$cTimer = 5000
$myAlpha = 50
$sInterface = IniRead(@ScriptDir & '\wifi.ini', 'wifi', 'interface', 0)
Local $omyerror
$omyerror = ObjEvent("AutoIt.Error", "MyErrFunc")
Dim $vol_from_speed[201]
Global $rr = ObjCreate("RideRunner.sdk")
_main()
Func myerrfunc()
$hexnumber = Hex($omyerror.number, 8)
Exit
EndFunc
Func _initvolarray()
$delta = 0
$vol_from_speed[0] = $delta
For $i = 0 To 150 Step 10
$tmp_vol_from_speed = $rr.getinfo("=$vol_from_speed_" & $i + 10 & "$") / 10
For $j = 1 To 10 Step 1
$delta = $delta + $tmp_vol_from_speed
$vol_from_speed[$i + $j] = Round($delta, 2)
Next
Next
For $i = 162 To 200 Step 1
$delta = $delta + $tmp_vol_from_speed
$vol_from_speed[$i] = Round($delta, 2)
Next
EndFunc
Func _main()
Global $iswork = 1
Global $isrun = 0
Global $name = "[CLASS:TSkinForm]"
Global $namecontrol = ""
Global $foobarwindowtitleprev = ""
Global $speed_prev = Round(Number($rr.getinfo("$IsDriveSpd$")), 0)
Global $speed_prev_round = Round($speed_prev, -1)
Global $vol_from_speed_full = 0
Global $vol_min = Number($rr.getinfo("=$vol_from_speed_min$"))
Global $vol_max = Number($rr.getinfo("=$vol_from_speed_max$"))
_Wlan_StartSession()
_Wlan_StartNotificationModule()
If _Wlan_QueryInterface() = "Connected" Then
Local $asConnection = _Wlan_QueryInterface($WLAN_INTF_OPCODE_CURRENT_CONNECTION)
$sCurrentProfile = $asConnection[2]
Else
_enable_()
Sleep(3000)
Local $asNetworks = _Wlan_GetNetworks(True) ;True will perform a scan before returning a list.
;_ArrayDisplay($asNetworks)
For $i = 0 To UBound($asNetworks) - 1
If StringInStr($asNetworks[$i][9], "P") Then ;If the entry has a profile.
$sCurrentProfile = $asNetworks[$i][0]
ExitLoop
EndIf
Next
_check_interface()
EndIf
_initvolarray()
$rr.execute("SetVar;vol_from_speed_full;" & Round($vol_from_speed[$speed_prev], 2))
While $iswork
$handle = WinGetHandle($name)
If @error Then
If $isrun Then
$iswork = 0
EndIf
Else
$isrun = 1
If WinActive($name) OR WinActive("[CLASS:TOverlayForm]") OR WinActive("[CLASS:TPopupSkinForm]") OR WinActive("[CLASS:TModalSkinForm]") OR WinActive("[CLASS:TMediaForm]") Then
$rr.execute("SETIND;!iCarDS_Active;ON")
Else
$rr.execute("SETIND;!iCarDS_Active;OFF")
EndIf
EndIf
$volume = StringSplit($rr.getinfo("VOLUME"), "%")
If @error = 0 Then
$current_volume = Number($volume[1])
Else
$current_volume = 0
EndIf
$speed_current = Round(Number($rr.getinfo("$IsDriveSpd$")), 0)
If $speed_current > $speed_prev Then
$delta_vol = Round($vol_from_speed[$speed_current] - $vol_from_speed[$speed_prev], 2)
If $current_volume + $delta_vol < $vol_max Then $rr.execute("volperc+;" & $delta_vol & "||SetVar;vol_from_speed_full;" & $vol_from_speed[$speed_current])
Else
If $speed_current < $speed_prev Then
$delta_vol = Round($vol_from_speed[$speed_prev] - $vol_from_speed[$speed_current], 2)
If $current_volume - $delta_vol > $vol_min Then $rr.execute("volperc-;" & $delta_vol & "||SetVar;vol_from_speed_full;" & $vol_from_speed[$speed_current])
EndIf
EndIf
$speed_prev = $speed_current
If Number($rr.getinfo("=$Is_new_vol_from_speed$")) = 1 Then
_initvolarray()
$rr.execute("SetVar;Is_new_vol_from_speed;0")
EndIf
Sleep(300)
If Not (Ping("www.google.com", 250) Or Ping("www.yandex.ru", 250)) Then ;пингуем гугл и если нет подключаемся
If Not (_Wlan_QueryInterface() = "Connected") Then ;проверяем подключение активного профиля
If _Wlan_Connect($sCurrentProfile, False) Then ;True will wait for the interface to connect. Подключаемся к сети.
_check_interface()
ElseIf Not (_Wlan_QueryInterface() = "Connected") Then ;если все еще нет сети пытаемсся включить адаптер
_enable_() ;включаем адаптер
EndIf
EndIf
EndIf
Sleep($cTimer) ;цикл в 10 сек
$overlay_handle = WinGetHandle("[CLASS:TOverlayForm]")
If ($overlay_handle And WinExists($overlay_handle)) Then
Local $iTransColor, $iAlpha
$iInfo = _WinAPI_GetLayeredWindowAttributes($overlay_handle, $iTransColor, $iAlpha)
If ($iAlpha <= 100) Then
Sleep(3000)
_WinAPI_SetLayeredWindowAttributes($overlay_handle, $iTransColor, $myAlpha)
EndIf
EndIf
Sleep(300)
If (ProcessExists("HD-Frontend.exe") And ($bsNoBorder = 1)) Then
; Убираем рамку вокруг окна BlueStacks
$bsHandle = WinGetHandle("BlueStacks App Player")
$bsStyle = _WinAPI_GetWindowLong($bsHandle, $GWL_STYLE)
$bsStyle = BitAND($bsStyle, BitNOT($WS_BORDER), BitNOT($WS_CAPTION), BitNOT($WS_THICKFRAME))
_WinAPI_SetWindowLong($bsHandle, $GWL_STYLE, $bsStyle)
EndIf
WEnd
EndFunc
Func _check_interface()
;If Not $sInterface Then
$iPID = Run('netsh.exe wlan show interfaces', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$sOut = ''
ProcessWaitClose($iPID)
Do
$sOut &= StdoutRead($iPID)
Until @error
$aResult = StringRegExp(_Encoding_866To1251($sOut), '(Имя|Name) *: *(.+) *', 1)
;_ArrayDisplay($aResult)
If UBound($aResult) >= 2 Then
$sInterface = $aResult[1]
EndIf
;MsgBox(0, "Check Interface result:", $sInterface)
$sInterface_check = IniRead(@ScriptDir & '\wifi.ini', 'wifi', 'interface', 0)
If Not ($sInterface == $sInterface_check) Then
IniWrite(@ScriptDir & '\wifi.ini', 'wifi', 'interface', $sInterface)
EndIf
;EndIf
EndFunc ;==>_check_interface
Func _enable_()
RunWait('netsh.exe interface set interface "' & $sInterface & '" enable', '', @SW_HIDE) ; включить
Sleep(200)
;$sping_ = Ping("www.google.com", 250)
;MsgBox(0, "Ping:", $sping_)
EndFunc ;==>_enable_
Func _disable_()
RunWait('netsh.exe interface set interface "' & $sInterface & '" disable', '', @SW_HIDE) ; выключить
Sleep(200)
EndFunc ;==>_disable_
|