Jump to content

Recommended Posts

Posted (edited)

A windows helper, just some general funcs.I had to do this because sometimes i want some screenshot from and apps or some games and stuff.

Here's the code:

Added ControlSetText(Didn't figure out how to use ControlSend properly). Just a little bit more convienient.

#include<GUIConstants.au3>
#include<misc.au3>
Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 2)
Opt("TrayMenuMode", 3)
Opt("GUICloseOnEsc", 0)
Global $i = 0
Global $Title = ""
Global $Top = False, $Status = True
FileInstall("\Capture.dll", @TempDir, 0)
$gui = GUICreate("Windows Helper", 215, 130, -1, -1, -1)
$input = GUICtrlCreateInput("Your Windows Title", 2, 3, 210, 20)
$button = GUICtrlCreateButton("Take Screenshot", 5, 25, 100, 30)
$button0 = GUICtrlCreateButton("Minimize", 110, 25, 100, 30)
$button1 = GUICtrlCreateButton("Set On Top", 5, 60, 100, 30)
$button3 = GUICtrlCreateButton("Disable", 110, 60, 100, 30)
$button2 = GUICtrlCreateButton("Close Windows", 5, 95, 205, 30)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUICtrlSetOnEvent($button, "_Screenshot")
GUICtrlSetOnEvent($button0, "_Minimize")
GUICtrlSetOnEvent($button2, "_Close")
GUICtrlSetOnEvent($button1, "_OnTop")
GUICtrlSetOnEvent($button3, "_State")
GUICtrlSetTip($input, "Ctrl+Left Click to get Windows Title", "Help", 1, 1)
GUICtrlSetLimit($input, 200)
GUISetFont(9, 400, 0, "Tahoma")
GUICtrlSetFont($button, 9, 400, 0, "Tahoma")
GUICtrlSetFont($button0, 9, 400, 0, "Tahoma")
GUICtrlSetFont($button2, 9, 400, 0, "Tahoma")
GUICtrlSetFont($button1, 9, 400, 0, "Tahoma")
GUICtrlSetFont($button3, 9, 400, 0, "Tahoma")
GUICtrlSetFont($input, 9, 400, 0, "Tahoma")
GUISetState()
While 1
    _Check()
    If _IsPressed("01") And _IsPressed("A2") Then
        $Winlist = WinList()
        For $list = 1 To $Winlist[0][0]
            If WinActive($Winlist[$list][1]) Then
                $WinTitle = $Winlist[$list][0]
            EndIf
        Next
        ControlFocus($gui, "", "Edit1")
        ControlSetText($gui, "", "Edit1", $WinTitle)
    EndIf
    Sleep(100)
WEnd
Func Quit()
    Exit
EndFunc   ;==>Quit
Func _Minimize()
    Local $state = WinSetState($Title, "", @SW_MINIMIZE)
    If $state = 0 Then
        _ToolTip()
        Return
    EndIf
EndFunc   ;==>_Minimize
Func _Close()
    Local $Close = WinClose($Title, "")
    If $Close = 0 Then
        _ToolTip()
        Return
    EndIf
EndFunc   ;==>_Close
Func _Screenshot()
    Local $size = WinGetPos($Title, "")
    If $size = 0 Then
        _ToolTip()
        Return
    EndIf
    DllCall(@TempDir & "\Capture.dll", "int:cdecl", "CaptureRegion", "str", $Title & " - " & $i & ".jpg", "int", $size[0], "int", $size[1], "int", $size[2], "int", $size[3], "int", 85)
    $i = $i + 1
EndFunc   ;==>_Screenshot
Func _ToolTip()
    ToolTip($Title & " was not found", Default, Default, "Windows Helper", 1, 1)
    Sleep(800)
    ToolTip("")
EndFunc   ;==>_ToolTip
Func _OnTop()
    $Top = Not $Top
    If $Top = True Then
        If Not WinSetOnTop($Title, "", 1) Then
            _ToolTip()
            $Top = Not $Top
            Return
        EndIf
        GUICtrlSetData($button1, "Remove On Top")
    Else
        If Not WinSetOnTop($Title, "", 0) Then
            _ToolTip()
            $Top = Not $Top
            Return
        EndIf
        GUICtrlSetData($button1, "Set On Top")
    EndIf
EndFunc   ;==>_OnTop
Func _State()
    $Status = Not $Status
    If $Status = False Then
        If Not WinSetState($Title, "", @SW_DISABLE) Then
            _ToolTip()
            $Status = Not $Status
            Return
        EndIf
        GUICtrlSetData($button3, "Enable")
    Else
        If Not WinSetState($Title, "", @SW_ENABLE) Then
            _ToolTip()
            $Status = Not $Status
            Return
        EndIf
        GUICtrlSetData($button3, "Disable")
    EndIf
EndFunc   ;==>_State
Func _Check()
    $Title = GUICtrlRead($input)
    Return $Title
EndFunc   ;==>_Check

Useful or not, just leave a comment.

Download link for capture.dll

I don't take credit because this thing doesn't require skill to make, but capture.dll credit goes to LazyCat. Rest goes to Autoit Forum.

Edited by Generator
Posted

I really love ur work

nice job I could use some learning example like this

can u tell me about the DLL file ? is ur programing

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Posted

I really love ur work

nice job I could use some learning example like this

can u tell me about the DLL file ? is ur programing

Nope i already gave credit to LazyCat for the capture.dll.
Posted

Nope i already gave credit to LazyCat for the capture.dll.

aha, but really nice job both of u

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Posted (edited)

pretty cool script. I personally love it. Rate: between 4 - 5 stars, i need to decide :rolleyes:

EDIT: 5 stars definitely. After a little thinking, I think it is better to have gui instead editing script for parameters. Excellent.

Edited by i542

I can do signature me.

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
×
×
  • Create New...