Jump to content

AdlibRegister including Sleep


Recommended Posts

Hi , is there a way to make sleep in adlibregister function but without pausing the script ?

when using something like this only 123 gonna be displayed ...

 

AdlibRegister("Check",500)

Func check()
    ConsoleWrite("1")
    Sleep(500)
    ConsoleWrite("2")
    Sleep(500)
    ConsoleWrite("3")
    Sleep(500)
EndFunc

while 1
    Sleep(500)
    ConsoleWrite("NOT")
WEnd


I wish if u understand me and thanks :)

Link to comment
Share on other sites

  • Developers
11 minutes ago, NewUser12 said:

Hi , is there a way to make sleep in adlibregister function but without pausing the script ?

Not in the same script as it is a single thread. This would require a seconds instance of the script.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

So when you want to have a specific function running in parallel with you main function, your only option is to shell a second script and communicate with it via a form of messaging to make it do what it needs to do. There are examples enough how this can be done.

Search for WM_COPYDATA to find examples.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Well i see that autoit doesn't support that right ?
Also i wanted to ask another question iam getting from ini files likes 5k lines and i have an progressbar is there a way to make the progressbar works in background while the listview is getting information from the ini files and both ends together ?

Link to comment
Share on other sites

  • Developers

Not sure I understand the question: Isn't this simply a matter of updating the processbar in the part that populates the listview?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Iam getting informations like this :
 

Func _Load()
$readsectionnames = _IniReadSectionNamesEx("file.txt")

GUICtrlSetData($Labelofloading,"1 %")
For $i = 1 to $readsectionnames[0]
 _GUICtrlListView_AddItem($ListView1,$readsectionnames[$i])
Next

For $i = 1 to 20
    Sleep(100)
GUICtrlSetData($Labelofloading,$i&" %")
Next

For $i = 1 to $readsectionnames[0]
$Case = IniRead("file.txt",$readsectionnames[$i],"Case","")
_GUICtrlListView_AddSubItem($ListView1,$i,$Case,1,1)
Next

For $i = 21 to 40
    Sleep(100)
GUICtrlSetData($Labelofloading,$i&" %")
Next

For $i = 1 to $readsectionnames[0]
$Code = iniread("file.txt",$readsectionnames[$i],"Code","")
_GUICtrlListView_AddSubItem($ListView1,$i,$Code,2,2)
Next

For $i = 41 to 50
    Sleep(100)
GUICtrlSetData($Labelofloading,$i&" %")
Next

For $i = 1 to $readsectionnames[0]
$Dateofbuying = iniread("file.txt",$readsectionnames[$i],"Date of buying","")
_GUICtrlListView_AddSubItem($ListView1,$i,$Dateofbuying,3,3)
Next

;;etc
endfunc

but actually i didn't like the fake progressbar for example like the $labelofloading i did i wanted it to work in background idk how xd

Link to comment
Share on other sites

  • Developers

Can't you simply start a progressbar and update the with each loop and use a single loop?
Something like this: (Untested)

Func _Load()
    ; Display a progress bar window.
    ProgressOn("Loading Progress", "getting data", "0%")
    ; Set the "subtext" and "maintext" of the progress bar window.
    $readsectionnames = _IniReadSectionNamesEx("file.txt")
    
    GUICtrlSetData($Labelofloading, "1 %")
    For $i = 1 To $readsectionnames[0]
        ProgressSet($i*100/$readsectionnames[0], $i & "%")
        _GUICtrlListView_AddItem($ListView1, $readsectionnames[$i])
        Sleep(100)
        GUICtrlSetData($Labelofloading, $i & " %")
        $Case = IniRead("file.txt", $readsectionnames[$i], "Case", "")
        _GUICtrlListView_AddSubItem($ListView1, $i, $Case, 1, 1)
        Sleep(100)
        GUICtrlSetData($Labelofloading, $i & " %")
        $Code = IniRead("file.txt", $readsectionnames[$i], "Code", "")
        _GUICtrlListView_AddSubItem($ListView1, $i, $Code, 2, 2)
        Sleep(100)
        GUICtrlSetData($Labelofloading, $i & " %")
        $Dateofbuying = IniRead("file.txt", $readsectionnames[$i], "Date of buying", "")
        _GUICtrlListView_AddSubItem($ListView1, $i, $Dateofbuying, 3, 3)
    Next
    ProgressOff()

    ;;etc
EndFunc   ;==>_Load

 

Edited by Jos
fixed typo

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

3 minutes ago, Jos said:

Can't you simply start a progressbar and update the with each loop and use a single loop?
Something like this: (Untested)

Func _Load()
    ; Display a progress bar window.
    ProgressOn("Loading Progress", "getting data", "0%")
    ; Set the "subtext" and "maintext" of the progress bar window.
    $readsectionnames = _IniReadSectionNamesEx("file.txt")
    
    GUICtrlSetData($Labelofloading, "1 %")
    For $i = 1 To $readsectionnames[0]
        ProgressSet($i+100/$readsectionnames[0], $i & "%")
        _GUICtrlListView_AddItem($ListView1, $readsectionnames[$i])
        Sleep(100)
        GUICtrlSetData($Labelofloading, $i & " %")
        $Case = IniRead("file.txt", $readsectionnames[$i], "Case", "")
        _GUICtrlListView_AddSubItem($ListView1, $i, $Case, 1, 1)
        Sleep(100)
        GUICtrlSetData($Labelofloading, $i & " %")
        $Code = IniRead("file.txt", $readsectionnames[$i], "Code", "")
        _GUICtrlListView_AddSubItem($ListView1, $i, $Code, 2, 2)
        Sleep(100)
        GUICtrlSetData($Labelofloading, $i & " %")
        $Dateofbuying = IniRead("file.txt", $readsectionnames[$i], "Date of buying", "")
        _GUICtrlListView_AddSubItem($ListView1, $i, $Dateofbuying, 3, 3)
    Next
    ProgressOff()

    ;;etc
EndFunc   ;==>_Load

 

Good example for me. Thank you

Link to comment
Share on other sites

  • Developers

I see I made at least one  typo in the code: + should be *

ProgressSet($i*100/$readsectionnames[0], $i & "%")

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
3 minutes ago, NewUser12 said:

Sorry this is my last question hahaha 

Somehow doubt that ... and there is no issue to ask questions.

3 minutes ago, NewUser12 said:

How to learn all the syntax in autoit ? what's the best way.

  1. F1 /Search
  2. Read
  3. Think
  4. Try
  5. Goto 1

Jos :)

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Yes, that is how I learned this language back in 2004 (i think), but have been programming since 1978 in various languages of which one is Basic, which is somewhat similar to AutoIt3.
To me learning any language is initially investing in learning the words (Functions etc)  and grammar (Syntax) and then putting them together into sentences (Scripts). 
I do realize it isn't always easy for everybody to have the discipline and patience, but to me it's the only way to properly learn.

As to your last post (to make a link to the first part of this PM): did you try to goggle it? One of the first hits I got was this one
It is in general fair to assume you aren't the first one asking the questions and likely somebody already shared the answer somewhere on the internet so always try and search for the answer yourself. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I searched a lot for that the sizes that in the registry files doesn't work correctly and it just changes when restarting pc so i would like to ask if there's another way to - minus the desktopheight from the taskbar size to get the gui full screen resolution

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