Sign in to follow this  
Followers 0
Soul

AutoIt Window Editor

9 posts in this topic

#1 ·  Posted (edited)

Window Editor

Recently, I have been working with AutoIt for about two days, but as I am rather proficient (or so I'd like to think) in most other languages, I picked it up quick. Yesterday, I started toying around with the windows feature of AutoIt. Since I had time to kill, I searched up something that would have similar function to what I was toying around with.

After a little bit, I found some prices (albeit, some with slightly better features):

$49.95

$11.99

$23.99

Insane! I could make a program like that for free!

So I did.

Features:

It is essentially the basic AutoIt window functions with a GUI or Command Line, but all features are listed anyway.

  • Command Line
  • GUI
  • Open Source
  • Always on Top
  • Show
  • Hide
  • Maximize
  • Minimize
  • Restore (Undoes Max or Min)
  • Disable (for playing tricks, not much other use) ;D
  • Enable (so you can look like a genius when you fix the problem)
  • Flash
  • Transparency
  • Minimize All
  • Undo Minimize All
  • Drop-Downs for easy Window/Command Selection.
  • Change Title (command line only)
  • Holiday Theme: Holiday Theme adds Santa to your editor (with no additional space needed)! He also disables himself so you don't click him by accident.
  • Error Catcher

Please posts bugs, suggestions, and criticism/praise here.

Below is the code in the program. You can either copy that or download below.

Window Editor v2.1

:: This program was made by Soul and posted on the AutoIt Forums. ::

:: This program is open source and free to use as long as this file remains. ::

:: This file can be removed, but credit must be given clearly visible elsewhere. ::

Step 1: Pick the value you want to edit.

Step 2: Click Edit Property.

Step 3: Do as the directions told you.

Step 4: Enjoy!

Notes:

You need AutoIt3 to edit the source.

Credit must remain.

By using this program you understand that it is being used at your own risk.

This is not malware.

I'll say it again, This Is NOT Malware.

Report all bugs to Soul on the AutoIt Forums.

Thank you for your time.

<http://php.webuda.com/autoit/winedit.au3>

If $CmdLine[0] = 0 Then
    $response = MsgBox(4, "Failure: No input.", "Correct Usage: winedit [edit] [window title] [parameter(s) (if applicable)]. Read HELP.txt for more info?")
    If $response = 7 then
        exit
    Else
        run("notepad.exe " & @ScriptDir & "\HELP.txt")
        exit
    EndIf
EndIf

If WinExists($CmdLine[2], "") = 0 Then
    MsgBox(1, "Failure: Window Access", "Could not access window. Please open the window.")
EndIf

; Set transparency.
If StringLower($CmdLine[1]) = "trans" Then
    WinActivate($CmdLine[2], "")
; Set it to Parameter1.
    WinSetTrans($CmdLine[2], "", $CmdLine[3])
ElseIf StringLower($CmdLine[1]) = "state" Then
    WinActivate($CmdLine[2], "")
; Tricky area: find out what @SW_ to use.
; Trim all but the first three letters.
$Cmd3Length = StringLen($CmdLine[3]) - 3
$CmdLineTrim = StringTrimRight($CmdLine[3], $Cmd3Length)
; This is important because someone can type min for minimize or just minimize.
; We want to make sure we cover both.
Switch StringLower($CmdLineTrim)
    Case "hid"
        WinSetState($CmdLine[2], "", @SW_HIDE)
    Case "sho"
        WinSetState($CmdLine[2], "", @SW_SHOW)
    Case "min"
        WinSetState($CmdLine[2], "", @SW_MINIMIZE)
    Case "max"
        WinSetState($CmdLine[2], "", @SW_MAXIMIZE)
    Case "res"
        WinSetState($CmdLine[2], "", @SW_RESTORE)
    Case "dis"
        WinSetState($CmdLine[2], "", @SW_DISABLE)
    Case "ena"
        WinSetState($CmdLine[2], "", @SW_ENABLE)
    Case Else
    $response = MsgBox(4, "Failure: Invalid input for parameter1.", "Correct Usage: winedit state [window title] [parameter]. Read HELP.txt for more info?")
    If $response = 7 then
        exit
    Else
        run("notepad.exe " & @ScriptDir & "\HELP.txt")
        exit
    EndIf
EndSwitch
ElseIf StringLower($CmdLine[1]) = "flash" Then
    If $CmdLine[4] = "" Then
    $response = MsgBox(4, "Failure: Invalid input for parameter4.", "Correct Usage: winedit flash [window title] [times to flash] [time between flashes]. Read HELP.txt for more info?")
    If $response = 7 then
        exit
    Else
        run("notepad.exe " & @ScriptDir & "\HELP.txt")
        exit
    EndIf
    EndIf
    WinFlash($CmdLine[2], "", $CmdLine[3], $CmdLine[4])
ElseIf StringLower($CmdLine[1]) = "top" Then
    WinSetOnTop ($CmdLine[2], "", $CmdLine[3])
ElseIf StringLower($CmdLine[1]) = "title" Then
    WinSetTitle($CmdLine[2], "", $CmdLine[3])
EndIF

<http://php.webuda.com/autoit/wineditGUI.au3>

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

Global $ExitID, $ChoiceCombo, $ListCombo
_Main()

Func _Main()
    Local $HelpButton, $OKButton, $AllWindow, $CurrentWindowRead
    GUICreate("Window Editor", 250, 180)
    ; Choice Combo:
    $ChoiceCombo = GUICtrlCreateCombo("Pick Command", 10, 32, 165, 40)
    GUICtrlSetData($ChoiceCombo, "Always On Top|Hide|Show|Minimize|Maximize|Minimize All|Undo Minimize|Restore (Undo)|Disable|Enable|Flash|Transparency|Command", "Pick Command")
    ; (Window) List Combo:
    $ListCombo = GUICtrlCreateCombo("Window Title", 10, 90, 165, 40)
    $AllWindow = WinList()
    For $CurrentWindowRead = 1 to $AllWindow[0][0]
      If $AllWindow[$CurrentWindowRead][0] <> "" AND IsVisible($AllWindow[$CurrentWindowRead][1]) Then
        GUICtrlSetData($ListCombo, $AllWindow[$CurrentWindowRead][0] & "|")
      EndIf
    Next

    ; OK Button
    $OKButton = GUICtrlCreateButton("Edit Property", 10, 60, 165)
    GUICtrlSetOnEvent($OKButton, "BtnEditProperty")
    GUICtrlSetBkColor($OKButton, 0x008000)
    GUICtrlSetColor($OKButton, 0x800000)
    ; Exit Button:
    $ExitID = GUICtrlCreateButton("Exit", 190, 150, 50, 22)
    GUICtrlSetOnEvent($ExitID, "OnExit")
    GUICtrlSetStyle($ExitID, $BS_BITMAP)
    GUICtrlSetImage($ExitID, "exit.bmp")
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
    ; Help Button:
    $HelpButton = GUICtrlCreateButton("Help", 130, 150, 50, 22)
    GUICtrlSetOnEvent($HelpButton, "BtnHelp")
    GUICtrlSetStyle($HelpButton, $BS_BITMAP)
    GUICtrlSetImage($HelpButton, "help.bmp")
    ; v DO NOT REMOVE. SHOWS GUI. v
    GUISetState()
    ; ^ DO NOT REMOVE. SHOWS GUI. ^
    WinActivate("Window Editor")
    While 1
        Sleep(1000)
    WEnd
EndFunc 


; Help:
Func BtnHelp()
    If FileExists(@ScriptDir & "\HELP.txt") = False Then
        MsgBox(0x30, "Cannot Access HELP.txt", "Window Editor ran into a problem when trying to find HELP.txt. This error is NOT fatal.")
    EndIF
    Run("notepad.exe " & @ScriptDir & "\HELP.txt")
EndFunc 

; Edit Property:
Func BtnEditProperty()
    Local $WindowListCombo, $AOTB, $IBF, $IBFD, $IBT
    $WindowListCombo = GUICtrlRead($ListCombo)
    WinActivate($WindowListCombo, "")
    Switch GUICtrlRead($ChoiceCombo)
    Case "Always On Top"
    $AOTB = MsgBox(4, $WindowListCombo & " - Window Editor", "Set to Always On Top (Yes)?" & @CRLF & "Or undo a previous Always on Top (No)?")
        WinSetOnTop($WindowListCombo, "", $AOTB - 5)
        ; Yes = 6. No = 7. 
        ; Therefore, No = 2 (not on top/invalid) and Yes = 1 (Always on Top). Nifty eh?
    Case "Hide"
        WinSetState($WindowListCombo, "", @SW_HIDE)
    Case "Show"
        WinSetState($WindowListCombo, "", @SW_SHOW)
    Case "Minimize"
        WinSetState($WindowListCombo, "", @SW_MINIMIZE)
    Case "Maximize"
        WinSetState($WindowListCombo, "", @SW_MAXIMIZE)
    Case "Restore (Undo)"
        WinSetState($WindowListCombo, "", @SW_RESTORE)
    Case "Disable"
        WinSetState($WindowListCombo, "", @SW_DISABLE)
    Case "Enable"
        WinSetState($WindowListCombo, "", @SW_ENABLE)
    Case "Flash"
        $IBF = InputBox("Number of Flashes?", "How many times do you want it to flash?", "4")
        $IBFD = InputBox("Delay Between Flashes", "How much of a delay do you want in seconds?", "5")
            WinFlash($WindowListCombo, "", $IBF, $IBFD * 1000)
    Case "Transparency"
        $IBT = InputBox("Transparency", "To what degree? (0 is fully transparent, 1-244 is translucent, and 255 is solid)", "128")
            WinSetTrans($WindowListCombo, "", $IBT)
    Case "Minimize All"
        WinMinimizeAll() ; Tell to minimize all.
    Case "Undo Minimize"
        WinMinimizeAllUndo()
    EndSwitch
EndFunc

Func IsVisible($hwnd)
    If BitAnd(WinGetState($hwnd), 2) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc

; Exit:
Func OnExit()
    Exit
EndFunc 


Func test()
    MsgBox(0, "Test", "TEST")
EndFunc

Use at your own discretion. I am not responsible for any harm, tangible or not, caused by this program.

Edited by Soul

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

So you tested this for hours and still haven't figured out that this line will never work? InputBox always returns a string; therefore, these two variables will never be numbers.

If IsNumber($IBF) = True And IsNumber($IBFD) = True Then
I could have sworn I fixed that earlier. I just removed the If altogether, seeing that AutoIt will ignore the input if it's invalid anyways.

Also, no edit button for main post. :x

Edited by Soul

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

  • Change Title (command line only)
Why only command line?

I managed to get it to work with GUI quite easily:

(Include change title option in the combo and declare the local variable $CHGTTL)

Case "Change Title"
        $CHGTTL = InputBox("Change a windows title", "Choose a new title.")
        If StringIsASCII($TitleText) Then
            if StringIsASCII($CHGTTL) Then
                WinSetTitle($TitleText, "", $CHGTTL)
            Else
                MsgBox(0, "Input must be ASCII.", "New Title contains non-ascii characters." & @CRLF & "Input must be ASCII."
            EndIf
        Else
            MsgBox(0, "Input must be ASCII.", "Window Title contains non-ascii characters." & @CRLF & "Input must be ASCII."
        EndIf

shanet

Edited by shanet

[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

Why only command line?

I managed to get it to work with GUI quite easily:

(Include change title option in the combo and declare the local variable $CHGTTL)

I had made the command line first for personal use, then converted it over to GUI. I found the change title feature rather worthless and cumbersome. I would have to change the textbox, although simple, it could confuse the user. Making this userfriendly is one of my goals, and changing a window title has very narrow usage. I kept it in Command Line (well, it's already there).

I'll be adding support for minimize all but ..., undo minimize, and hopefully a more userfriendly list of windows later today. Please download from the attachment, the source code is now outdated.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Attached is the newest version (v2).

Change Log:

Replaced Textbox with another combo box, now containing all windows you have open.

Minimize All/Undo Minimize All (although I'm not sure this works fully).

Fixed Transparency/Flash.

Download here. This link is the one that will be updated. (If someone could add this to the main post, and remove the code, I'd be very grateful).

In case you're skeptical about OMG VIRUS ATTACK, here is the forum attachment version, which will be outdated next time I update.

Window Editor v2.zip

Edited by Soul

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You need to have a certain number of posts (10?) before you are allowed to edit them.

Ah, well I suppose that makes sense,

Edit: Haha. Just as I posted this it gave me the ability to edit posts.

Edited by Soul

Share this post


Link to post
Share on other sites

@Soul

Looks like clever idea for handy tool.

But it should allow changing all these properties (enable/disable/show/hide/...) also for controls and not only for windows.

Also it's good practise to edit first post in your topic accordingly to have there latest version

so people needn't go through all posts to check where is the latest version.

Share this post


Link to post
Share on other sites

@Soul

Looks like clever idea for handy tool.

But it should allow changing all these properties (enable/disable/show/hide/...) also for controls and not only for windows.

Also it's good practise to edit first post in your topic accordingly to have there latest version

so people needn't go through all posts to check where is the latest version.

I'll get working on the control thing now, thanks for the good idea. :x

I wanted to edit the first post, but you aren't allowed to until you have five posts. I have updated the first post now.

Share this post


Link to post
Share on other sites

Merry Christmas Everyone!

Change Log for v2.1:

  • Added Festive Theme
  • Added Help and Exit Graphics. (I'm a programmer, not an artist.)

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