Ok found a solution in case any one has similar needs. This script will double click on the PdaNet tray icon which initiates it to connect.
Code:
#Include <GuiToolBar.au3>
Global $hSysTray_Handle, $iSystray_ButtonNumber
Global $sToolTipTitle = "PdaNet" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here
$iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)
If $iSystray_ButtonNumber = 0 Then
MsgBox(16, "Error", "Icon not found in system tray")
Exit
Else
Sleep(500)
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "left")
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "left")
EndIf
Exit
;............
Func Get_Systray_Index($sToolTipTitle)
; Find systray handle
$hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
If @error Then
MsgBox(16, "Error", "System tray not found")
Exit
EndIf
; Get systray item count
Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
If $iSystray_ButCount = 0 Then
MsgBox(16, "Error", "No items found in system tray")
Exit
EndIf
; Look for wanted tooltip
For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1
If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop
Next
If $iSystray_ButtonNumber = $iSystray_ButCount Then
Return 0 ; Not found
Else
Return $iSystray_ButtonNumber ; Found
EndIf
EndFunc
I got most of the code from the Autoit forums and made 2 small changes. It can also be used for other programs. For example I'm using it for My Mobiler also. Now I can just map these to a centrafuse button.
Bookmarks