News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help with loop

Started by Ryo, September 16, 2009, 09:04:56 AM

Previous topic - Next topic

Ryo

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

Ramon Sala

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
Greetings from Catalonia

Ryo


ragdog

Hi

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




greets
ragdog