Jump to content

Problem with strings


Recommended Posts

I made this small script to practice my gui using and i was wondering if there is a way i can make an input box have a documents typed name in it so the autoit will find that name and pixel color and put it in the trash ben

; Autoit Script by: ÆTnTProductionsÆ
; this is a simple clean up script that i made to practice using Gui options
; ill add more delet options later

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}","Terminate")
Func Terminate()
    Exit 0
EndFunc
GUICreate("Desktop Cleaner V1.03",400,500,-1,-1,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$word = GUICtrlCreateButton("Clean Word Document",0,10,200,50)
$autoit = GUICtrlCreateButton("clean Autoit Script",200,10,200,50)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
;if you press word document
Case $msg = $word
    $C = PixelSearch(0,0,1271,767,0x0000FF)
If not @error then
MouseClickDrag("left", $C[0], $C[1],46,50)
endif
Case $msg = $autoit
    $X = PixelSearch(0,0,1271,767,0x394b80)
    If not @error then
MouseClickDrag("left", $X[0], $X[1],46,50)
EndIf
EndSelect
WEnd
Edited by TnTProductions

"FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"

Link to comment
Share on other sites

Let me get this straight ... you want to have actually an inputbox instead of 2 buttons and if you type in "word" and hit the "Go" button it will look for word documents and if you type "autoit" it will look for autoit scripts.

Is this what would you like to do?

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Hi,

If it is a case of just sending a certain file type from the desktop to the recycle bin then maybe try something like this.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiComboBoxEx.au3>
#include <File.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $fTypes = "au3|doc|docx|txt|zip|rar|lnk"

$Gui = GUICreate("Desktop Cleaner V1.03", 385, 185, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)

$LV = GUICtrlCreateListView("Desktop Files", 5, 10, 280, 140, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))
FindDesktopFiles()

GUICtrlCreateGroup("File Types", 290, 5, 90, 45)
$Combo = GUICtrlCreateCombo("All Types", 300, 20, 70, 20, $CBS_DROPDOWNLIST)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetData(-1, $fTypes, "All Types")

$SelectAll = GUICtrlCreateButton("Select All", 290, 65, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SelectNone = GUICtrlCreateButton("Select None", 290, 95, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$InvertSeleced = GUICtrlCreateButton("Invert Selected", 290, 125, 90, 25)
GUICtrlSetOnEvent(-1, "Event")

$SendToBin = GUICtrlCreateButton("Send Selected File(s) To Recycle Bin", 5, 155, 375, 25)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 10, 700)

GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            FindDesktopFiles(GUICtrlRead($Combo))
        Case $SelectAll
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, True)
            Next
        Case $SelectNone
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, False)
            Next
        Case $InvertSeleced
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then
                    _GUICtrlListView_SetItemChecked($LV, $s, False)
                Else
                    _GUICtrlListView_SetItemChecked($LV, $s, True)
                EndIf
            Next
        Case $SendToBin
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then _
                        FileRecycle(@DesktopDir & "\" & _GUICtrlListView_GetItemText($LV, $s, 0))
            Next
            FindDesktopFiles(GUICtrlRead($Combo))
    EndSwitch
EndFunc

Func FindDesktopFiles($sType = "All Types")
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))
    Local $ext = "*." & $sType, $FL2A
    If $sType = "All Types" Then $ext = "*.*"
    $FL2A = _FileListToArray(@DesktopDir, $ext, 1)
    If Not @error Then
        For $i = 1 To $FL2A[0]
            If $sType = "All Types" Then
                Local $SST = StringSplit($fTypes, "|")
                For $j = 1 To $SST[0]
                    If $SST[$j] = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
                            GUICtrlCreateListViewItem($FL2A[$i], $LV)
                Next
            ElseIf $sType <> "All Types" Then
                If $sType = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
                        GUICtrlCreateListViewItem($FL2A[$i], $LV)
            EndIf
        Next
        _GUICtrlListView_SetColumnWidth($LV, 0, $LVSCW_AUTOSIZE)
    EndIf
EndFunc

All I did was *cough*, mildly modified your code.

Cheers

Link to comment
Share on other sites

Let me get this straight ... you want to have actually an inputbox instead of 2 buttons and if you type in "word" and hit the "Go" button it will look for word documents and if you type "autoit" it will look for autoit scripts.

Is this what would you like to do?

No, i want to make it where above the button there is an input box where autoit uses the GUICtrlRead() function and searches for the file with that name and delets it after you press the button so it would look kind of like this:

$word = GUICtrlCreateButton("Clean Word Document",0,10,200,50)
$Docname = GuiCtrlCreateInput("Enter Name of Your Document", 0, 10, 100, 20)
$msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
;if you press word document
Case $msg = $word
$nameofdoc = GUICtrlRead($Docname)
$C = PixelSearch(0,0,1271,767,0x0000FF)
If not @error then
MouseClickDrag("left", $C[0], $C[1],46,50)

"FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"

Link to comment
Share on other sites

Hi,

If it is a case of just sending a certain file type from the desktop to the recycle bin then maybe try something like this.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiComboBoxEx.au3>
#include <File.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $fTypes = "au3|doc|docx|txt|zip|rar|lnk"

$Gui = GUICreate("Desktop Cleaner V1.03", 385, 185, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)

$LV = GUICtrlCreateListView("Desktop Files", 5, 10, 280, 140, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))
FindDesktopFiles()

GUICtrlCreateGroup("File Types", 290, 5, 90, 45)
$Combo = GUICtrlCreateCombo("All Types", 300, 20, 70, 20, $CBS_DROPDOWNLIST)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetData(-1, $fTypes, "All Types")

$SelectAll = GUICtrlCreateButton("Select All", 290, 65, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SelectNone = GUICtrlCreateButton("Select None", 290, 95, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$InvertSeleced = GUICtrlCreateButton("Invert Selected", 290, 125, 90, 25)
GUICtrlSetOnEvent(-1, "Event")

$SendToBin = GUICtrlCreateButton("Send Selected File(s) To Recycle Bin", 5, 155, 375, 25)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 10, 700)

GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            FindDesktopFiles(GUICtrlRead($Combo))
        Case $SelectAll
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, True)
            Next
        Case $SelectNone
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, False)
            Next
        Case $InvertSeleced
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then
                    _GUICtrlListView_SetItemChecked($LV, $s, False)
                Else
                    _GUICtrlListView_SetItemChecked($LV, $s, True)
                EndIf
            Next
        Case $SendToBin
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then _
                        FileRecycle(@DesktopDir & "\" & _GUICtrlListView_GetItemText($LV, $s, 0))
            Next
            FindDesktopFiles(GUICtrlRead($Combo))
    EndSwitch
EndFunc

Func FindDesktopFiles($sType = "All Types")
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))
    Local $ext = "*." & $sType, $FL2A
    If $sType = "All Types" Then $ext = "*.*"
    $FL2A = _FileListToArray(@DesktopDir, $ext, 1)
    If Not @error Then
        For $i = 1 To $FL2A[0]
            If $sType = "All Types" Then
                Local $SST = StringSplit($fTypes, "|")
                For $j = 1 To $SST[0]
                    If $SST[$j] = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
                            GUICtrlCreateListViewItem($FL2A[$i], $LV)
                Next
            ElseIf $sType <> "All Types" Then
                If $sType = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
                        GUICtrlCreateListViewItem($FL2A[$i], $LV)
            EndIf
        Next
        _GUICtrlListView_SetColumnWidth($LV, 0, $LVSCW_AUTOSIZE)
    EndIf
EndFunc

All I did was *cough*, mildly modified your code.

Cheers

Thanks this was exactly what i was looking for

"FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"

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...