Sign in to follow this  
Followers 0
James

_StealWinTitle() - Need help

12 posts in this topic

Hey,

I am currently working on a UDF which deals with:

  • Fading GUI in
  • Steal a random window title and sets the AutoIt window title
I have the fading one done.. But the name steal is hard.

I currently have:

Func _StealWinTitle($iGUI)
    $iGUI = AutoItWinGetTitle()
EndFunc

The idea is, the UDF will create a list of all the windows which are currently available. Then it will randomly set the title of an AutoIt GUI from the available windows. But I have no idea how to do that.

So:

  • Creates a list of the running windows
  • Randomly picks a window title
  • Sets the AutoIt window to the chosen name
If you still don't get it, ask me.

Thanks,

Secure

Share this post


Link to post
Share on other sites



But why


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Creates a list of the running windows - Use search button in the forum

Randomly picks a window title - Well a hint Random()

Sets the AutoIt window to the chosen name - Look inj the file containing help also know as helpfile...

And the

Func _StealWinTitle($iGUI)

$iGUI = AutoItWinGetTitle()

EndFunc

Cant be used to anything of the things you wanna acomplish :whistle:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

This is what I did to solve this problem. Let me know if it works for you.

;Made by: Sardith
;Jeff
;Type: UDF?
;Renames a GUI to a random Running program title, that is visable, and isn't "".
;2-23-07

Dim $Program, $i, $Rvar

Func _Randomtitle($Debug = 1); Debug = 0, no Debug mode. Debug = 1, Debug mode. Shows a Debug tooltip.
$Program = WinList(); Gathers current running programs.
sleep(10)

Do 
    $Rvar = Random(1, $Program[0][0]); Randoms a program. Program 1- to current amount of running programs. '$Program[0][0]'
  
Until $Program[$Rvar][0] <> "" AND _IsVisible($Program[$Rvar][1]);Checks the program, to make sure it's not blank Window title, and if it's visable to the user.

If $Debug = 0 Then
    Sleep(10)

ElseIf $Debug = 1 Then

ToolTip("", 0, 0);Clears old tooltip. DEBUG
Sleep(10); DEBUS
ToolTip("Title= " & $Program[$Rvar][0] & @LF & "Handle= " & $Program[$Rvar][1], 0, 0);Test: Displays a random program gathered from Winlist. DEBUG
Sleep(1000); DEBUG
EndIf
EndFunc

Func _IsVisible($handle);Checks to see if program is visable to the current user.
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc

Func _StealWinTitle(); Must keep the _Randomtitle placement. You also, must have a GUI created, $iGUI.
    $GUItitle = WinGetTitle($iGUI, "");Gets title of the parent GUI you created. AutoIt Help file variable = $iGUI
_Randomtitle("1")
WinSetTitle($GUItitle, "", $Program[$Rvar][0]); Renames the GUI title to a random program title.
EndFunc

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This is what I did to solve this problem. Let me know if it works for you.

Mines a little shorter.

Func _StealWindowTitle($Title_to_Change)
$oldTitle=WinGetTitle($Title_to_Change)
Local $Window[100], $Title[100], $HWND[100], $number = 0
Local $WindowList = WinList()
For $i = 1 to $WindowList[0][0]
    If $WindowList[$i][0] <> "" And $WindowList[$i][0] <> "Program Manager" AND $WindowList[$i][0] <> $oldtitle AND IsVisible($WindowList[$i][1]) Then
        $number = $number + 1
        $HWND[$Number] = $WindowList[$i][1]
        $Title[$Number] = $WindowList[$i][0]
    EndIf
Next
WinSetTitle(WinGetHandle($oldtitle),"",$Title[Random(1,$number)])
EndFunc

Func IsVisible($handle)
    If BitAnd( WinGetState($handle), 2 ) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc
Edited by Paulie

Share this post


Link to post
Share on other sites

Mines a little shorter.

:) You bragging? :whistle:

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

:) You bragging? :whistle:

Who? me?! B):lol::P:lol::)

No way! :(

Share this post


Link to post
Share on other sites

Paulie

The function _IsVisible() can be much shorter :whistle:

Func IsVisible($handle)
    Return  BitAnd( WinGetState($handle), 2 )
EndFunc

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Mines a little shorter.

Func _StealWindowTitle($Title_to_Change)
$oldTitle=WinGetTitle($Title_to_Change)
Local $Window[100], $Title[100], $HWND[100], $number = 0
Local $WindowList = WinList()
For $i = 1 to $WindowList[0][0]
    If $WindowList[$i][0] <> "" And $WindowList[$i][0] <> "Program Manager" AND $WindowList[$i][0] <> $oldtitle AND IsVisible($WindowList[$i][1]) Then
        $number = $number + 1
        $HWND[$Number] = $WindowList[$i][1]
        $Title[$Number] = $WindowList[$i][0]
    EndIf
Next
WinSetTitle(WinGetHandle($oldtitle),"",$Title[Random(1,$number)])
EndFunc

Func IsVisible($handle)
    If BitAnd( WinGetState($handle), 2 ) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc
Thats interesting. I'll look at that script of yours. Always willing to learn something new =)

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

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