Jump to content
Sign in to follow this  
zaini

Stop array function

Recommended Posts

zaini

i using array function in my script...now i want set the array to stop before the its operation end..

how could i do that?? :P


Share this post


Link to post
Share on other sites
cartman380

i using array function in my script...now i want set the array to stop before the its operation end..

how could i do that?? :P

We need more information than that, perhaps a code sample so we understand what it is you are trying to do.

Share this post


Link to post
Share on other sites
Varian

If you are using function like:

Func YourFuncName()

some code

EndFunc

Then use keyword: Return to exit out of a function and continue your script

Share this post


Link to post
Share on other sites
zaini

We need more information than that, perhaps a code sample so we understand what it is you are trying to do.

#include <GUIConstants.au3>
#include <File.au3>
#include <FileListToArray3.au3>
#include <GuiListView.au3>
#include <ReduceMemory.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\zainiafzan\Desktop\Au3it\Scan projek\Scanner.kxf
$Form1 = GUICreate("Gui", 417, 400, -1, -1)
GUISetBkColor(0x7A96DF)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\zainiafzan\Desktop\Au3it\Scan projek\scan pendrive.jpg", 0, 0, 416, 105, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Group1 = GUICtrlCreateGroup("Select Your Pendrive :", 8, 120, 401, 65)
$Input1 = GUICtrlCreateInput("", 16, 144, 305, 21, BitOR($ES_AUTOHSCROLL,$WS_BORDER))
$Button1 = GUICtrlCreateButton("Browse", 328, 141, 73, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListView1 = GUICtrlCreateListView("File|Size|Format", 8, 192, 401, 145, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_BORDER))
GUICtrlSendMsg(-1, 0x101E, 0, 150)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
$Label2 = GUICtrlCreateLabel("Indexing :   NONE", 8, 344, 295, 30)
GUICtrlSetColor(-1, 0xFFFFFF)
$Button2 = GUICtrlCreateButton("Start", 320, 344, 89, 25, 0)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Pic2 = GUICtrlCreatePic("C:\Documents and Settings\zainiafzan\Desktop\Au3it\name.gif", 8, 376, 85, 15, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$inipath = @ScriptDir & "\Update.ini"
If FileExists($inipath) = 0 Then
MsgBox(0,"Update!!!","Please Indexing Your Pendrive")
EndIf

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
         Exit
     Case $Button1
         $var = FileSelectFolder("Choose a folder.", "")
         $File = GUICtrlSetData($Input1,$var)
     Case $Button2
         GUICtrlSetData($Label2,"Scanning : Getting Collection...") 
         $File1 = GUICtrlRead($Input1)
         _GUICtrlListView_DeleteAllItems_MODIFIED($ListView1)
         If $File1 = True Then
             loadfiles($var)
             Indexing()
        Else
             MsgBox(0,"Scanner Error!!!","Please select your pendrive")
        EndIf
         
EndSwitch
WEnd
_ReduceMemory()
Func loadfiles($folder)
$files = _FileListToArray3($folder, "*.*", 1, 1)
local $szIconFile1, $nIcon1=0,$ListViewItem[UBound($files)]
For $i = 1 To UBound($files) - 1
GUICtrlSetData($Label2,"Scanning : " &$files[$i]) 
$ListViewItem[$i]=GUICtrlCreateListViewItem($files[$i] & "|" & Round(FileGetSize($files[$i]) / 1024)&" Kb" & "|" & StringRight($files[$i], 3), $ListView1)
GUICtrlSetImage(-1, _FileGetIcon($folder&'\'&$files[$i]), 1)
Next

EndFunc;==>loadfiles

Func _FileGetIcon($szFile)
Local $arTemp,$sExt,$arPath
$arTemp = StringSplit($szFile,'.')
$sExt='.'&$arTemp[$arTemp[0]]
If StringLower($sExt) = '.exe' Then Return $szFile
$arPath = StringRegExp(RegRead("HKCR\"&RegRead("HKCR\"&$sExt,"")&"\shell\open\command",""),"(.*)(?i)exe",2)
If IsArray($arPath) Then
Return StringReplace($arPath[0],'"','')
Else
;unknown...
Return "shell32.dll"
EndIf
EndFunc;==>_FileGetIcon

Func ControlColor($ControlArray,$BkColor,$Color)
    For $Index = 0 To UBound($ControlArray)-1
        GUICtrlSetBkColor($ControlArray[$Index],$BkColor)
        GUICtrlSetColor($ControlArray[$Index],$Color)
    Next
EndFunc;==>ControlColor

Func Indexing()
    $list = IniReadSection($inipath,"treat")
    MsgBox (4160, "Information", "Item Scanned: " & _GUICtrlListView_GetItemCount ($ListView1) & " Files")
    Sleep(100)
EndFunc


Func _GUICtrlListView_DeleteAllItems_MODIFIED($hWnd)
    If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
    Local $ctrlID, $index
   
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
   
    If _GUICtrlListView_GetItemCount($hWnd) == 0 Then Return True

    Return _SendMessage($hWnd, $LVM_DELETEALLITEMS) <> 0
EndFunc  ;==>_GUICtrlListView_DeleteAllItems



Func _ReturnStringArraySearch(ByRef $n_Array, $f_FindString)
    For $i = 1 To UBound($n_Array) - 1
        If StringInStr($n_Array[$i], $f_FindString) Then Return $n_Array[$i]
    Next
EndFunc

This is my script...i want to add stop indexing button...i dont know how to create that function...

can you help me..???


Share this post


Link to post
Share on other sites
zaini

If you are using function like:

Func YourFuncName()

some code

EndFunc

Then use keyword: Return to exit out of a function and continue your script

thanks for an advice...but how i want to put it in my script..? :P

Edited by zaini

Share this post


Link to post
Share on other sites
trancexx

#include <GUIConstants.au3>
#include <File.au3>
#include <FileListToArray3.au3>
#include <GuiListView.au3>
#include <ReduceMemory.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\zainiafzan\Desktop\Au3it\Scan projek\Scanner.kxf
$Form1 = GUICreate("Gui", 417, 400, -1, -1)
GUISetBkColor(0x7A96DF)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\zainiafzan\Desktop\Au3it\Scan projek\scan pendrive.jpg", 0, 0, 416, 105, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Group1 = GUICtrlCreateGroup("Select Your Pendrive :", 8, 120, 401, 65)
$Input1 = GUICtrlCreateInput("", 16, 144, 305, 21, BitOR($ES_AUTOHSCROLL,$WS_BORDER))
$Button1 = GUICtrlCreateButton("Browse", 328, 141, 73, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListView1 = GUICtrlCreateListView("File|Size|Format", 8, 192, 401, 145, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_BORDER))
GUICtrlSendMsg(-1, 0x101E, 0, 150)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
$Label2 = GUICtrlCreateLabel("Indexing :   NONE", 8, 344, 295, 30)
GUICtrlSetColor(-1, 0xFFFFFF)
$Button2 = GUICtrlCreateButton("Start", 320, 344, 89, 25, 0)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Pic2 = GUICtrlCreatePic("C:\Documents and Settings\zainiafzan\Desktop\Au3it\name.gif", 8, 376, 85, 15, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$inipath = @ScriptDir & "\Update.ini"
If FileExists($inipath) = 0 Then
MsgBox(0,"Update!!!","Please Indexing Your Pendrive")
EndIf

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
         Exit
     Case $Button1
         $var = FileSelectFolder("Choose a folder.", "")
         $File = GUICtrlSetData($Input1,$var)
     Case $Button2
         GUICtrlSetData($Label2,"Scanning : Getting Collection...") 
         $File1 = GUICtrlRead($Input1)
         _GUICtrlListView_DeleteAllItems_MODIFIED($ListView1)
         If $File1 = True Then
             loadfiles($var)
             Indexing()
        Else
             MsgBox(0,"Scanner Error!!!","Please select your pendrive")
        EndIf
         
EndSwitch
WEnd
_ReduceMemory()
Func loadfiles($folder)
$files = _FileListToArray3($folder, "*.*", 1, 1)
local $szIconFile1, $nIcon1=0,$ListViewItem[UBound($files)]
For $i = 1 To UBound($files) - 1
GUICtrlSetData($Label2,"Scanning : " &$files[$i]) 
$ListViewItem[$i]=GUICtrlCreateListViewItem($files[$i] & "|" & Round(FileGetSize($files[$i]) / 1024)&" Kb" & "|" & StringRight($files[$i], 3), $ListView1)
GUICtrlSetImage(-1, _FileGetIcon($folder&'\'&$files[$i]), 1)
Next

EndFunc;==>loadfiles

Func _FileGetIcon($szFile)
Local $arTemp,$sExt,$arPath
$arTemp = StringSplit($szFile,'.')
$sExt='.'&$arTemp[$arTemp[0]]
If StringLower($sExt) = '.exe' Then Return $szFile
$arPath = StringRegExp(RegRead("HKCR\"&RegRead("HKCR\"&$sExt,"")&"\shell\open\command",""),"(.*)(?i)exe",2)
If IsArray($arPath) Then
Return StringReplace($arPath[0],'"','')
Else
;unknown...
Return "shell32.dll"
EndIf
EndFunc;==>_FileGetIcon

Func ControlColor($ControlArray,$BkColor,$Color)
    For $Index = 0 To UBound($ControlArray)-1
        GUICtrlSetBkColor($ControlArray[$Index],$BkColor)
        GUICtrlSetColor($ControlArray[$Index],$Color)
    Next
EndFunc;==>ControlColor

Func Indexing()
    $list = IniReadSection($inipath,"treat")
    MsgBox (4160, "Information", "Item Scanned: " & _GUICtrlListView_GetItemCount ($ListView1) & " Files")
    Sleep(100)
EndFunc


Func _GUICtrlListView_DeleteAllItems_MODIFIED($hWnd)
    If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
    Local $ctrlID, $index
   
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
   
    If _GUICtrlListView_GetItemCount($hWnd) == 0 Then Return True

    Return _SendMessage($hWnd, $LVM_DELETEALLITEMS) <> 0
EndFunc;==>_GUICtrlListView_DeleteAllItems



Func _ReturnStringArraySearch(ByRef $n_Array, $f_FindString)
    For $i = 1 To UBound($n_Array) - 1
        If StringInStr($n_Array[$i], $f_FindString) Then Return $n_Array[$i]
    Next
EndFunc

This is my script...i want to add stop indexing button...i dont know how to create that function...

can you help me..???

That script works for you?

edit; can you post obfuscated version (/striponly parameter)?

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
komalo

ok this an idea ,

1 - create a global variable $stop and set it false

2 - create a function associated by a button to stop indexing

3 - modifie the indexing function to examine the stop variable

every time on indexing and if it find it is set to true

it put it to false and return nothing

if you want , i can help you creating those function

Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites
PsaltyDS

CODE
#include <GUIConstants.au3>

#include <File.au3>

#include <FileListToArray3.au3>

#include <GuiListView.au3>

#include <ReduceMemory.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\zainiafzan\Desktop\Au3it\Scan projek\Scanner.kxf

$Form1 = GUICreate("Gui", 417, 400, -1, -1)

GUISetBkColor(0x7A96DF)

$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\zainiafzan\Desktop\Au3it\Scan projek\scan pendrive.jpg", 0, 0, 416, 105, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Group1 = GUICtrlCreateGroup("Select Your Pendrive :", 8, 120, 401, 65)

$Input1 = GUICtrlCreateInput("", 16, 144, 305, 21, BitOR($ES_AUTOHSCROLL,$WS_BORDER))

$Button1 = GUICtrlCreateButton("Browse", 328, 141, 73, 25, 0)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$ListView1 = GUICtrlCreateListView("File|Size|Format", 8, 192, 401, 145, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_BORDER))

GUICtrlSendMsg(-1, 0x101E, 0, 150)

GUICtrlSendMsg(-1, 0x101E, 1, 100)

GUICtrlSendMsg(-1, 0x101E, 2, 100)

$Label2 = GUICtrlCreateLabel("Indexing : NONE", 8, 344, 295, 30)

GUICtrlSetColor(-1, 0xFFFFFF)

$Button2 = GUICtrlCreateButton("Start", 320, 344, 89, 25, 0)

GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")

$Pic2 = GUICtrlCreatePic("C:\Documents and Settings\zainiafzan\Desktop\Au3it\name.gif", 8, 376, 85, 15, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

GUICtrlSetCursor (-1, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

$inipath = @ScriptDir & "\Update.ini"

If FileExists($inipath) = 0 Then

MsgBox(0,"Update!!!","Please Indexing Your Pendrive")

EndIf

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

$var = FileSelectFolder("Choose a folder.", "")

$File = GUICtrlSetData($Input1,$var)

Case $Button2

GUICtrlSetData($Label2,"Scanning : Getting Collection...")

$File1 = GUICtrlRead($Input1)

_GUICtrlListView_DeleteAllItems_MODIFIED($ListView1)

If $File1 = True Then

loadfiles($var)

Indexing()

Else

MsgBox(0,"Scanner Error!!!","Please select your pendrive")

EndIf

EndSwitch

WEnd

_ReduceMemory()

Func loadfiles($folder)

$files = _FileListToArray3($folder, "*.*", 1, 1)

local $szIconFile1, $nIcon1=0,$ListViewItem[uBound($files)]

For $i = 1 To UBound($files) - 1

GUICtrlSetData($Label2,"Scanning : " &$files[$i])

$ListViewItem[$i]=GUICtrlCreateListViewItem($files[$i] & "|" & Round(FileGetSize($files[$i]) / 1024)&" Kb" & "|" & StringRight($files[$i], 3), $ListView1)

GUICtrlSetImage(-1, _FileGetIcon($folder&'\'&$files[$i]), 1)

Next

EndFunc;==>loadfiles

Func _FileGetIcon($szFile)

Local $arTemp,$sExt,$arPath

$arTemp = StringSplit($szFile,'.')

$sExt='.'&$arTemp[$arTemp[0]]

If StringLower($sExt) = '.exe' Then Return $szFile

$arPath = StringRegExp(RegRead("HKCR\"&RegRead("HKCR\"&$sExt,"")&"\shell\open\command",""),"(.*)(?i)exe",2)

If IsArray($arPath) Then

Return StringReplace($arPath[0],'"','')

Else

;unknown...

Return "shell32.dll"

EndIf

EndFunc;==>_FileGetIcon

Func ControlColor($ControlArray,$BkColor,$Color)

For $Index = 0 To UBound($ControlArray)-1

GUICtrlSetBkColor($ControlArray[$Index],$BkColor)

GUICtrlSetColor($ControlArray[$Index],$Color)

Next

EndFunc;==>ControlColor

Func Indexing()

$list = IniReadSection($inipath,"treat")

MsgBox (4160, "Information", "Item Scanned: " & _GUICtrlListView_GetItemCount ($ListView1) & " Files")

Sleep(100)

EndFunc

Func _GUICtrlListView_DeleteAllItems_MODIFIED($hWnd)

If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)

Local $ctrlID, $index

If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

If _GUICtrlListView_GetItemCount($hWnd) == 0 Then Return True

Return _SendMessage($hWnd, $LVM_DELETEALLITEMS) <> 0

EndFunc ;==>_GUICtrlListView_DeleteAllItems

Func _ReturnStringArraySearch(ByRef $n_Array, $f_FindString)

For $i = 1 To UBound($n_Array) - 1

If StringInStr($n_Array[$i], $f_FindString) Then Return $n_Array[$i]

Next

EndFunc

This is my script...i want to add stop indexing button...i dont know how to create that function...

can you help me..???

The problem is that once you leave the message loop to run the requested function, the message loop is not checking buttons like "STOP" anymore. The best way to do that kind of thing is to change the GUI to event mode. Then the GUI controls can interrupt the functions.

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×