Jump to content

Dropdown menu


Recommended Posts

Hi guys :)
 
Not sure if my request here is too complicated, but here goes:
 
I have created a script for the company, with big success. What it does, is to forward our duty calls to a specific cellphone number, via Lync.
 
Below is the script.

Don't get confused about all the send commands. Those are just the process to make lync turn on the forward.

There are 4 buttons.

1. Lync 2010 - Transfer call (Opens a dialog box, where you can specify a telephone number, which later refers to the Send($sInput) command.

2. Lync 2010 - Turn off forward of calls (Nevermind this button)

3. Lync 2013 - Transfer call (Opens a dialog box, where you can specify a telephone number, which later refers to the Send($sInput) command.

4. Lync 2013 - Turn off forward of calls (Nevermind this button)

Ok so what would be even more nice than a dialog box to enter phone number in (button 1 and 3)? --> A Dialogbox with names to chose from! Then maybe I could add all the names of the employers in some sort of list, and define what their cellphone numbers are.

So instead of now where people manually type in a phone number in a dialog box, they could chose a name from the dropdown menu, and the script would know what number to use af the Send($sInput) line!

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg
    GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
             Case $msg = $Button_1
                
                
;_______________________Stille vagten over - Lync 2010 UNDER HER_______________________;

If WinExists("Microsoft Lync") Then
   

While 1
    $sInput = InputBox("David Linder script®", "Indtast mobilnummeret du vil stille over til:", "", "", 250, 125)
     If @error <> 0 Then Exit
     If StringStripWS($sInput, 3) <> "" Then
        
     
;Nedenstående slår vagten fra, så den er klar til at blive viderestillet til et mobilnr.

BlockInput(1) ;blocker mus/tastatur

WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen

;Nedenstående slår vagten over til det indtastede mobilnr.

BlockInput(1) ;blocker mus/tastatur

Sleep(1000)
WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{*}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("808")
Sleep(1000)
Send($sInput) ;phone number
Sleep(1000)
Send("{#}")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen


        Exit
    EndIf
WEnd


Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
      
      Endif
;_______________________Stille vagten over - Lync 2010 OVER HER_______________________;
                
             Case $msg = $Button_2
                
;_______________________Slå vagten fra - Lync 2010 UNDER HER_______________________;

If WinExists("Microsoft Lync") Then

BlockInput(1) ;blocker mus/tastatur

WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen
Exit

   Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
      
      Endif
                
;_______________________Slå vagten fra - Lync 2010 OVER HER_______________________;

Case $msg = $Button_3
                
;_______________________Stille vagten over - Lync 2013 UNDER HER_______________________;

If WinExists("Lync") Then



While 1
    $sInput = InputBox("David Linder script®", "Indtast mobilnummeret du vil stille over til:", "", "", 250, 125)
     If @error <> 0 Then Exit
     If StringStripWS($sInput, 3) <> "" Then
        
     
;Nedenstående slår vagten fra, så den er klar til at blive viderestillet til et mobilnr.

BlockInput(1) ;blocker mus/tastatur

WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen


;Nedenstående slår vagten over til det indtastede mobilnr.

BlockInput(1) ;blocker mus/tastatur

Sleep(1000)
WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{*}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("808")
Sleep(1000)
Send($sInput) ;phone number
Sleep(1000)
Send("{#}")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen

        Exit
    EndIf
WEnd


Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
      
      Endif
;_______________________Stille vagten over - Lync 2013 OVER HER_______________________;

Case $msg = $Button_4
                
;_______________________Slå vagten fra Lync 2013 UNDER HER_______________________;

If WinExists("Lync") Then

BlockInput(1) ;blocker mus/tastatur

WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen
Exit


Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
      
      Endif
                
;_______________________Slå vagten fra Lync 2013 OVER HER_______________________;



        EndSelect
    WEnd
    
EndFunc   ;==>Example
Link to comment
Share on other sites

  • Moderators

david1337,

Please do not bump your own threads within 24 hours. :naughty:

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. ;)

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 comment
Share on other sites

  • Moderators

david1337,

This should give you a good idea of how you might do what you want: ;)

#include <GUIConstantsEx.au3>
#include <Array.au3>

; Array to hold data of employer and phone number
Global $aData[5][2] = [["Employer 1", "111-111-1111"], _
                       ["Employer 2", "222-222-2222"], _
                       ["Employer 3", "333-333-3333"], _
                       ["Employer 4", "444-444-4444"], _
                       ["Cancel", ""]]

; Extract emplyer names
$sComboData = ""
For $i = 0 To UBound($aData) - 1
    $sComboData &= "|" & $aData[$i][0]
Next

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg
    GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Button_1
                ;If WinExists("Microsoft Lync") Then
                    ; Hide button
                    GUICtrlSetState($Button_1, $GUI_HIDE)
                    ; Create combo
                    $cCombo = GUICtrlCreateCombo("", 23, 30, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 2)
                                ; If found
                                If $iIndex <> -1 Then
                                    ; Use the related number
                                    MsgBox(0, "Selection", "Number to use: " & $aData[$iIndex][1])
                                EndIf
                                ; Delete the combo and reshow the button
                                GUICtrlDelete($cCombo)
                                GUICtrlSetState($Button_1, $GUI_SHOW)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                ;Else
                    ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
                ;EndIf

            Case $Button_2

            Case $Button_3
                ;If WinExists("Lync") Then
                    While 1
                        $sInput = InputBox("David Linder script®", "Indtast mobilnummeret du vil stille over til:", "", "", 250, 125)
                        If @error <> 0 Then Exit
                        If StringStripWS($sInput, 3) <> "" Then
                        EndIf
                    WEnd
                ;Else
                    ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
                ;EndIf

            Case $Button_4

        EndSwitch
    WEnd
EndFunc   ;==>Example
Please ask if you have any questions. :)

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 comment
Share on other sites

  • Moderators

david1337,

Perhaps this will help: ;)

#include <GUIConstantsEx.au3>
#include <Array.au3>

; Array to hold data of employer and phone number
Global $aData[5][2] = [["Employer 1", "111-111-1111"], _
                       ["Employer 2", "222-222-2222"], _
                       ["Employer 3", "333-333-3333"], _
                       ["Employer 4", "444-444-4444"], _
                       ["Cancel", ""]]

; Extract emplyer names
$sComboData = ""
For $i = 0 To UBound($aData) - 1
    $sComboData &= "|" & $aData[$i][0]
Next

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg, $hGUI_Child
    Local $hGUI = GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Button_1
                ;If WinExists("Microsoft Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Select Employer", 200, 40, -1, -1, Default, Default, $hGUI)
                    GUISetBkColor(0xFF0000)
                    $cCombo = GUICtrlCreateCombo("", 25, 10, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)
                    GUISetState(@SW_SHOW, $hGUI_Child)
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 2)
                                ; If found
                                If $iIndex <> -1 Then
                                    ; Use the related number
                                    MsgBox(0, "Selection", "Number to use: " & $aData[$iIndex][1])
                                EndIf
                                ; Delete the combo and reshow the button
                                GUICtrlDelete($cCombo)
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                ;Else
                    ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
                ;EndIf

            Case $Button_2

            Case $Button_3
                ;If WinExists("Lync") Then
                    While 1
                        $sInput = InputBox("David Linder script®", "Indtast mobilnummeret du vil stille over til:", "", "", 250, 125)
                        If @error <> 0 Then Exit
                        If StringStripWS($sInput, 3) <> "" Then
                        EndIf
                    WEnd
                ;Else
                    ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
                ;EndIf

            Case $Button_4

        EndSwitch
    WEnd
EndFunc   ;==>Example
As before, please ask if you have any questions. :)

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 comment
Share on other sites

Melba,

That is so cool! I managed to make it work with the help from you!

Thank you SO MUCH!!!

2 small things:

- How can I enter an "OK" button, så that after choosing an employee, you have to click OK before the script executes?

- Is it possible to change the color of the buttons ?

See my currents scripts below:

Thanks!!!

#include <GUIConstantsEx.au3>
#include <Array.au3>

; Array to hold data of employer and phone number
Global $aData[8][2] = [["Anders Lausen", "12 34 56 78"], _
                       ["Anders Smith", "12 34 56 78"], _                      
                       ["Anel Habibovic", "12 34 56 78"], _
                       ["Bo Orluff", "212 34 56 78"], _
                       ["Daniel Gerner Knudsen", "12 34 56 78"], _
                       ["Danny Camargo", "12 34 56 78"], _
                       ["David Linder", "12 34 56 78"], _
                       ["Cancel", ""]]

; Extract emplyer names
$sComboData = ""
For $i = 0 To UBound($aData) - 1
    $sComboData &= "|" & $aData[$i][0]
Next

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg, $hGUI_Child
    Local $hGUI = GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered
     GUISetBkColor(0xF87217)

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
                    ;__________________________________________________________________________________;
                
                
             Case $Button_1
                
                ;_______________________Stille vagten over - Lync 2010 UNDER HER_______________________;
                
                If WinExists("Microsoft Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Vælg medarbejder", 230, 40, -1, -1, Default, Default, $hGUI)
                    GUISetBkColor(0x000000)
                    $cCombo = GUICtrlCreateCombo("", 25, 10, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)
                    GUISetState(@SW_SHOW, $hGUI_Child)
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 2)
                                ; If found
                                If $iIndex <> -1 Then
                                   
                                    ; Use the related number
                                    
                                    
;Nedenstående slår vagten fra, så den er klar til at blive viderestillet til et mobilnr.

BlockInput(1) ;blocker mus/tastatur

WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen

;Nedenstående slår vagten over til det indtastede mobilnr.

BlockInput(1) ;blocker mus/tastatur

Sleep(1000)
WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{*}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("808")
Sleep(1000)
Send($sInput) ;phone number
Sleep(1000)
Send("{#}")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen
                                    
                                    
                                    MsgBox(0, "Selection", "Number to use: " & $aData[$iIndex][1])
                                EndIf
                                ; Delete the combo and reshow the button
                                GUICtrlDelete($cCombo)
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                Else
                    MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
                EndIf
                
;_______________________Stille vagten over - Lync 2010 OVER HER_______________________;

            Case $Button_2

;_______________________Slå vagten fra - Lync 2010 UNDER HER_______________________;

If WinExists("Microsoft Lync") Then

BlockInput(1) ;blocker mus/tastatur

WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen
Exit

   Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
      
      Endif
                
;_______________________Slå vagten fra - Lync 2010 OVER HER_______________________;


            Case $Button_3
               
;_______________________Stille vagten over - Lync 2013 UNDER HER__________________;


   If WinExists("Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Vælg medarbejder", 230, 40, -1, -1, Default, Default, $hGUI)
                    GUISetBkColor(0x000000)
                    $cCombo = GUICtrlCreateCombo("", 25, 10, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)
                    GUISetState(@SW_SHOW, $hGUI_Child)
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 2)
                                ; If found
                                If $iIndex <> -1 Then
                                   
                                    ; Use the related number


;Nedenstående slår vagten fra, så den er klar til at blive viderestillet til et mobilnr.

BlockInput(1) ;blocker mus/tastatur

WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen


;Nedenstående slår vagten over til det indtastede mobilnr.

BlockInput(1) ;blocker mus/tastatur

Sleep(1000)
WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{*}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("808")
Sleep(1000)
Send($aData[$iIndex][1]) ;Vælger person fra listen's tlf.nr.
Sleep(1000)
Send("{#}")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen

   EndIf
                                ; Delete the combo and reshow the button
                                GUICtrlDelete($cCombo)
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                    
                    
                    
                Else
                    MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
                EndIf
                

;_______________________Stille vagten over - Lync 2013 OVER HER_______________________;


            Case $Button_4


;_______________________Slå vagten fra Lync 2013 UNDER HER_______________________;


If WinExists("Lync") Then

BlockInput(1) ;blocker mus/tastatur

WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen
Exit


Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
      
      Endif

;_______________________Slå vagten fra Lync 2013 OVER HER_______________________;


        EndSwitch
    WEnd
EndFunc   ;==>Example
Edited by david1337
Link to comment
Share on other sites

  • Moderators

david1337,

 

How can I enter an "OK" button

Something like this should be what you want: ;)

#include <GUIConstantsEx.au3>
#include <Array.au3>

; Array to hold data of employer and phone number
Global $aData[5][2] = [["Employer 1", "111-111-1111"], _
                       ["Employer 2", "222-222-2222"], _
                       ["Employer 3", "333-333-3333"], _
                       ["Employer 4", "444-444-4444"], _
                       ["Cancel", ""]]

; Extract employer names
$sComboData = ""
For $i = 0 To UBound($aData) - 1
    $sComboData &= "|" & $aData[$i][0]
Next

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg, $hGUI_Child
    Local $hGUI = GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Button_1
                ;If WinExists("Microsoft Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Select Employer", 200, 80, -1, -1, Default, Default, $hGUI)
                    GUISetBkColor(0xFF0000)
                    $cCombo = GUICtrlCreateCombo("", 25, 10, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)
                    ; Create a disabled button
                    $cAction = GUICtrlCreateButton("Action", 60, 40, 80, 30)
                    GUICtrlSetState($cAction, $GUI_DISABLE)
                    GUISetState(@SW_SHOW, $hGUI_Child)
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; See if cancel selected
                                If GUICtrlRead($cCombo) = "Cancel" Then
                                    ; Delete the combo and GUI
                                    GUICtrlDelete($cCombo)
                                    GUIDelete($hGUI_Child)
                                    ; Return to main loop
                                    ExitLoop
                                Else
                                    ;Enable button
                                    GUICtrlSetState($cAction, $GUI_ENABLE)
                                EndIf
                            Case $cAction
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 1)
                                ; If found
                                If $iIndex <> -1 Then
                                    ; Use the related number
                                    MsgBox(0, "Selection", "Number to use: " & $aData[$iIndex][1])
                                EndIf
                                ; Delete the GUI
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                ;Else
                    ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
                ;EndIf

            Case $Button_2

            Case $Button_3
                ;If WinExists("Lync") Then
                    While 1
                        $sInput = InputBox("David Linder script®", "Indtast mobilnummeret du vil stille over til:", "", "", 250, 125)
                        If @error <> 0 Then Exit
                        If StringStripWS($sInput, 3) <> "" Then
                        EndIf
                    WEnd
                ;Else
                    ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
                ;EndIf

            Case $Button_4

        EndSwitch
    WEnd
EndFunc   ;==>Example

Is it possible to change the color of the buttons

Yes, using GUICtrlSetColor - but there is a bug deep in the AutoIt core code which means that all sorts of unwanted things (trapping the ENTER key, inability to use button styles, etc) can occur so I strongly recommend that you do not do 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

 

Link to comment
Share on other sites

You're the man Melba! :D

Worked just as expected!

I had a great idea. To implement my old inputbox into the same window as the dropdown menu. So that people could choose an employee from the drop down list, OR type in the phone number manually like in the old script, which then pointed to the Send($sInput)

After they either choose a name in the dropdown menu, or type in the number manually, they can click the "OK" button to execute their choice.

Now it got way to complicated for me :(

This is what my script looks like now:

#include <GUIConstantsEx.au3>
#include <Array.au3>

; Array to hold data of employer and phone number
Global $aData[8][2] = [["", "12 34 56 78"], _
                       ["", "12 34 56 78"], _                      
                       ["", "12 34 56 78"], _
                       ["", "12 34 56 78"], _
                       ["", "12 34 56 78"], _
                       ["", "12 34 56 78"], _
                       ["", "12 34 56 78"], _
                       ["Cancel", ""]]

; Extract emplyer names
$sComboData = ""
For $i = 0 To UBound($aData) - 1
    $sComboData &= "|" & $aData[$i][0]
Next

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg, $hGUI_Child
    Local $hGUI = GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered
     GUISetBkColor(0xF87217)

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
                    ;__________________________________________________________________________________;
                
                
             Case $Button_1
                
                ;_______________________Stille vagten over - Lync 2010 UNDER HER_______________________;
                
                If WinExists("Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Vælg medarbejder", 230, 80, -1, -1, Default, Default, $hGUI)                        
                    GUISetBkColor(0x000000)
                    $cCombo = GUICtrlCreateCombo("", 40, 10, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)                    
                    ; Create a disabled button
                    $cAction = GUICtrlCreateButton("OK", 74, 40, 80, 30)
                    GUICtrlSetState($cAction, $GUI_DISABLE)
                    GUISetState(@SW_SHOW, $hGUI_Child)                  
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; See if cancel selected
                                If GUICtrlRead($cCombo) = "Cancel" Then
                                    ; Delete the combo and GUI
                                    GUICtrlDelete($cCombo)
                                    GUIDelete($hGUI_Child)
                                    ; Return to main loop
                                    ExitLoop
                                Else
                                    ;Enable button
                                    GUICtrlSetState($cAction, $GUI_ENABLE)                              
                                EndIf
                            Case $cAction
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 1)
                                ; If found
                                 If $iIndex <> -1 Then                                  
                                   
                                    ; Use the related number
                                    
                                    
;Nedenstående slår vagten fra, så den er klar til at blive viderestillet til et mobilnr.

BlockInput(1) ;blocker mus/tastatur

WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen

;Nedenstående slår vagten over til det indtastede mobilnr.

BlockInput(1) ;blocker mus/tastatur

Sleep(1000)
WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{*}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("808")
Sleep(1000)
Send($sInput) ;phone number
Sleep(1000)
Send("{#}")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen
                                    
                                    
                                    MsgBox(0, "Selection", "Number to use: " & $aData[$iIndex][1])
                                EndIf
                                ; Delete the combo and reshow the button
                                GUICtrlDelete($cCombo)
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                Else
                    MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
                EndIf
                
;_______________________Stille vagten over - Lync 2010 OVER HER_______________________;

            Case $Button_2

;_______________________Slå vagten fra - Lync 2010 UNDER HER_______________________;

If WinExists("Microsoft Lync") Then

BlockInput(1) ;blocker mus/tastatur

WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen
Exit

   Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
      
      Endif
                
;_______________________Slå vagten fra - Lync 2010 OVER HER_______________________;


            Case $Button_3
               
;_______________________Stille vagten over - Lync 2013 UNDER HER__________________;


                     If WinExists("Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Vælg medarbejder", 230, 80, -1, -1, Default, Default, $hGUI)
                    GUISetBkColor(0x000000)
                    $cCombo = GUICtrlCreateCombo("", 40, 10, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)
                    ; Create a disabled button
                    $cAction = GUICtrlCreateButton("OK", 74, 40, 80, 30)
                    GUICtrlSetState($cAction, $GUI_DISABLE)
                    GUISetState(@SW_SHOW, $hGUI_Child)
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; See if cancel selected
                                If GUICtrlRead($cCombo) = "Cancel" Then
                                    ; Delete the combo and GUI
                                    GUICtrlDelete($cCombo)
                                    GUIDelete($hGUI_Child)
                                    ; Return to main loop
                                    ExitLoop
                                Else
                                    ;Enable button
                                    GUICtrlSetState($cAction, $GUI_ENABLE)
                                EndIf
                            Case $cAction
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 1)
                                ; If found
                                 If $iIndex <> -1 Then
                                   
                                    ; Use the related number


;Nedenstående slår vagten fra, så den er klar til at blive viderestillet til et mobilnr.

BlockInput(1) ;blocker mus/tastatur

WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen


;Nedenstående slår vagten over til det indtastede mobilnr.

BlockInput(1) ;blocker mus/tastatur

Sleep(1000)
WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{*}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("808")
Sleep(1000)
Send($aData[$iIndex][1]) ;Vælger person fra listen's tlf.nr.
Sleep(1000)
Send("{#}")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen

   EndIf
                                ; Delete the combo and reshow the button
                                GUICtrlDelete($cCombo)
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                    
                    
                    
                Else
                    MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
                EndIf
                

;_______________________Stille vagten over - Lync 2013 OVER HER_______________________;


            Case $Button_4


;_______________________Slå vagten fra Lync 2013 UNDER HER_______________________;


If WinExists("Lync") Then

BlockInput(1) ;blocker mus/tastatur

WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen
Exit


Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
      
      Endif

;_______________________Slå vagten fra Lync 2013 OVER HER_______________________;


        EndSwitch
    WEnd
EndFunc   ;==>Example
Edited by david1337
Link to comment
Share on other sites

  • Moderators

david1337,

 

I had a great idea

And you expect me to implement it! :whistle:

As I have a few moments spare I have coded this (there are a few little extras in there for you too): ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <GuiComboBox.au3>

Global $cCombo = 9999, $cInput = 9999, $cAction = 9999 ; Use place holders

; Array to hold data of employer and phone number
Global $aData[5][2] = [["Employer 1", "111-111-1111"], _
                       ["Employer 2", "222-222-2222"], _
                       ["Employer 3", "333-333-3333"], _
                       ["Employer 4", "444-444-4444"], _
                       ["Cancel", ""]]

; Extract employer names
$sComboData = ""
For $i = 0 To UBound($aData) - 1
    $sComboData &= "|" & $aData[$i][0]
Next

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg, $hGUI_Child
    Local $hGUI = GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Register the input change message
    GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Button_1
                ;If WinExists("Microsoft Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Select Employer", 200, 110, -1, -1, Default, Default, $hGUI)
                    GUISetBkColor(0xFF0000)
                    $cCombo = GUICtrlCreateCombo("", 25, 10, 150, 20)
                    _GUICtrlComboBox_SetCueBanner($cCombo, "Select an employer...")
                    GUICtrlSetData($cCombo, $sComboData)
                    $cInput = GUICtrlCreateInput("", 25, 40,150, 20)
                    GUICtrlSendMsg($cInput, $EM_SETCUEBANNER, True, "...or enter number")
                    GUICtrlSetState($cInput, $GUI_FOCUS)
                    ; Create a disabled button
                    $cAction = GUICtrlCreateButton("Action", 60, 70, 80, 30)
                    GUICtrlSetState($cAction, $GUI_DISABLE)
                    GUISetState(@SW_SHOW, $hGUI_Child)
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; See if cancel selected
                                If GUICtrlRead($cCombo) = "Cancel" Then
                                    ; Delete the combo and GUI
                                    GUICtrlDelete($cCombo)
                                    GUIDelete($hGUI_Child)
                                    ; Return to main loop
                                    ExitLoop
                                Else
                                    ;Enable button
                                    GUICtrlSetState($cAction, $GUI_ENABLE)
                                    ; Remove input cue banner and disable
                                    GUICtrlSendMsg($cInput, $EM_SETCUEBANNER, True, "")
                                    GUICtrlSetState($cInput, $GUI_DISABLE)
                                EndIf
                            Case $cAction
                                Local $sNumber = ""
                                ; Use input if filled
                                $sNumber = GUICtrlRead($cInput)
                                ; If not use combo
                                If Not $sNumber Then
                                    ; Look for the employer in the array - but ignore the "Cancel" element
                                    $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 1)
                                    ; If found
                                    If $iIndex <> -1 Then
                                        ; Use the related number
                                        $sNumber = $aData[$iIndex][1]
                                    EndIf
                                EndIf
                                MsgBox(0, "Selection", "Number to use: " & $sNumber)
                                ; Delete the GUI
                                GUIDelete($hGUI_Child)
                                ; Reset place holders
                                $cCombo = 9999
                                $cInput = 9999
                                $cAction = 9999
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                ;Else
                    ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
                ;EndIf

            Case $Button_2

            Case $Button_3
                ;If WinExists("Lync") Then
                    While 1
                        $sInput = InputBox("David Linder script®", "Indtast mobilnummeret du vil stille over til:", "", "", 250, 125)
                        If @error <> 0 Then Exit
                        If StringStripWS($sInput, 3) <> "" Then
                        EndIf
                    WEnd
                ;Else
                    ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
                ;EndIf

            Case $Button_4

        EndSwitch
    WEnd
EndFunc   ;==>Example

Func _WM_COMMAND($hWHnd, $iMsg, $wParam, $lParam)
    ; If the input has been altered
    If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $cInput Then
        ;Enable button
        GUICtrlSetState($cAction, $GUI_ENABLE)
        ; Clear combo cue banner
        _GUICtrlComboBox_SetCueBanner($cCombo, "")
    EndIf
EndFunc   ;==>WM_COMMAND
Please ask if you have any questions. :)

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 comment
Share on other sites

  • 3 months later...

Melba my friend! :)

Thank you so much.

I have been away from the forum quite a long time, and just saw that you had replied me long time ago!

That was brilliant. The search box is included in the dropdown box!

So why can't I make this work in my own script? :(

Button 1 and Button 3 must open the box with both the name drop down and the box for manual phone number.

How to I include it the way you did to Button 1 in your posted script? Drives me insane!

Thanks you so much!

#include <GUIConstantsEx.au3>
#include <Array.au3>

; Array to hold data of employer and phone number
Global $aData[5][2] = [["name1", "12 34 56 78"], _
                       ["name2", "12 34 56 78"], _                     
                       ["name3", "12 34 56 78"], _
                       ["name4", "12 34 56 78"], _
                       ["Cancel", ""]]

; Extract emplyer names
$sComboData = ""
For $i = 0 To UBound($aData) - 1
    $sComboData &= "|" & $aData[$i][0]
Next

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg, $hGUI_Child
    Local $hGUI = GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered
     GUISetBkColor(0xF87217)

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
                    ;__________________________________________________________________________________;
                
                
             Case $Button_1
                
                ;_______________________Stille vagten over - Lync 2010 UNDER HER_______________________;
                
                If WinExists("Microsoft Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Vælg medarbejder", 230, 80, -1, -1, Default, Default, $hGUI)                        
                    GUISetBkColor(0x000000)
                    $cCombo = GUICtrlCreateCombo("", 40, 10, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)                    
                    ; Create a disabled button
                    $cAction = GUICtrlCreateButton("OK", 74, 40, 80, 30)
                    GUICtrlSetState($cAction, $GUI_DISABLE)
                    GUISetState(@SW_SHOW, $hGUI_Child)                  
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; See if cancel selected
                                If GUICtrlRead($cCombo) = "Cancel" Then
                                    ; Delete the combo and GUI
                                    GUICtrlDelete($cCombo)
                                    GUIDelete($hGUI_Child)
                                    ; Return to main loop
                                    ExitLoop
                                Else
                                    ;Enable button
                                    GUICtrlSetState($cAction, $GUI_ENABLE)                              
                                EndIf
                            Case $cAction
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 1)
                                ; If found
                                 If $iIndex <> -1 Then                                  
                                   
                                    ; Use the related number
                                    
                                    
;Nedenstående slår vagten fra, så den er klar til at blive viderestillet til et mobilnr.

BlockInput(1) ;blocker mus/tastatur

WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen

;Nedenstående slår vagten over til det indtastede mobilnr.

BlockInput(1) ;blocker mus/tastatur

Sleep(1000)
WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{*}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("808")
Sleep(1000)
Send($sInput) ;phone number
Sleep(1000)
Send("{#}")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen
                                    
                                    
                                    MsgBox(0, "Selection", "Number to use: " & $aData[$iIndex][1])
                                EndIf
                                ; Delete the combo and reshow the button
                                GUICtrlDelete($cCombo)
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                Else
                    MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
                EndIf
                
;_______________________Stille vagten over - Lync 2010 OVER HER_______________________;

            Case $Button_2

;_______________________Slå vagten fra - Lync 2010 UNDER HER_______________________;

If WinExists("Microsoft Lync") Then

BlockInput(1) ;blocker mus/tastatur

WinActivate("Microsoft Lync")
WinWaitActive("Microsoft Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{ALTDOWN}")
Sleep(100)
Send("q")
Sleep(100)
Send("{ALTUP}")

BlockInput(0) ;fjerner block igen
Exit

   Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende")
      
      Endif
                
;_______________________Slå vagten fra - Lync 2010 OVER HER_______________________;


            Case $Button_3
               
;_______________________Stille vagten over - Lync 2013 UNDER HER__________________;


                     If WinExists("Lync") Then
                    ; Create dialog and show combo
                    Local $hGUI_Child = GUICreate("Vælg medarbejder", 230, 80, -1, -1, Default, Default, $hGUI)
                    GUISetBkColor(0x000000)
                    $cCombo = GUICtrlCreateCombo("", 40, 10, 150, 20)
                    GUICtrlSetData($cCombo, $sComboData)
                    ; Create a disabled button
                    $cAction = GUICtrlCreateButton("OK", 74, 40, 80, 30)
                    GUICtrlSetState($cAction, $GUI_DISABLE)
                    GUISetState(@SW_SHOW, $hGUI_Child)
                    ; Wait for a selection
                    While 1
                        Switch GUIGetMsg()
                            ; Close GUI if [X] clicked
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $cCombo
                                ; See if cancel selected
                                If GUICtrlRead($cCombo) = "Cancel" Then
                                    ; Delete the combo and GUI
                                    GUICtrlDelete($cCombo)
                                    GUIDelete($hGUI_Child)
                                    ; Return to main loop
                                    ExitLoop
                                Else
                                    ;Enable button
                                    GUICtrlSetState($cAction, $GUI_ENABLE)
                                EndIf
                            Case $cAction
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 1)
                                ; If found
                                 If $iIndex <> -1 Then
                                   
                                    ; Use the related number


;Nedenstående slår vagten fra, så den er klar til at blive viderestillet til et mobilnr.

BlockInput(1) ;blocker mus/tastatur

WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen


;Nedenstående slår vagten over til det indtastede mobilnr.

BlockInput(1) ;blocker mus/tastatur

Sleep(1000)
WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{*}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("808")
Sleep(1000)
Send($aData[$iIndex][1]) ;Vælger person fra listen's tlf.nr.
Sleep(1000)
Send("{#}")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen

   EndIf
                                ; Delete the combo and reshow the button
                                GUICtrlDelete($cCombo)
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                        EndSwitch
                    WEnd
                    
                    
                    
                Else
                    MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
                EndIf
                

;_______________________Stille vagten over - Lync 2013 OVER HER_______________________;


            Case $Button_4


;_______________________Slå vagten fra Lync 2013 UNDER HER_______________________;


If WinExists("Lync") Then

BlockInput(1) ;blocker mus/tastatur

WinActivate("Lync")
WinWaitActive("Lync")
Send("64215455")
Sleep(1000)
Send("{ENTER}")
Sleep(3000)
Send("5401")
Sleep(3000)
Send("{#}")
Send("511")
Sleep(500)
Send("91")
Sleep(500)
Send("480")
Sleep(4000)
Send("{ESC}")
Sleep(1000)
Send("{CTRLDOWN}")
Sleep(100)
Send("{ENTER}")
Sleep(100)
Send("{CTRLUP}")
Sleep(1000)
Send("{ENTER}")

BlockInput(0) ;fjerner block igen
Exit


Else
      
      MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende")
      
      Endif

;_______________________Slå vagten fra Lync 2013 OVER HER_______________________;


        EndSwitch
    WEnd
EndFunc   ;==>Example
Link to comment
Share on other sites

  • Moderators

david1337,

Glad it was helpful. :)

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 comment
Share on other sites

  • Moderators

david1337,

Sorry, I read the post too quickly! :D

I would run the same code for each button and then, once the number has been determined, split the code depending on which was pressed:

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <EditConstants.au3>

; Array to hold data of employer and phone number
Global $aData[5][2] = [["Employer 1", "111-111-1111"], _
        ["Employer 2", "222-222-2222"], _
        ["Employer 3", "333-333-3333"], _
        ["Employer 4", "444-444-4444"], _
        ["Cancel", ""]]

; Extract employer names
$sComboData = ""
For $i = 0 To UBound($aData) - 1
    $sComboData &= "|" & $aData[$i][0]
Next

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4, $msg, $hGUI_Child
    Local $hGUI = GUICreate("David Linder script", 380, 130) ; will create a dialog box that when displayed is centered
    GUISetBkColor(0xF87217)

    Opt("GUICoordMode", 4)
    $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150)
    $Button_2 = GUICtrlCreateButton("S vagten fra - Lync 2010", 203, 30, 150)
    $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150)
    $Button_4 = GUICtrlCreateButton("S gten fra Lync 2013", 203, 80, 150)

    GUISetState() ; will display a dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $iMsg = GUIGetMsg() ; Save ControlID <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
                ;__________________________________________________________________________________;


            Case $Button_1, $Button_3 ; Fire on both buttons <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

                ; And run the same code for both <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

                ;If WinExists("Microsoft Lync") Then
                ; Create dialog and show combo
                Local $hGUI_Child = GUICreate("Select Employer", 200, 110, -1, -1, Default, Default, $hGUI)
                GUISetBkColor(0xFF0000)
                $cCombo = GUICtrlCreateCombo("", 25, 10, 150, 20)
                _GUICtrlComboBox_SetCueBanner($cCombo, "Select an employer...")
                GUICtrlSetData($cCombo, $sComboData)
                $cInput = GUICtrlCreateInput("", 25, 40, 150, 20)
                GUICtrlSendMsg($cInput, $EM_SETCUEBANNER, True, "...or enter number")
                GUICtrlSetState($cInput, $GUI_FOCUS)
                ; Create a disabled button
                $cAction = GUICtrlCreateButton("Action", 60, 70, 80, 30)
                GUICtrlSetState($cAction, $GUI_DISABLE)
                GUISetState(@SW_SHOW, $hGUI_Child)
                ; Wait for a selection
                While 1
                    Switch GUIGetMsg()
                        ; Close GUI if [X] clicked
                        Case $GUI_EVENT_CLOSE
                            Exit
                        Case $cCombo
                            ; See if cancel selected
                            If GUICtrlRead($cCombo) = "Cancel" Then
                                ; Delete the combo and GUI
                                GUICtrlDelete($cCombo)
                                GUIDelete($hGUI_Child)
                                ; Return to main loop
                                ExitLoop
                            Else
                                ;Enable button
                                GUICtrlSetState($cAction, $GUI_ENABLE)
                                ; Remove input cue banner and disable
                                GUICtrlSendMsg($cInput, $EM_SETCUEBANNER, True, "")
                                GUICtrlSetState($cInput, $GUI_DISABLE)
                            EndIf
                        Case $cAction
                            Local $sNumber = ""
                            ; Use input if filled
                            $sNumber = GUICtrlRead($cInput)
                            ; If not use combo
                            If Not $sNumber Then
                                ; Look for the employer in the array - but ignore the "Cancel" element
                                $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 1)
                                ; If found
                                If $iIndex <> -1 Then

                                    ; Use the number
                                    Switch $iMsg ; Now we see which of the 2 button was pressed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                        Case $Button_1
                                            ; Place code for button 1 here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                            MsgBox(0, "Selection", "Number to use in Lync 2010 : " & $aData[$iIndex][1])
                                        Case $Button_3
                                            ; Place code for button 3 here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                            MsgBox(0, "Selection", "Number to use in Lync 2013 : " & $aData[$iIndex][1])
                                    EndSwitch
                                EndIf
                            EndIf
                            ; Delete the GUI
                            GUIDelete($hGUI_Child)
                            ; Reset place holders
                            $cCombo = 9999
                            $cInput = 9999
                            $cAction = 9999
                            ; Return to main loop
                            ExitLoop

                    EndSwitch
                WEnd

            Case $Button_2

            Case $Button_4

        EndSwitch
    WEnd
EndFunc   ;==>Example
How about that? :)

M23

Edited by Melba23
Wrong button too soon!

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 comment
Share on other sites

Argh I can't get it working Melba!

But I am extremely grateful for all the effort you put into this script anyway!

I have a 100% fully working script with the dropdown menu, thanks to you!

This last request was just a 'nice to have' feature!

I'm sure your code works, I'm just too n00b to implement it in the final script!

Edited by david1337
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...