Jump to content

Recommended Posts

Hi all!

I have a problem with creating the right varibles in the switch statment and wonder if some on can help me figure out the best way to procide?

i got the part when i create all trayitems with a "FOR" statement from an ini file working, but i fail when it comes to the switch statement.

ini file look like this..

[Links]

Calulator=Calc.exe

and so on...

 

here is part of my script..

it works for a few min.. then the hole application hangs (when compiled, seems to work in test mode, before i compile it?)

is this part that seems to cose the error?

Case Else
                    If $Msg > 0 Then
                    _DebugOut("While Statement - $Msg: " & $Msg)
                    $aSearch = _ArraySearch($Linksarray, $gText, 0, 0, 0, 1, 1, 0)
                    If @error Then

                    Else
                    $aSearch1 = _ArraySearch($Linksarray, $Linksarray[$aSearch][0], 0, 0, 0, 1, 1, 0)
                    If @error Then

                    Else
                    _DebugOut("While Statement - $aSearch1: " & $Linksarray[$aSearch1][0])
                    _DebugOut("While Statement - $aSearch1: " & $Linksarray[$aSearch1][1])
                    ShellExecute($Linksarray[$aSearch][1], "", "", "open")
                    EndIf
                    EndIf
                    EndIf

here is both functions...

Func _WinMain()
    _readConfigFile()
    Opt("TrayMenuMode", 11)
    Opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled

    _TrayInit()
    ; Main GUI Loop
    Local $tvHandle = 0
    $iBegin = TimerInit()
    $LatencyUrl = IniRead($ConfigFile, "General", "LatencyUrl", "www.charger.se")
    $LatencyMS = IniRead($ConfigFile, "General", "LatencyMS", "500")
    HotKeySet("+!z", '_ShowITSupport')
    HotKeySet("+!x", '_ShowITSupport')



    While 1
        $Msg = GUIGetMsg()
        $gText = _GetMenuText($Msg)
        If TimerDiff($iBegin) > 5000 Then ; Loop until 5 sec have passed
            _Ping($LatencyUrl, $LatencyMS)
            #cs
                Local $net_test = _IsInternetConnectedEx()
                ;           ConsoleWrite("$net_test: " & $net_test & @CRLF)
                If $net_test = 1 Then
                Local $net_test2 = __GetConnectedAdapterIPMAC()
                If StringInStr($net_test2, "Wireless") Or StringInStr($net_test2, "Wired") Then
                EndIf
                Else
                ConsoleWrite("$net_test2? " & __GetConnectedAdapterIPMAC() & @CRLF)
                EndIf
            #ce
            ;           ConsoleWrite("Counter: " & $iBegin & @CRLF)
            $iBegin = TimerInit()
        EndIf

        Switch $Msg
            Case $ToggleLogonUser
                _DebugOut("While Statement - $ToggleLogonUser: " & $gText)
                _ToggleLogonUser()

            Case $TrayTS
                _DebugOut("While Statement - $TrayTS: " & $gText)
                _DebugOut(@ScriptDir & "TeamViewerQS_sv-idcnnz7xxq.exe" & @CRLF)
                FileInstall("Res\TeamViewerQS_sv-idcnnz7xxq.exe", @ScriptDir & "\TeamViewerQS_sv-idcnnz7xxq.exe", 0)
                ShellExecute("TeamViewerQS_sv-idcnnz7xxq.exe", "", @ScriptDir, 'open')
                ;           Sleep(10000)
            Case $ResetInternet
                _DebugOut("While Statement - $ResetInternet: " & $gText)
                $tmpNessage = MsgBox(20, "Warning", "You are about to do a complete Network reset!")
                If $tmpNessage = 6 Then
                    _DebugOut("While Statement - $ResetInternet: MsgBox, Returns: " & $tmpNessage)
                Else
                    _DebugOut("While Statement - $ResetInternet: MsgBox, Returns: " & $tmpNessage)
                EndIf

            Case $TrayExit
                _DebugOut("While Statement - $TrayExit: " & $gText)
                _TrayIconDelete($nTrayIcon1)
                ExitLoop
            Case Else
                #cs
                    If $Msg > 0 Then
                    _DebugOut("While Statement - $Msg: " & $Msg)
                    $aSearch = _ArraySearch($Linksarray, $gText, 0, 0, 0, 1, 1, 0)
                    If @error Then

                    Else
                    $aSearch1 = _ArraySearch($Linksarray, $Linksarray[$aSearch][0], 0, 0, 0, 1, 1, 0)
                    If @error Then

                    Else
                    _DebugOut("While Statement - $aSearch1: " & $Linksarray[$aSearch1][0])
                    _DebugOut("While Statement - $aSearch1: " & $Linksarray[$aSearch1][1])
                    ShellExecute($Linksarray[$aSearch][1], "", "", "open")
                    EndIf
                    EndIf
                    EndIf
                #ce
        EndSwitch
        Sleep(10)
    WEnd
    _TrayIconDelete($nTrayIcon1)
EndFunc   ;==>_WinMain

Func _TrayInit()
    Opt('TrayMenuMode', 3) ; Default tray menu items (Script Paused/Exit) will not be shown.
    Opt('TrayAutoPause', 0) ; Script will not be paused when clicking the tray icon.
    ;Opt("TrayOnEventMode", 1)
    Opt('MustDeclareVars', 0)

    ; *** Create the tray icon ***
    ;Func _TrayIconCreate($sToolTip = "", $sIconFile = @AutoItExe, $nIconID = 0, $sCallback = "", $nMsg = 0, $hIcon = 0)

    ;TraySetIcon(@ScriptFullPath, "201")
    $nTrayIcon1 = _TrayIconCreate("Datornamn: " & @ComputerName & @CRLF & "IPAdress: " & @IPAddress1 & " ," & @IPAddress2, @ScriptFullPath, -1)
    _TrayIconSetClick(-1, 16)
    _TrayIconSetState() ; Show the tray icon

    ; *** Create the tray context menu ***
    Local $iIndex = _ArraySearch($GeneralArray, "Kund", 0, 0, 0, 1, 1, 0)
    $TrayMenuname = "ChaQ - " & $GeneralArray[$iIndex][1]
    $nTrayMenu1 = _TrayCreateContextMenu() ; is the same like _TrayCreateContextMenu(-1) or _TrayCreateContextMenu($nTrayIcon1)
    $nSideItem3 = _CreateSideMenu($nTrayMenu1)
    _SetSideMenuText($nSideItem3, $TrayMenuname)
    _SetSideMenuColor($nSideItem3, 0x00FFFF) ; yellow; default color - white
    _SetSideMenuBkColor($nSideItem3, 0x802222) ; bottom start color - dark blue
    _SetSideMenuBkGradColor($nSideItem3, 0x4477AA) ; top end color - orange
    _SetSideMenuImage($nSideItem3, "shell32.dll", 309, True)

    $TrayCase = _TrayCreateItem("SupportCenter, Add a Case")
    _TrayCreateItem("")
    _TrayItemSetIcon($TrayCase, @ScriptFullPath, -7)
    $TrayTS = _TrayCreateItem("Teamviwer")
    _TrayCreateItem("")
    _TrayItemSetIcon($TrayTS, @ScriptFullPath, -9)
    $MenuLinks = _TrayCreateMenu("Links")
    _TrayCreateItem("")
    _TrayItemSetIcon($MenuLinks, "shell32.dll", -44)
    $MenuTools = _TrayCreateMenu("Program")
    _TrayCreateItem("")
    _TrayItemSetIcon($MenuTools, "", 0)
    $chargeitem = _TrayCreateMenu("Tools")
    $chargeitem1 = _TrayCreateMenu("Settings", $chargeitem)
    _TrayCreateItem("")

    $TrayExit = _TrayCreateItem("Exit")

    _TrayItemSetIcon($TrayCase, @ScriptFullPath, -7)
    _TrayItemSetIcon($MenuLinks, "shell32.dll", -318)
    _TrayItemSetSelIcon($MenuLinks, "shell32.dll", -44)
    _TrayItemSetIcon($MenuTools, "shell32.dll", -20)
    _TrayItemSetSelIcon($MenuTools, "shell32.dll", -20)
    _TrayItemSetIcon($chargeitem, @ScriptFullPath, -11)
    _TrayItemSetSelIcon($chargeitem, @ScriptFullPath, -11)
    _TrayItemSetIcon($chargeitem1, @ScriptFullPath, -11)
    _TrayItemSetSelIcon($chargeitem1, @ScriptFullPath, -11)

    _TrayItemSetIcon($TrayHelp, "mstsc_101.ico", 0)
    _TrayItemSetIcon($TrayTS, @ScriptFullPath, -9)
    _TrayItemSetIcon($TrayExit, "shell32.dll", -28)

    ; *** Sub menu items ***
    For $x = 1 To $Linksarray[0][0]
        _DebugOut("$Linksarray " & $Linksarray[$x][0])
        If StringInStr($Linksarray[$x][1], "http") Then
            $Tray_Item[$x] = _TrayCreateItem($Linksarray[$x][0], $MenuLinks)
            _TrayItemSetIcon($Tray_Item[$x], "shell32.dll", -14)
        Else
            $Tray_Item[$x] = _TrayCreateItem($Linksarray[$x][0], $MenuTools)
            _TrayItemSetIcon($Tray_Item[$x], $Linksarray[$x][1], "")
        EndIf

    Next

    $EnableBit = _TrayCreateItem("Enable (BIT/WSUS)", $chargeitem)
    $DisableBit = _TrayCreateItem("Disable (BIT/WSUS)", $chargeitem)
    $ResetInternet = _TrayCreateItem("Reset Internet Connection", $chargeitem)
    $ToggleLogonUser = _TrayCreateItem("Toggle Username/logon screen", $chargeitem)

    _TrayItemSetIcon($TrayTSSite, "shell32.dll", -14)
    _TrayItemSetIcon($TraySupportSite, "shell32.dll", -14)
    _TrayItemSetIcon($TraySupportSite1, "shell32.dll", -14)
    _TrayItemSetIcon($DisableBit, "shell32.dll", -275)
    _TrayItemSetIcon($EnableBit, "shell32.dll", -276)
    _TrayItemSetIcon($ResetInternet, @ScriptFullPath, -12)
    _TrayItemSetIcon($ToggleLogonUser, "regedit.exe", -1)



    GUICtrlSetState($chargeitem, $GUI_DISABLE)
    GUICtrlSetState($EnableBit, $GUI_DISABLE)
    GUICtrlSetState($DisableBit, $GUI_DISABLE)
    GUICtrlSetState($ResetInternet, $GUI_DISABLE)


EndFunc   ;==>_TrayInit

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By abberration
      Software Installer
      Version: 2.0
      It's been been a long year, but I finally got some time to rework this project. I re-wrote everything from scratch because the old version was getting too complicated with so many options and sub-menus. This new version is much easier to use and I have been testing for a few days and it seems very stable.
      For those who are new to this software, it helps you install software silently/unattended. This new version tries to determine the silent switch automatically. You can also re-organize the order in which the software installs by dragging & dropping them in the listview. It now supports creating profiles and checks for missing software (and automatically unchecks them, so it does not attempt to install non-existent software). One feature I included was because I have seen several people on Youtube talk about disliking bright screens at night. So, now you can choose from a few color theme (half of them are dark). I dabbled a bit more into GDI+ to draw a few things and show my logo with a transparent background (hint: I'm not good at GDI+).
      Under the Help menu, you will find a User Guide, which goes through most of it's features. I included a new icon if you want to use when you compile the script (in the Assets > Misc folder).
      If you have questions, comments or suggestions, all are welcome. Hope you enjoy!
      Here it is in action:

       
      Software_Installer_2.0.zip
    • By Jemboy
      Recently I was working on a script with icons using GuiCtrkCreatIcon.
      I decided to change the sub folder name of the icons to a more meaning name, however made a typo.

      I tested the .exe on my test computer and it worked flawlessly (because both icon folder where on my test computer) 😁
      But after I installed the script on the intended computers , I got chaos!😵
      Zooming into the problem, I discovered, that because the icons could not be found, the ControlID were returned with a value of 0
      and thus played havoc within the GuiGetMsg() switch/case statement.
      I have been able to reproduce this  (see example)
      #include <GUIConstantsEx.au3> ;============================================================================================================ ; PLEASE, do not save this example in the example folder: C:\Program Files (x86)\AutoIt3\Examples\Helpfile ;============================================================================================================ Example() Func Example() GUICreate(" My GUI Icons", 250, 250) $Icon1 = GUICtrlCreateIcon("shell32.dll", 10, 20, 20) $Icon2 = GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 20, 40, 32, 32) $Icon3 = GUICtrlCreateIcon("shell32.dll", 7, 20, 75, 32, 32) GUISetState(@SW_SHOW) ;$Icon2 = -1 ; ==> When this line is uncommented the script "works", so -1 could be a potential fix. ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Icon2 Beep (500,500) EndSwitch WEnd GUIDelete() EndFunc ;==>Example If you save the above script outside the Autoit example folder and run it, it will keep beeping because GuiCtrlCreatIcon did not find horse.ani and return $Icon2=0.
      At the moment GUICtrlCreateIcon () only returns the conntrolID on success and 0 on failure.
      I would like to propose a return of -1 on failure, so a existing and working script won't go awry when the icon can not be found.
       
    • By MONaH-Rasta
      Opt('TrayAutoPause', 0) $iTray1 = TrayCreateItem('Tray 1') TrayItemSetState(-1, 1) TrayCreateItem('') $iTrayMenu1 = TrayCreateMenu('Tray Menu 1') $iTray2 = TrayCreateItem('Tray 2', $iTrayMenu1, -1, 1) TrayItemSetState(-1, 1) $iTray3 = TrayCreateItem('Tray 3', $iTrayMenu1, -1, 1) $iTray4 = TrayCreateItem('Tray 4', $iTrayMenu1, -1, 1) TrayCreateItem('') $iTrayMenu2= TrayCreateMenu('Tray Menu 2') $iTray5 = TrayCreateItem('Tray 5', $iTrayMenu2, -1, 1) TrayItemSetState(-1, 1) $iTray6 = TrayCreateItem('Tray 6', $iTrayMenu2, -1, 1) $iTray7 = TrayCreateItem('Tray 7', $iTrayMenu2, -1, 1) TrayCreateItem('') $iTray8 = TrayCreateItem('Tray 8') $iTray9 = TrayCreateItem('Tray 9') $iTray10 = TrayCreateItem('Tray 10') TrayItemSetState(-1, 1) While True Sleep(1000*5) WEnd When I click on Tray 3 / Tray 4 / Tray 6 / Tray 7 nothing happens. Only Tray 2 and Tray 5 stay checked.
      I have tried setting 
      Opt("TrayMenuMode", 8) In this case radio menuitems act like normal menuitems only looks different.
      I'm using AutoIt v3.3.14.5.
      Tested on Windows 10 LTSC 2019 (1809) x64 version: 10.0.17763 build 17763.475 and Windows Server 2008 R2.
      Tried run script x64 and x86 same result.
      Is this kind a bug or something?
    • By xtcislove
      I have a script which is not very good written and could be mouch smaller etc. but thats not the point.

      The Problem is that sometimes my script stuck and the reason is i am using a tray menu and hotkeys to call other functions...

      Is there a way, to only allow a new hotkey function to get started when the other stopped? 

      Or a way to always return to the tray menu? 
       
      #RequireAdmin #include <StringConstants.au3> #include <TrayConstants.au3> #include <Process.au3> #include <File.au3> #include <FileConstants.au3> #include "ScalingMessageBox.au3" #include "_GetCurrentSoundDevice.au3" #include <Array.au3> #include <WinAPI.au3> #include <_MuteActiveWindow.au3> Opt("TrayMenuMode", 3) Opt("TrayIconDebug", 1) Global $IsMinimized = 0 Global $ActualWindow HotKeySet("+!s", "SwitchSoundDevice") ; Shift-Alt-t. - Hotkey to switch between devices. HotKeySet("+!k", "AppMinMax") ; Shift-Alt-k. - Hotkey to minimize/maximize current app. HotKeySet("+!t", "Taskkiller") ; Shift-Alt-t. - Hotkey to kill current app. HotKeySet("+!f", "SteamFriends") ; Shift-Alt-f. - Hotkey to open Steam Friends. HotKeySet("+!n", "Notepad") ; Shift-Alt-N. - Hotkey for Notepad Function. HotKeySet("+!m", "_MuteActiveWindow") ; Shift-Alt-M. - Hotkey to mute active window sound. HotKeySet("+!c", "SciTEClipboard") ; Shift-Alt-M. - Hotkey to mute active window sound. If Not ProcessExists("aida64.exe") Or Not ProcessExists("RemotePanel.exe") Or Not ProcessExists("PerfTune.exe") Then local AutoStart() local $dcPID[3] $dcPID[0] = 2 $dcPID[1] = ShellExecute("D:\Batch Space\WindowsAutomation\DownloadControl.au3") $dcPID[2] = ShellExecute("D:\Batch Space\WindowsAutomation\FrapsMessage.au3") SwitchSoundDevice("Speaker") ;-> Selecting Speaker on Startup. Local $iSteam = TrayCreateItem("Steam") TrayCreateItem("") ; Create a separator line. Local $iMobileAuthenticator = TrayCreateItem("Mobile Authenticator") TrayCreateItem("") ; Create a separator line. Local $iGames = TrayCreateMenu("Games") ; Create a tray menu sub menu with two sub items. Local $iPUBG = TrayCreateItem("PLAYERUNKNOWN'S BATTLEGROUNDS", $iGames) Local $iDARWIN = TrayCreateItem("Darwin Project", $iGames) Local $iFORTNITE = TrayCreateItem("Fortnite Battle Royale", $iGames) TrayCreateItem("") ; Create a separator line. Local $iStopWatch = TrayCreateItem("StopWatch") TrayCreateItem("") ; Create a separator line. Local $iTimer = TrayCreateItem("Timer") TrayCreateItem("") ; Create a separator line. Local $iTaskManager = TrayCreateItem("TaskManager") TrayCreateItem("") ; Create a separator line. Local $iRestartSensor = TrayCreateItem("RestartSensor") TrayCreateItem("") ; Create a separator line. Local $iShutdown = TrayCreateItem("Shutdown") TrayCreateItem("") ; Create a separator line. Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. While 1 Switch TrayGetMsg() Case $iSteam ShellExecute("D:\Spiele\Steam\Steam.exe") Case $iMobileAuthenticator ShellExecute("D:\Batch Space\WindowsAutomation\MobileAuthenticator.au3") Case $iPUBG ShellExecute("steam://rungameid/578080") Case $iDARWIN ShellExecute("steam://rungameid/544920") Case $iFORTNITE Run("D:\Spiele\Epic Games\Fortnite\FortniteGame\Binaries\Win64\FortniteClient-Win64-Shipping.exe") Case $iStopWatch ShellExecute("D:\Batch Space\WindowsAutomation\StopWatch.au3") Case $iTimer ShellExecute("D:\Batch Space\Timer\Timer.bat") Case $iTaskManager ShellExecute("D:\Batch Space\TaskManager\Taskmanager.bat") Case $iRestartSensor If ProcessExists("RemotePanel.exe") Then ProcessClose("RemotePanel.exe") If ProcessExists("aida64.exe") Then ProcessClose("aida64.exe") ScreenState() ShellExecute("C:\Program Files (x86)\FinalWire\AIDA64 Extreme\aida64.exe","",@SW_SHOWNORMAL) Run("C:\Program Files (x86)\Odospace\Remote Panel\RemotePanel.exe") Case $iShutdown ShellExecute("D:\Batch Space\WindowsAutomation\Shutdown.au3") Case $idExit for $i = 1 To $dcPID[0] If ProcessExists($dcPID[$i]) Then ProcessClose($dcPID[$i]) Next Exit EndSwitch WEnd Func SciTEClipboard() _sMsgBox("SciTE Clipboard", "MsgBox;_sMsgBox", "Choose a option: ", "db=1;to=7;tr=10") if @extended = 1 Then ClipPut('MsgBox(0, "Test", "Test")') if @extended = 2 Then ClipPut('_sMsgBox("Test", "Ok", "Test", "")'&@CRLF) Return EndFunc Func Notepad() _sMsgBox("Launch SciTE or Notepad++?", "SciTE;Notepad++", "Launch SciTE or Notepad++?", "db=1;to=10;tr=10") if @extended = 1 Then Run("C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe") if @extended = 2 Then Run("C:\Program Files (x86)\Notepad++\notepad++.exe") EndFunc Func SwitchSoundDevice($SoundDevice = "") local $NirCMD = "D:\Batch Space\tools\nircmd.exe" ; nircmd.exe path local $IconPath = "D:\Batch Space\ICON\" ; Icons path local $CurrentDevice = StringLeft(_GetCurrentSoundDevice(), 7) If Not IsDeclared("SoundDevice") Then if $CurrentDevice = "Headset" Then Local $SoundDevice = "Speaker" if $CurrentDevice = "Speaker" Then Local $SoundDevice = "Headset" Run($NirCMD & " setdefaultsounddevice " & $SoundDevice) EndIf TrayTip($SoundDevice & " active.", " ", 1, $TIP_ICONASTERISK) TraySetToolTip($SoundDevice & " active.") TraySetIcon($IconPath & $SoundDevice & ".ico") Local $sActualWindow = WinGetTitle("[ACTIVE]") If $SoundDevice = "Headset" Then If Not ProcessExists("ts3client_win64.exe") Then _sMsgBox("Headset Active, Teamspeak not.", "Yes;No", "Headset active, TeamSpeak 3 is not running.", "db=1;to=10") If @extended = 1 Then ShellExecute("C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe") WinWaitActive("TeamSpeak3") EndIf EndIf EndIf If ProcessExists("ts3client_win64.exe") Then WinActivate("TeamSpeak3") If $SoundDevice = "Speaker" Then Send("!b") ; Alt + b -> Mute Mic/Speaker in Teamspeak. If $SoundDevice = "Headset" Then Send("!m") ; Alt + m -> Unmute Mic/Speaker in Teamspeak. EndIf If WinExists($sActualWindow) Then WinActivate($sActualWindow) EndFunc Func AppMinMax($IsMinimized) ;==>AppMinMax function. If $IsMinimized = 0 Then $ActualWindow = WinGetTitle("[ACTIVE]") TraySetState($TRAY_ICONSTATE_FLASH) WinSetState($ActualWindow, "", @SW_MINIMIZE) TraySetToolTip("Minimized: " & $ActualWindow) $IsMinimized = 1 else Local $Process = _ProcessGetName(WinGetProcess($ActualWindow)) For $i = 1 to _FileCountLines("D:\Batch Space\WindowsAutomation\Games.txt") $Line = FileReadLine("D:\Batch Space\WindowsAutomation\Games.txt", $i) If $line = $Process Then If WinExists($ActualWindow) Then WinActivate($ActualWindow) WinSetState($ActualWindow, "", @SW_MAXIMIZE) EndIf ExitLoop EndIf Next WinActivate($ActualWindow) TraySetToolTip("Restored: " & $ActualWindow) TraySetState($TRAY_ICONSTATE_STOPFLASH) $IsMinimized = 0 EndIf EndFunc ;==>AppMinMax stop. Func Taskkiller() ;==>Taskkiller function. local $Window = WinGetTitle("[ACTIVE]") local $Process = _ProcessGetName(WinGetProcess($Window)) _sMsgBox("Kill " & $Process & "?", "Yes.,No.", "Do you like to kill: " &@LF&@LF& $Window & "?", "db=1;to=1,20") If @extended = 1 Then ProcessClose($Process) If WinExists($Window) Then WinActivate($Window) EndFunc ;==>Taskkiller stop. Func SteamFriends() ;==>SteamFriends function. ShellExecute("steam://open/friends/") AppMinMax(0) WinActivate("Friends") EndFunc ;==>SteamFriends stop. Func AutoStart() TraySetToolTip("Autorun active.") TraySetIcon("D:\Batch Space\ICON\Autorun.ico") TraySetState($TRAY_ICONSTATE_FLASH) RunWait('regedit /s "D:\Batch Space\WindowsAutomation\REGISTRY.reg"') ShellExecute("C:\Program Files (x86)\Intel\Intel(R) Extreme Tuning Utility\Client\PerfTune.exe","",@SW_SHOWNORMAL) WinWaitActive("Intel® Extreme Tuning Utility", "", 20) WinActivate("Intel® Extreme Tuning Utility") WinClose("Intel® Extreme Tuning Utility") If ProcessExists("RemotePanel.exe") Then ProcessClose("RemotePanel.exe") If ProcessExists("aida64.exe") Then ProcessClose("aida64.exe") ScreenState() ShellExecute("C:\Program Files (x86)\FinalWire\AIDA64 Extreme\aida64.exe","",@SW_SHOWNORMAL) Run("C:\Program Files (x86)\Odospace\Remote Panel\RemotePanel.exe") Run("G:\Programme\Tools\W10Privacy\W10Privacy.exe /s 1") BatteryLevel() TraySetState($TRAY_ICONSTATE_STOPFLASH) EndFunc Func ScreenState() FileChangeDir("C:\Program Files (x86)\Odospace\Remote Panel\adb") If ProcessExists("adb.exe") Then ProcessClose("adb.exe") Local $Odospace = StringInStr(_RunCmd('adb -s 3200d994ae6f9000 shell dumpsys activity activities | find "mFocusedActivity:"'), "com.odospace.remotepanel") If $Odospace <> 0 Then RunWait(@ComSpec & ' /c ' & "adb -s 3200d994ae6f9000 shell am force-stop com.odospace.remotepanel", @TempDir, @SW_HIDE) RunWait(@ComSpec & ' /c ' & "adb -s 3200d994ae6f9000 shell monkey -p com.odospace.remotepanel -c android.intent.category.LAUNCHER 1", @TempDir, @SW_HIDE) RunWait(@ComSpec & ' /c ' & "adb -s 3200d994ae6f9000 shell input keyevent KEYCODE_WAKEUP", @TempDir, @SW_HIDE) EndFunc Func BatteryLevel() FileChangeDir("C:\Program Files (x86)\Odospace\Remote Panel\adb") If ProcessExists("adb.exe") Then ProcessClose("adb.exe") Local $sBatteryLevel = StringTrimLeft(_RunCmd('adb -s 3200d994ae6f9000 shell dumpsys power | find "mBatteryLevel="'), 14) If $sBatteryLevel < 10 Then MsgBox(0, "Warning!", "Battery Level from Sensor Tablet is at: " & $sBatteryLevel & "%" & @CRLF & @CRLF & "Press ok to shutdown Tablet.") RunWait(@ComSpec & ' /c ' & "adb -s 3200d994ae6f9000 shell input keyevent KEYCODE_SLEEP", @TempDir, @SW_HIDE) Endif TrayTip("Tablet Battery Level is at: " & $sBatteryLevel & " %.", " ", 1, $TIP_ICONASTERISK) EndFunc Func _RunCmd($sCommand) If StringLeft($sCommand, 1) = " " Then $sCommand = " " & $sCommand Local $nPid = Run (@Comspec & " /c" & $sCommand, "", @SW_Hide, 8), $sRet = "" If @Error then Return "ERROR:" & @ERROR ProcessWait ($nPid) While 1 $sRet &= StdoutRead($nPID) If @error Or (Not ProcessExists($nPid)) Then ExitLoop WEnd Return StringStripWS($sRet, 3) EndFunc ; ==> _RunCmd  
    • By Skysnake
      From From here, bottom of the post
      I am not arguing the logic of this, merely would like to point out that if there is such a rule, it is not documented...  Are there other such rules?
      Skysnake
×
×
  • Create New...