Sign in to follow this  
Followers 0

GUI loop problem...Control freezing

9 posts in this topic

#1 ·  Posted

I'm having a problem, I've made a program callen LAN Talk, it's in example scripts in .exe form cause I haven't released the code yet, the problem I'm facing is:

When you run the script after it creates the GUI, the socket is created and a While loop receives the messages if $connected = 1, $connected is 0 until you press "Sign IN" and it returns to that state after you press "sign out".

What I want to do is, open the socket when you press sign in and close it when you press sign out, to do that, I have the messenger function that does all that being called when you press "sign in", so the While loop starts there. If I leave it like that the GUI closes after it starts because there is no loop to keep it open, so I add another loop to only sleep while $connected = 0.So the GUI stays open by that loop and when you press sign in it stays open by the other loop but all the controls stop working after you press "sign in", except from the Treeview that responds..

I can make an example but I would prefer to PM my source code to members interested in helping...


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites



#2 ·  Posted

Really can't help much without source... :P

Your doing the loop wrong somehow, the loop must include reactions for all controls, if they aren't in the loop... More specifically the loop your program is currently running through, your control will not react to input or any kind of alteration.

Share this post


Link to post
Share on other sites

#3 ·  Posted

it's like:

;code posted is just an example not a working one, there is no GUI

This works:

$connected = 0

somefunction()   ; creates GUI with button SIGN IN that sets $connected = 1 and SIGN OUT to set $connected = 0
Messenger()


Func Messenger
      $chatserver = UDPBind....
      If @error <> 0 Then
    SocketBindError(1)
      Else
          While 1
      If $Connected = 1 Then
                .............
                Sleep(10)
           WEnd
      EndIf
EndFunc

s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#4 ·  Posted

it's like:

;code posted is just an example not a working one, there is no GUI

This works:

$connected = 0

somefunction()   ; creates GUI with button SIGN IN that sets $connected = 1 and SIGN OUT to set $connected = 0
Messenger()


Func Messenger
      $chatserver = UDPBind....
      If @error <> 0 Then
    SocketBindError(1)
      Else
          While 1
      If $Connected = 1 Then
                .............
                Sleep(10)
           WEnd
      EndIf
EndFuncoÝ÷ ÛZµÚ²}ý·
++ºÚ"µÍÌÍØÛÛXÝYHÛÛYY[Ý[Û
HÈÜX]ÈÕRHÚ]]ÛÒQÓS]Ø[ÈÚ[Ú[[ÒQÓÕU]Ø[ÈÚYÛÝ]ÚYÛ[
BÚYÛÝ]

BÚ[H   ÌÍØÛÛXÝYHÛY
L
BÙ[[Ý[ÛÚYÛ[
B   ÌÍØÚ]ÙHQ[YÜ   ÉÝÈ[ÛØÚÙ][ÜJB[ÙB   ÌÍØÛÛXÝYHBYÜÙ[Ù
B[Y[[Â[ÈÚYÛÝ]

BÛÜÙÈÛØÚÙ]  ÌÍØÛÛXÝYH[[Â[ÈYÜÙ[ÙÚ[HBY    ÌÍÐÛÛXÝYHH[ÛY
L
BÑ[[[
The code you say works looks to me like it can't.

In the code that doesn't work how does the function Messenger() ever get finished? So how does singin() return?

Are you using message loop or event mode and have you set any hotkeys?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted

Looks like your going to need to re-write... You can't call a GUI through a function like that, and expect the secondary function to work properly... If the first hangs in GUI-loops... The other functions will never be called, although that would probably work if AutoIt supported multi-threaded operations, which it doesn't... :P

You will have to build your code around a better concept of loops. Again, without the source... It's hard to know exactly what your doing wrong... :unsure:

I'm not trying to ride you out about the source thing, but it's like trying to explain to someone why your brand-new Secret0 car is not running right, but you won't let anyone see it, instead you try and explain what noises it's making... :D

I'm terrible at metaphors, but still... PM me the source, and I'll try and give a better answer... :D

Share this post


Link to post
Share on other sites

#6 ·  Posted

martin, the first one does work, the messenger function is waiting until it receives something and wen it does it calls other function, it works pretty well the way it is. The only hotkey there is hides the main window and makes it appear again when you press it again...

Would you like to see my code martin and let me know?


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#8 ·  Posted

Hello Aceguy, the program woks fine on 15+ computers connected to the same LAN at once, I've tried it...There are some things I want to optimize however...


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#9 ·  Posted

I figured out a way to make it work and also changed a few things, you can download the new version here


s!mpL3 LAN Messenger

Current version 2.9.8.6 [04/11/2014]

Download Here

s!mpL3

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  
Followers 0