Jump to content

help with getting control data in event mode


Influx
 Share

Recommended Posts

i am trying to read the control data in event mode

control creation code:

dim $x[500]
$var = WinList()
ConsoleWrite($var[0][0])
$c = ($width-150)/20
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
  $x[$i] = GUICtrlCreatebutton($var[$i][0], $c, 5, ($width-150)/20, 25)
  GUICtrlSetOnEvent(-1, "pushed")
      GUICtrlSetColor(-1, 0xffffff)
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
   GUICtrlSetTip(-1, $var[$i][0])
   $c=$c+($width-150)/20
  EndIf
NextoÝ÷ Ú·v)à~éÜjëh×6func pushed()
        WinActivate(GUICtrlRead($x[@GUI_Ctrlid-1]))
EndFunc

what am i doing wrong?

Link to comment
Share on other sites

that is a code capable of running, just add a while loop at the end and a guicreate() at the start.

that doesn't work btw.

It wasn't really capable of running as is.. by the way.

But I tinkered a bit with it. Try this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode",1)

$width = 800
$height = 300

$Form1 = GUICreate("Form1", $width, $height, 193, 115)
dim $x[500]
$var = WinList()
ConsoleWrite($var[0][0])
$c = ($width-150)/20
For $i = 1 to $var[0][0]
    
  ; Only display visble windows that have a title
  If $var[$i][0] <> "" AND _WinAPI_IsWindowVisible($var[$i][1]) Then
  $x[$i] = GUICtrlCreatebutton($var[$i][0], $c, 5, ($width-150)/20, 25)
  GUICtrlSetOnEvent(-1, "pushed")
      GUICtrlSetColor(-1, 0xffffff)
;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
   ;GUICtrlSetTip(-1, $var[$i][0])  Commented out because winactive falsely detects your form instead.
   $c=$c+($width-150)/20
  EndIf
Next

GUISetState(@SW_SHOW)
While 1

WEnd


func pushed()
        ;MsgBox(0, "Pressed", "GuiCtrlRead=" & ControlGetText("","",@GUI_CtrlID) & "ID=" & @GUI_CtrlID & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
        WinActivate("[TITLE:"&ControlGetText("","",@GUI_CtrlID)&"]")
    EndFunc
Link to comment
Share on other sites

that is a code capable of running, just add a while loop at the end and a guicreate() at the start.

~130 of my 150 posts are replies to help-requests, think I'll have to spent 1 minute adding some code to every reply, would have cost me more than 2 hours to do so, and than look at the post count of some others here... next time you don't have to add it... but it sure will raise the probability of a helpful reply... btw...

Link to comment
Share on other sites

Thanks for the help, however is there any way to left align the named (not have them centered) also is there any way to give it a tooltip?(so hovering over it will show full name) maybe using a different method, is there some kind of on_hover object?

also it includes windows not open (such as my username, proccess manager, and the start bar, desktop and start menu, is there anyway to exclude those?

Thanks so much fo rall your help,

Influx

Edited by Influx
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...