Jump to content

Search the Community

Showing results for tags 'traymenu'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 6 results

  1. 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?
  2. 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
  3. I'd be happy with help, even for problem (1) alone, so don't be overwhelmed... Rusty and frustrated with some weird stuff in my program for well over 2 years, I've finally made a reproducer... (I'm using v3.3.14.1 here) In this forum, I picked up some code to detect a Mouse Right-click (see URL below). I have no idea if that code is solid or dodgy... In my program I test for the combo of Shift + Right-click, which will then automatically copy the URL of an underlying html link and do stuff with it (here simply replaced with a BEEP). In the reproducer, when doing Shift + R-click anywhere, this should initially BEEP (if your sound is on), unless you enable the TrayMenu... Problems that have come up so far ... (1) [SOLVED with help of 3rd post] If you enable the line creating the _Example_TrayMenu(), that menu will work but my Shift + R-click feature seems sabotaged by it for some reason...? (2) [I pray this might be solved by (1), cause this one may be hard to get a clue on...] If I set everything [no TrayMenu] so I can use the Shift + R-click detection, another problem is that this feature often gets disabled somehow — usually between 5 to 120 mins. Occasionally, it still works the following morning. Still have I been unable to get a clue to what might sabotage it. It might be a specific thing me or my PC is doing, or might it be a buffer that is corrupting by the use of the detection code? (I'm pretty sure I'm also getting this without pausing/unpausing my program, but I'll retest) (there is a chance this may not happen in the reproducer and only in my full program; I'll try and test for that) (3) To hopefully prevent (2) — and since I usually pause the utility quite often — I hoped that at the same time correctly stopping and restarting this detection system might mostly prevent the problem, or at least make it easy for me to reboot the functionality by pausing/unpausing. I asked if I was doing that right more than a year ago, but possibly in a time that many took their holiday, so never heard back. That question (and the original detection code) is here (I guess it needs a reproducer too, and I may make that tomorrow...) : If (1) could get solved, I'd be very happy and could retest for (2) a while. (3) is of course also very welcome, cause it might be the 'easy' workaround for (2), or another reason stuff might get corrupted (although I'm currently probably not pausing/unpausing the detection system, cause how I do it crashes AutoIt; see other topic). Thank You for having a look! #Region #AutoIt3Wrapper_UseX64=n #EndRegion #include <Misc.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <TrayConstants.au3> Opt("TrayMenuMode", 3) Local $hDLL = DllOpen("user32.dll") ;~ _Example_TrayMenu() ; When enabled, the Shift + R-click detection won't work. Why? ; mouse R-click detection code from www.autoitscript.com/forum/topic/119856-detect-fast-mouse-click Global Const $HC_ACTION = 0 Global $hStub_MouseProc = DllCallbackRegister("_MouseProc", "long", "int;wparam;lparam") Global $hmod = _WinAPI_GetModuleHandle(0) Global $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub_MouseProc), $hmod) Global $iMseDwn = 0 Func _MouseProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf If $nCode = $HC_ACTION Then Switch $wParam Case $WM_RBUTTONDOWN $iMseDwn = 3 ; assigned code for a Mouse R-click EndSwitch EndIf Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc While 1 ; MAIN LOOP Switch $iMseDwn Case 3 ; Mouse Right was clicked MouseUp($MOUSE_CLICK_RIGHT) ; 'unclick' it $iMseDwn = 0 ; reset var If _isPressed("10", $hDLL) Then ; is Shift held down as well? _Mouse_R_click(10) ; (10 = Shift key) call BEEP Func EndIf EndSwitch Sleep(50) WEnd Func _Mouse_R_click($_modKey) ; called from MAIN LOOP if Shift was held down before R-click If $_modKey = 10 Then ;~ MsgBox(0,"", "You performed Shift + R-click") Beep(300,30) EndIf EndFunc Func _Example_TrayMenu() ; example from AutoIt Help on TrayCreateMenu Local $iSettings = TrayCreateMenu("Settings") Local $iDisplay = TrayCreateItem("Display", $iSettings) Local $iPrinter = TrayCreateItem("Printer", $iSettings) TrayCreateItem("") Local $idAbout = TrayCreateItem("About") TrayCreateItem("") Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) While 1 Switch TrayGetMsg() Case $idAbout MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _ "Version: " & @AutoItVersion & @CRLF & _ "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) Case $iDisplay, $iPrinter MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.") Case $idExit ExitLoop EndSwitch WEnd EndFunc
  4. Included is a working piece of code to enlarge the handy Move / Copy dialog windows in FastStone Image Viewer, and default to the Favorites tab I am usually using a main program with hotkeys. Therefore the While 1 ... WEnd loop. I only recently made the beginning of a TrayMenu, but I have not come across how to ideally incorporate this with the While 1 ... loop yet... If I only include _exampleTrayMenu() in the loop, that works. If I only include the FastStone test without _exampleTrayMenu(), that works. If I include both in the loop, like in the example, the FastStone code doesn't enlarge the window and the TrayMenu often jumps into Pause / flashing. 1) Where to put _exampleTrayMenu() code so all combines...? 2) How to most efficiently combine multiple window detection cases in the future? 3) ...or can you run more than one AutoIt .exe and would you advise that? For me too, it would be clearer if I had all window detection code and small stuff in a 2nd .exe. #include <MsgBoxConstants.au3> #include <TrayConstants.au3> Opt("WinTitleMatchMode", 2) ; MAIN program loop While 1 If WinActive("[CLASS:TCopyMoveFolder]") Then _FastStoneImgViewer() Else _exampleTrayMenu() Sleep(100) EndIf WEnd ; Detect opening of both Copy & Move windows in Faststone viewer, enlarge them and click 'Favorites' tab Func _FastStoneImgViewer()     ; if WinActive(" to Folder") (when Copy or Move window appears)     If WinActive( "[CLASS:TCopyMoveFolder]" ) Then         Local $hWnd = WinGetHandle("[CLASS:TCopyMoveFolder]")         ; click once on tab 'Favorites'         ControlClick( $hWnd, "", "[CLASS:TbsSkinPageControl; INSTANCE:1]", "left", 1, 70, 10 )         ; enlarge window         WinMove($hWnd, "", Default, 60, 900, 1060)         ; move buttons down         ; BUTTON Clear History List         ControlMove($hWnd, "", "[CLASS:TbsSkinButton; INSTANCE:1]", Default, 990)         ; BUTTON         ControlMove($hWnd, "", "[CLASS:TbsSkinButton; INSTANCE:2]", Default, 990)         ; BUTTON         ControlMove($hWnd, "", "[CLASS:TbsSkinButton; INSTANCE:3]", Default, 990)         ; BUTTON         ControlMove($hWnd, "", "[CLASS:TbsSkinButton; INSTANCE:4]", Default, 990)         ; ENLARGE the Inside Window         ControlMove($hWnd, "", "[CLASS:TbsSkinPageControl; INSTANCE:1]", Default, Default, 862, 910)         ; ensure focus is back to inside window and previously selected item (so 'select by keypress' will work)         ControlFocus( $hWnd, "", "[CLASS:TListView; INSTANCE:1]" )         WinWaitNotActive($hWnd)     EndIf EndFunc ; traymenu example from manual Func _exampleTrayMenu() Local $iSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items. Local $iDisplay = TrayCreateItem("Display", $iSettings) Local $iPrinter = TrayCreateItem("Printer", $iSettings) TrayCreateItem("") ; Create a separator line. Local $idAbout = TrayCreateItem("About") TrayCreateItem("") ; Create a separator line. Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. While 1 Switch TrayGetMsg() Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable. MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _ "Version: " & @AutoItVersion & @CRLF & _ "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path. Case $iDisplay, $iPrinter MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.") Case $idExit ; Exit the loop. ExitLoop EndSwitch WEnd EndFunc
  5. Hello all, 2 quest: 1. Is it possible for TrayMenu, to align the menus right to left (hebrew) ? 2. I am using #include <TrayConstants.au3> to control the BGcolor can I choose to use different colors for different menus on the same TrayMenu I have tried different name for every set of TrayCreateMenu And assigning different bgcolor for every menu (under the same TrayMenu) but didn't get the result TNX Eyal
  6. 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
×
×
  • Create New...