Jump to content

Recommended Posts

Hi there. I wrote a simple script that sends string that was passed as a parameter to the softphone dialer. The problem is the program is almost always will be minimized to tray and script stops until it is restored. I tried using WinSetState but was unsuccessful. Any help is appreciated, the snippet is below:

Local Const $title = "Phone"
Local Const $soft = @ProgramFilesDir & "\Phone\Phone.exe"
Local $number = $CmdLine[1]

$number = StringReplace($number, "/", "") ;strip unneded characters
$number = StringReplace($number, "dial:", "")

If WinExists($title) == 0 Then
Run($soft, "", @SW_MAXIMIZE)
WinWait($title)
EndIf

;I tried using fance method, but decided to at least raise it somehow

;Local $state = WinGetState($title, "")
;If BitAND($state, 16) Then ;if it is
; WinSetState($title, "", @SW_MAXIMIZE)
;EndIf

WinSetState($title, "", @SW_MAXIMIZE) ;doesn't do the trick, and neither do RESTORE or SHOW

ControlSend($title, "", "Edit1", $number)
WinActivate($title)
ControlSend($title, "", "Edit1", "{ENTER}")
Link to post
Share on other sites
  • Moderators

NickFrost,

Welcome to the AutoIt forum. ;)

I have used this code to rightclick on tray items to get to their menu - I have found that Send("{UP}/{DOWN}{ENTER}") works well from then on if you add a Sleep(100) between multiple commands to allow them time to have effect: :)

#Include <GuiToolBar.au3>

Global $hSysTray_Handle, $iSysTray_ButtonNumber

Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< 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, "right")
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) <> 0 Then ExitLoop
    Next

    If $iSysTray_ButtonNumber = $iSysTray_ButCount Then
        Return 0 ; Not found
    Else
        Return $iSysTray_ButtonNumber ; Found
    EndIf

EndFunc

I hope that helps - ask again if not. :)

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

 

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.

×
×
  • Create New...