The MASM Forum Archive 2004 to 2012

Project Support Forums => IDE Development and Support => Easy Code => Topic started by: Ryo on September 16, 2009, 09:04:56 AM

Title: Help with loop
Post by: Ryo on September 16, 2009, 09:04:56 AM
I made this program that sends a packet to a client with packet.dll, but i cant get it to loop infinite. This code loops it 100 times, but the program freezes meanwhile the loop is on.
I want it to loop every 50ms when the button is checked, and stop loop when the button is unchecked. (without crashing..)

Anyone?

.If Ax == IDC_WINMAIN_CHKLOOTGOLD
HiWord wParam
.If Ax == BN_CLICKED
          Invoke GetWindowItem, hWnd, IDC_WINMAIN_CHKLOOTGOLD
          Invoke SendMessage, Eax, BM_GETCHECK, 0, 0
.If Eax
Invoke LoadLibrary, Addr LibName
Mov PacketLibrary, Eax
Invoke GetProcAddress, PacketLibrary, Addr FunctionName
Mov SendPacket, Eax
Invoke FindWindow, Addr ClientName, NULL
Invoke GetWindowThreadProcessId, Eax, Addr ProcessID
        Mov Timer, 0
.While Timer < 100
Inc Timer
Push NULL                   ; i want this to loop until the sleep
Push TRUE
Push Offset LootGold
Push ProcessID
Call [SendPacket]
Invoke Sleep, 50
.EndW
.Else
Invoke FreeLibrary, PacketLibrary
.EndIf
;Returns TRUE for no further processing
Return TRUE
.EndIf
         .EndIf
Title: Re: Help with loop
Post by: Ramon Sala on September 16, 2009, 11:25:20 AM
Hi Ryo,

I can see an .EndW sentence in your code, but I cannot see where the loop begins (the  .While sentence). Would you mind posting the whole project please?

On the other hand, you must take the following into account:

HiWord wParam
.If Ax == BN_CLICKED
    ...
    ...
    ...
.EndIf


This code will be processed for any object sending the BN_CLICKED notification (check box, option, etc.). For restricting this code to just a button click (or check or radio,...), you first have to check the object sending the notification by comparing the low word of wParam with its IDentifier. That is:

LoWord wParam
.If Ax == IDC_WINDOW1_CHECK1     ;If the check box is named Check1 and the window is named Window1
    HiWord wParam
    .If Ax == BN_CLICKED
        ...
        ...
        ...
        Return TRUE
    .EndIf
.EndIf



Please post or send me the whole project.

Ramon
Title: Re: Help with loop
Post by: Ryo on September 16, 2009, 01:14:53 PM
sent you a message
Title: Re: Help with loop
Post by: ragdog on September 19, 2009, 06:33:22 AM
Hi

Yes this freez the dialog you must work with  Thread (CreateThread)
this Slepp function freez this




greets
ragdog