Sign in to follow this  
Followers 0
faldo

Drop-down list?

12 posts in this topic

Is it possible to create a "drop-down" list with GUI that lists all the windows currently active/inactive/minimized etc. and then one could select a window and move that name into a variable?

If so, i'd love to get some help on how that would look :)

Share this post


Link to post
Share on other sites



Is it possible to create a "drop-down" list with GUI that lists all the windows currently active/inactive/minimized etc. and then one could select a window and move that name into a variable?

If so, i'd love to get some help on how that would look :)

<{POST_SNAPBACK}>

Check here for new WinList() feature in the unstable version.: #41057

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

wow... AutoIt just gets better and better... thanx alot! =o)

Share this post


Link to post
Share on other sites

I got the script working where i could create MSGboxes that poped one after one displaying all the window titles... but how do i put that in a drop-down list? some loop in the list of some kind? :/

Share this post


Link to post
Share on other sites

I got the script working where i could create MSGboxes that poped one after one displaying all the window titles... but how do i put that in a drop-down list? some loop in the list of some kind? :/

<{POST_SNAPBACK}>

something like this ?

#include <GUIConstants.au3>
$var = WinList ()
$Windows = ""
For $i = 1 To $var[0][0]
  ; Only display visble windows that have a title
   If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
      If $Windows = "" Then
         $Windows = $var[$i][0]
      Else
         $Windows = $Windows & "|" & $var[$i][0]
      EndIf
   EndIf
Next
GUICreate("test")
GUICtrlCreateCombo("windows", 10, 10)
GUICtrlSetData(-1, $Windows)
GUISetState()
; Run the GUI until the dialog is closed
While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Func IsVisible($handle)
   If BitAND( WinGetState($handle), 2) Then
      Return 1
   Else
      Return 0
   EndIf
EndFunc  ;==>IsVisible

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

How do i keep a text in a GUIwindow updated along with a variable?... meaning: if the variable changes, the text also changes automaticly.

I tried it with GUICtrlGetState but i'm not sure i'm doing it right :/

Edited by faldo

Share this post


Link to post
Share on other sites

How do i keep a text in a GUIwindow updated along with a variable?... meaning: if the variable changes, the text also changes automaticly.

I tried it with GUICtrlGetState but i'm not sure i'm doing it right :/

<{POST_SNAPBACK}>

dunno what you mean... what text do you want to update? or maybe show your code ...

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

#include <GUIConstants.au3>
$var = WinList ()
$Windows = "test"
For $i = 1 To $var[0][0]
; Only display visble windows that have a title
  If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
     If $Windows = "" Then
        $Windows = $var[$i][0]
     Else
        $Windows = $Windows & "|" & $var[$i][0]
     EndIf
  EndIf
Next

GUICreate("Windows")
$n1=GUICtrlCreateCombo("windows", 10, 10)
GUICtrlSetData(-1, $Windows)
GUISetState()

GUICtrlCreateLabel ( GuiRead($n1),  70, 70)



; Run the GUI until the dialog is closed
While 1
  $msg = GUIGetMsg()
  If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Func IsVisible($handle)
  If BitAND( WinGetState($handle), 2) Then
     Return 1
  Else
     Return 0
  EndIf
EndFunc;==>IsVisible

I would like it to change $n1 as soon as i change $Windows... so that the label is allways updated when i change the selection in the list.

Edited by faldo

Share this post


Link to post
Share on other sites

You need to save the handle for the label and the update that when somethiung is selected in the combo:

#include <GUIConstants.au3>
$var = WinList ()
$Windows = "test"
For $i = 1 To $var[0][0]
  ; Only display visble windows that have a title
   If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
      If $Windows = "" Then
         $Windows = $var[$i][0]
      Else
         $Windows = $Windows & "|" & $var[$i][0]
      EndIf
   EndIf
Next
GUICreate("Windows")
$n1 = GUICtrlCreateCombo("windows", 10, 10)
GUICtrlSetData(-1, $Windows)
GUISetState()
$selected = GUICtrlCreateLabel(GUIRead($n1), 70, 70)
; Run the GUI until the dialog is closed
While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
   If $msg = $n1 Then GUICtrlSetData($selected,GUIRead($n1))
Wend
Func IsVisible($handle)
   If BitAND( WinGetState($handle), 2) Then
      Return 1
   Else
      Return 0
   EndIf
EndFunc  ;==>IsVisible

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>


$var = WinList ()
$Windows = ""
For $i = 1 To $var[0][0]
; Only display visble windows that have a title
  If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
     If $Windows = "" Then
        $Windows = $var[$i][0]
     Else
        $Windows = $Windows & "|" & $var[$i][0]
     EndIf
  EndIf
Next


If Random() < 0.5 Then
   ;Capitals
    $Letter1 = Chr(Random(Asc("A"), Asc("Z")+1))
    $Letter2 = Chr(Random(Asc("A"), Asc("Z")+1))
    $Letter3 = Chr(Random(Asc("A"), Asc("Z")+1))
    $Letter4 = Chr(Random(Asc("A"), Asc("Z")+1))
    $Letter5 = Chr(Random(Asc("A"), Asc("Z")+1))
    $Letter6 = Chr(Random(Asc("A"), Asc("Z")+1))
Else
   ;Lower case
    $Letter1 = Chr(Random(Asc("a"), Asc("z")+1))
    $Letter2 = Chr(Random(Asc("a"), Asc("z")+1))
    $Letter3 = Chr(Random(Asc("a"), Asc("z")+1))
    $Letter4 = Chr(Random(Asc("a"), Asc("z")+1))
    $Letter5 = Chr(Random(Asc("a"), Asc("z")+1))
    $Letter6 = Chr(Random(Asc("a"), Asc("z")+1))
Endif



GUICreate("test")
$n1=GUICtrlCreateCombo("Select a window", 10, 10)
GUICtrlSetData(-1, $Windows)
GUISetState()
GUICtrlCreateLabel ( "Do you want to change the window-title of:",  60, 50)
$selected=GUICtrlCreateLabel ( GuiRead($n1),  70, 70, 300)
GUICtrlCreateLabel ( "to:",  60, 90)
$changed=GUICtrlCreateLabel ( $Letter1 & $Letter2 & $Letter3 & $Letter4 & $Letter5 & $Letter6 & "?",  70, 110, 300)


$cancel=GUICtrlCreateButton ("Cancel",  120, 140, 50)
$yes=GUICtrlCreateButton ( "Yes",  70, -1, 50)
$refresh=GUICtrlCreateButton ( "Refresh",  320, 10, 50)

GUISetState () 


; Run the GUI until the dialog is closed
While 1
  $msg = GUIGetMsg()
  If $msg = $GUI_EVENT_CLOSE Then ExitLoop
  If $msg = $n1 Then GUICtrlSetData($selected, GUIRead($n1))
  If $msg = $cancel Then ExitLoop
  If $msg = $yes Then WinSetTitle(GuiRead($n1), "", GuiRead($changed))
  If $msg = $refresh Then 
Wend

Func IsVisible($handle)
  If BitAND( WinGetState($handle), 2) Then
     Return 1
  Else
     Return 0
  EndIf
EndFunc ;==>IsVisible

Could someone please help me with the "refresh button"? I would like to get the dropdown-list refreshed.

Share this post


Link to post
Share on other sites

Could someone please help me with the "refresh button"? I would like to get the dropdown-list refreshed.

<{POST_SNAPBACK}>

moved the winlist into a function and call that everytime the button is pressed...something like:

#include <GUIConstants.au3>
If Random() < 0.5 Then
  ;Capitals
   $Letter1 = Chr(Random(Asc("A"), Asc("Z") + 1))
   $Letter2 = Chr(Random(Asc("A"), Asc("Z") + 1))
   $Letter3 = Chr(Random(Asc("A"), Asc("Z") + 1))
   $Letter4 = Chr(Random(Asc("A"), Asc("Z") + 1))
   $Letter5 = Chr(Random(Asc("A"), Asc("Z") + 1))
   $Letter6 = Chr(Random(Asc("A"), Asc("Z") + 1))
Else
  ;Lower case
   $Letter1 = Chr(Random(Asc("a"), Asc("z") + 1))
   $Letter2 = Chr(Random(Asc("a"), Asc("z") + 1))
   $Letter3 = Chr(Random(Asc("a"), Asc("z") + 1))
   $Letter4 = Chr(Random(Asc("a"), Asc("z") + 1))
   $Letter5 = Chr(Random(Asc("a"), Asc("z") + 1))
   $Letter6 = Chr(Random(Asc("a"), Asc("z") + 1))
EndIf
GUICreate("test")
$n1 = GUICtrlCreateCombo("Select a window", 10, 10)
GUICtrlSetData(-1, getWindows())
GUISetState()
GUICtrlCreateLabel("Do you want to change the window-title of:", 60, 50)
$selected = GUICtrlCreateLabel(GUIRead($n1), 70, 70, 300)
GUICtrlCreateLabel("to:", 60, 90)
$changed = GUICtrlCreateLabel($Letter1 & $Letter2 & $Letter3 & $Letter4 & $Letter5 & $Letter6 & "?", 70, 110, 300)
$cancel = GUICtrlCreateButton("Cancel", 120, 140, 50)
$yes = GUICtrlCreateButton("Yes", 70, -1, 50)
$refresh = GUICtrlCreateButton("Refresh", 320, 10, 50)
GUISetState()
; Run the GUI until the dialog is closed
While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
   If $msg = $n1 Then GUICtrlSetData($selected, GUIRead($n1))
   If $msg = $cancel Then ExitLoop
   If $msg = $yes Then WinSetTitle(GUIRead($n1), "", GUIRead($changed))
   If $msg = $refresh Then GUICtrlSetData($n1, getWindows())
Wend
;
Func getWindows()
   Local $T_Windows = ""
   Local $Var = WinList ()
   For $i = 1 To $var[0][0]
     ; Only display visble windows that have a title
      If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
            $T_Windows = $T_Windows & "|" & $var[$i][0]
      EndIf
   Next
   Return $T_Windows
EndFunc  ;==>getWindows
;
Func IsVisible($handle)
   If BitAND( WinGetState($handle), 2) Then
      Return 1
   Else
      Return 0
   EndIf
EndFunc  ;==>IsVisible

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Worx great... thanx again.

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
Sign in to follow this  
Followers 0