Jump to content
MONaH-Rasta

Radio menuitems not checked automatically by click

Recommended Posts

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?

Share this post


Link to post
Share on other sites

@MONaH-Rasta
That's because those "clicks" need to be handled in a different way.
TrayGetMsg() will handle both the messages sent from the various Tray items, and add a sleep to the While loop, so you don't need to worry about CPU overload.

Look at the example below:

#include <TrayConstants.au3>

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
    Switch TrayGetMsg()
        Case $iTray2
            _CheckUncheckTrayItem($iTray2)
        Case $iTray3
            _CheckUncheckTrayItem($iTray3)
        Case $iTray5
            _CheckUncheckTrayItem($iTray5)
        Case $iTray6
            _CheckUncheckTrayItem($iTray6)
        Case $iTray7
            _CheckUncheckTrayItem($iTray7)
    EndSwitch
WEnd

Func _CheckUncheckTrayItem($idControl)
    Return TrayItemGetState($idControl) = BitOR($TRAY_ENABLE, $TRAY_CHECKED) ? TrayItemSetState($idControl, $TRAY_UNCHECKED) : TrayItemSetState($idControl, $TRAY_CHECKED)
EndFunc

:)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Posted (edited)

@FrancescoDiMuro, please, understand, I'm not trying to handle nothing in my script. My point was that radiobuttons didn't change their state automaticly.

Here is an example with radiobuttons working as they should:

Opt('TrayAutoPause', 0)

$iTray1 = TrayCreateItem('Tray 1', -1, -1, 1)
TrayItemSetState(-1, 1)
$iTray2 = TrayCreateItem('Tray 2', -1, -1, 1)
$iTray3 = TrayCreateItem('Tray 3', -1, -1, 1)
TrayCreateItem('')
$iTray8 = TrayCreateItem('Tray 8')
$iTray9 = TrayCreateItem('Tray 9')
$iTray10 = TrayCreateItem('Tray 10')
TrayItemSetState(-1, 1)

While True
    Sleep(1000*5)
WEnd

If I klick on Tray 2 / Tray 3 it will become checked and other 2 will become unchecked, just as expected.

The problem comes when using radiobuttons in menu.

 

Edited by MONaH-Rasta

Share this post


Link to post
Share on other sites
1 minute ago, MONaH-Rasta said:

The problem comes when using radiobuttons in menu.

That's because they need to be handled in that manner.
In your example, you are not showing the behaviour of a Menu item; instead, you are showing the behaviour of a tray item, which is not the problem you are trying to solve :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Posted (edited)

Oh, so you are telling me that behavior of menuradioitems are different when they are in tray menu :blink:

Isn't that's strange?

Edited by MONaH-Rasta

Share this post


Link to post
Share on other sites
Posted (edited)

@MONaH-Rasta
Referring about what it is stated in the Help file, seems that those kind of messages need to be handled in that way :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Posted (edited)
Opt('TrayAutoPause', 0)

$iTrayMenu1 = TrayCreateMenu('Tray Menu 1')
$iTray1 = TrayCreateItem('Tray 1', $iTrayMenu1, -1, 1)
TrayItemSetState(-1, 1)
$iTray2 = TrayCreateItem('Tray 2', $iTrayMenu1, -1, 1)
$iTray3 = TrayCreateItem('Tray 3', $iTrayMenu1, -1, 1)
$iTray4 = TrayCreateItem('Tray 4', $iTrayMenu1, -1, 1)
TrayCreateItem('', $iTrayMenu1)
$iTray5 = TrayCreateItem('Tray 5', $iTrayMenu1, -1, 1)
$iTray6 = TrayCreateItem('Tray 6', $iTrayMenu1, -1, 1)
$iTray7 = TrayCreateItem('Tray 7', $iTrayMenu1, -1, 1)

While True
    Sleep(1000*5)
WEnd

Tray 1 - Tray 4 works like expected, Tray 5-7 not. Can you explain why?

Opt('TrayAutoPause', 0)

$iTrayMenu1 = TrayCreateMenu('Tray Menu 1')
$iTray1 = TrayCreateItem('Tray 1', $iTrayMenu1, -1, 1)
TrayItemSetState(-1, 1)
$iTray2 = TrayCreateItem('Tray 2', $iTrayMenu1, -1, 1)
$iTray3 = TrayCreateItem('Tray 3', $iTrayMenu1, -1, 1)
$iTray4 = TrayCreateItem('Tray 4', $iTrayMenu1, -1, 1)
TrayCreateItem('', $iTrayMenu1)
$iTray5 = TrayCreateItem('Tray 5', $iTrayMenu1, -1, 1)
$iTray6 = TrayCreateItem('Tray 6', $iTrayMenu1, -1, 1)
$iTray7 = TrayCreateItem('Tray 7', $iTrayMenu1, -1, 1)
TrayCreateItem('', $iTrayMenu1)
$iTray8 = TrayCreateItem('Tray 8', $iTrayMenu1, -1, 1)
$iTray9 = TrayCreateItem('Tray 9', $iTrayMenu1, -1, 1)
$iTray10 = TrayCreateItem('Tray 10', $iTrayMenu1, -1, 1)
TrayCreateItem('', $iTrayMenu1)
TrayCreateItem('Dumb', $iTrayMenu1)

While True
    Sleep(1000*5)
WEnd

Tray 1 - Tray 7 works like expected, Tray 8-10 not. Can you explain why?

Edited by MONaH-Rasta

Share this post


Link to post
Share on other sites

@MONaH-Rasta
This line of code

TrayCreateItem('', $iTrayMenu1)

breaks the group made by TrayItem1 to 4, and since it's a radio button, they are controls apart.
You need to use the TrayGetMsg() function in order to get messages from the other tray items :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Posted (edited)

@FrancescoDiMuro, I don't need to get messages. My script is something like this:

While True
    If TrayItemGetState($iTray2) = 65 Then
        Scenario 1
    Elseif TrayItemGetState($iTray3) = 65 Then
        Scenario 2
    Else
        Scenario 3
    EndIf
    Sleep(1000*60*5)
WEnd

Why Tray 8-10 not working? There is exactly same line of code there, I even added a checkbox in the end, but still they are not working like expected.

After some tests I can say that to get those radio menuitems work propertly in menu there should be 1 additional empty item (line) + 2 additional radio menuitems

TrayCreateItem('', $iTrayMenu1)
$iTrayDumb1 = TrayCreateItem('Dumb 1', $iTrayMenu1, -1, 1)
$iTrayDumb2 = TrayCreateItem('Dumb 2', $iTrayMenu1, -1, 1)

I just want to understand why it's so.

According to help file 

Quote

Radio menuitems are automatically grouped together and these groups are separated by a separator line or a normal item which is not a radio item.
By default, a clicked radio menuitem will be checked automatically and all other radio items in the same group will be unchecked!
To turn off this behaviour use Opt("TrayMenuMode", 8).

There is nothing about "but not when it in tray menu"

Edited by MONaH-Rasta

Share this post


Link to post
Share on other sites

MONaH-Rasta,

That was a fun bit of debugging! The problem seems to be using the default menu along with items with the $TRAY_ITEM_RADIO style. If you get rid of the default menu everything seems to work normally:

#include <TrayConstants.au3>

Opt("TrayMenuMode", 1) ; No default menu

$iTray1 = TrayCreateItem('Tray 1')
TrayItemSetState(-1, $TRAY_CHECKED)

$iTrayMenu1 = TrayCreateMenu('Tray Menu 1')
$iTray2 = TrayCreateItem('Tray 2', $iTrayMenu1, -1, $TRAY_ITEM_RADIO)
TrayItemSetState(-1, $TRAY_CHECKED)
$iTray3 = TrayCreateItem('Tray 3', $iTrayMenu1, -1, $TRAY_ITEM_RADIO)
$iTray4 = TrayCreateItem('Tray 4', $iTrayMenu1, -1, $TRAY_ITEM_RADIO)
TrayCreateItem('', $iTrayMenu1) ; Needed to close radio group

$iTrayMenu2= TrayCreateMenu('Tray Menu 2')
$iTray5 = TrayCreateItem('Tray 5', $iTrayMenu2, -1, $TRAY_ITEM_RADIO)
TrayItemSetState(-1, $TRAY_CHECKED)
$iTray6 = TrayCreateItem('Tray 6', $iTrayMenu2, -1, $TRAY_ITEM_RADIO)
$iTray7 = TrayCreateItem('Tray 7', $iTrayMenu2, -1, $TRAY_ITEM_RADIO)
TrayCreateItem('', $iTrayMenu2) ; Needed to close radio group

$iTray8 = TrayCreateItem('Tray 8')
$iTray9 = TrayCreateItem('Tray 9')
$iTray10 = TrayCreateItem('Tray 10')
TrayItemSetState(-1, $TRAY_CHECKED)

TrayCreateItem('')

$mExit = TrayCreateItem("Exit") ; Needed because there is no default menu

While 1
    Switch TrayGetMsg()
        Case $mExit
            Exit
    EndSwitch

WEnd

Which works fine for me - how about you?

M23

 


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Posted (edited)

Melba23, thanks for your suggestion. I like standart menu, so it's not an option for me. After some additional test I found that I need to place 4 empty trayitems to get everything work as expected, so my final code is like this:

Opt('TrayAutoPause', 0)

$iItem1 = TrayCreateItem('Item1')
TrayItemSetState(-1, 1)
TrayCreateItem('')

$iMenu1 = TrayCreateMenu('Menu 1')
$iItem2 = TrayCreateItem('Item 2', $iMenu1, -1, 1)
TrayItemSetState(-1, 1)
$iItem3 = TrayCreateItem('Item 3', $iMenu1, -1, 1)
$iItem4 = TrayCreateItem('Item 4', $iMenu1, -1, 1)
TrayCreateItem('', $iMenu1)
$iItem5 = TrayCreateItem('Item 5', $iMenu1, -1, 1)
TrayItemSetState(-1, 1)
$iItem6 = TrayCreateItem('Item 6', $iMenu1, -1, 1)
$iItem7 = TrayCreateItem('Item 7', $iMenu1, -1, 1)
TrayCreateItem('', $iMenu1)
TrayCreateItem('', $iMenu1)
TrayCreateItem('', $iMenu1)
TrayCreateItem('', $iMenu1)
TrayCreateItem('')

$iMenu2 = TrayCreateMenu('Menu 2')
$iItem8 = TrayCreateItem('Item 8', $iMenu2, -1, 1)
TrayItemSetState(-1, 1)
$iItem9 = TrayCreateItem('Item 9', $iMenu2, -1, 1)
$iItem10 = TrayCreateItem('Item 10', $iMenu2, -1, 1)
TrayCreateItem('', $iMenu2)
$iItem11 = TrayCreateItem('Item 11', $iMenu2, -1, 1)
$iItem12 = TrayCreateItem('Item 12', $iMenu2, -1, 1)
TrayItemSetState(-1, 1)
$iItem13 = TrayCreateItem('Item 13', $iMenu2, -1, 1)
TrayCreateItem('', $iMenu2)
TrayCreateItem('', $iMenu2)
TrayCreateItem('', $iMenu2)
TrayCreateItem('', $iMenu2)
TrayCreateItem('')

$iMenu3 = TrayCreateMenu('Menu 3')
$iItem14 = TrayCreateItem('Item 14', $iMenu3, -1, 1)
TrayItemSetState(-1, 1)
$iItem15 = TrayCreateItem('Item 15', $iMenu3, -1, 1)
$iItem16 = TrayCreateItem('Item 16', $iMenu3, -1, 1)
TrayCreateItem('', $iMenu3)
$iItem17 = TrayCreateItem('Item 17', $iMenu3, -1, 1)
TrayItemSetState(-1, 1)
$iItem18 = TrayCreateItem('Item 18', $iMenu3, -1, 1)
$iItem19 = TrayCreateItem('Item 19', $iMenu3, -1, 1)
TrayCreateItem('', $iMenu3)
TrayCreateItem('', $iMenu3)
TrayCreateItem('', $iMenu3)
TrayCreateItem('', $iMenu3)
TrayCreateItem('')

$iShowIEWnd = TrayCreateItem('Show IE')
$iShowNotify = TrayCreateItem('Show notify')
$iLogActions = TrayCreateItem('Log actions')
TrayItemSetState(-1, 1)

While True
    Sleep(1000*5)
WEnd

 

Edited by MONaH-Rasta

Share this post


Link to post
Share on other sites

MONaH-Rasta,

Quote

I like standart menu

Why? All you get in the default tray menu  is an "Exit" item - which you can easily replicate in your code - and the "Pause/Restart Script" item - which is a right pain and usually the first thing to go in any of my scripts. But if you are happy with the rather odd visual effect that your multiple empty entries give then by all means use it.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@Melba23, ok, what do you use to pause script? It's quite usefull for me...

Something like this?

TrayCreateItem('')

$mPause = TrayCreateItem("Pause") ; Needed because there is no default menu

TrayCreateItem('')

$mExit = TrayCreateItem("Exit") ; Needed because there is no default menu

While True
    Switch TrayGetMsg()
        Case $mExit
            Exit
        Case $mPause
            While TrayItemGetState($mPause) = 65
                Sleep(1000)
            WEnd
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

MONaH-Rasta,

I rarely want to pause my scripts - they are usually designed to work full-time! But there are many ways to pause scripts programmatically - just search the forum and you will find many examples of how to do it.

As an aside, I quite often use TrayOnEvent mode for the tray menu, while retaining MessageLoop mode for the main idle loop. That way the tray items get actioned instantly and are not affected by any ongoing functions within the main script. Why is that important? The Interrupting a running function tutorial in the Wiki will explain.

 

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Posted (edited)

I'm using traymenu for 3 main purposes:

  1. Set script options (Like on/off logging, notifications, etc.)
  2. Pause the script
  3. Exit script.

So I don't need no TrayGetMsg() nor TrayOnEven't mode. I just never need my script to react immediately on tray item state changes. If this "bug" with behaviour of traymenu with standard menu on is "ok" for developers of autoit, then I will just use 4 empty items and that's it 😎

Edited by MONaH-Rasta

Share this post


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

  • Similar Content

    • By lonardd
      I need to open an INTEL Graphic Tool clicking on a Win7 Tray Icon. This icon is not shown on the Win7 Tray but it is shown once you click on a button that shows a little  arrow-up. This button opens up an extension of the tray and there is my INTEL Graphic Tool Icon. 
      The first ControlClick('[Class:Shell_TrayWnd]', '', 1502 ) at line 26 of my source code (Rotatedisplays.au3) works fine as it clicks on the up-arrow shown on the uparrowfirst Menu.jpg  picture and opens up an extension of the tray. Then I'm trying to click on the INTEL Graphic Tool Icon which is the first blue icon (up-left) of the tray extension but I failed all my attempts. Can somebody help me out?
      Thanks 
      Dave


      RotateDisplays.au3
    • By argumentum
      So I'm coding in win 10, ..every thing looks nice but then I think, what about XP, ...ugly, but I make it pretty again, no problem. Lets check in Win 7 and here is my conundrum.
      Win 10, DRM is on, XP is off ( well, non-existant ), so far so good. I decide to make it the "switch" to enable or disable the checkbox in the context menu.
      Win 7 ... I try to apply the same logic and:
      DRM on:

       
      DRM off:

       
      now, "Windows 7 Basic": DRM is off


      Question: how should I determine if to hide the check-mark or not?, Is there a way to know that this theme is ? or better yet, how can I know that the theme is classic ?
      Thanks
      PS: I know that the code is not here but I think that my trend of thought would make it irrelevant anyway.
       
    • 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 ur
      I need to read the status of OneDrive icon running in the taskbar and update the status in a log file.
      2nd part I can complete
      But the first part, how to read the status of tray menu icon.

      I need the text above from the tray icon.
      I looked into , but not that helpful.
       
       
×
×
  • Create New...