Jump to content
algiuxas

Dragging GUI makes script pause

Recommended Posts

algiuxas

Hello,

When I move GUI, script pause until I release GUI.

I need to make script not pause while dragging GUI.
 

GUICreate("Hello world!",250,175,-1,-1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent(-3, "exit_") ; Check if closed
GUISetState()

While 1
    ToolTip("This tooltip should move.")
    Sleep(50)
WEnd

Func exit_()
    GUIDelete()
    Exit
EndFunc

 

Edited by algiuxas

42783.png

Share this post


Link to post
Share on other sites
JLogan3o13

@algiuxas we can't offer much in the way of help when you don't include any of your code. Obviously, we have many GUI scripts on this forum, and they aren't all freezing when dragged, so there is something going on in your script specifically. Rather than having us consult our crystal ball, how about posting your code? ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
algiuxas
30 minutes ago, JLogan3o13 said:

@algiuxas we can't offer much in the way of help when you don't include any of your code. Obviously, we have many GUI scripts on this forum, and they aren't all freezing when dragged, so there is something going on in your script specifically. Rather than having us consult our crystal ball, how about posting your code? ;)

GUICreate("Hello world!",250,175,-1,-1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent(-3, "exit_") ; if closed, exit.
GUISetState()

While 1
    ToolTip("This tooltip should move.")
    Sleep(50)
WEnd

Func exit_()
    GUIDelete()
    Exit
EndFunc

I wrote this right now, and it still haves the same problem, script pauses while moving GUI.
I mean that it pauses, I didn't mean that it crashes, exits or etc., sorry.

Edited by algiuxas

42783.png

Share this post


Link to post
Share on other sites
UEZ

Try this:

#Include <Timers.au3>
#include <WindowsConstants.au3>

Global $hGUI = GUICreate("Hello world!",250,175,-1,-1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent(-3, "exit_") ; Check if closed
GUISetState()

Global $iMs = 30
GUIRegisterMsg($WM_TIMER, "_Interrupt")
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iMs, "int", 0)


While 1
    Sleep(50)
WEnd

Func exit_()
    GUIRegisterMsg($WM_TIMER, "")
    GUIDelete()
    Exit
EndFunc

Func _Interrupt()
    ToolTip("This tooltip should move.")
EndFunc

 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
algiuxas
1 minute ago, UEZ said:

Try this:

#Include <Timers.au3>
#include <WindowsConstants.au3>

Global $hGUI = GUICreate("Hello world!",250,175,-1,-1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent(-3, "exit_") ; Check if closed
GUISetState()

Global $iMs = 30
GUIRegisterMsg($WM_TIMER, "_Interrupt")
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iMs, "int", 0)


While 1
    Sleep(50)
WEnd

Func exit_()
    GUIRegisterMsg($WM_TIMER, "")
    GUIDelete()
    Exit
EndFunc

Func _Interrupt()
    ToolTip("This tooltip should move.")
EndFunc

 

Thanks,
but this loop took about 40 milisecounds, is there a way to make it faster, like in a normal loop(0.01ms)?
:)


42783.png

Share this post


Link to post
Share on other sites
BrewManNH

Actually, with a 50ms sleep in there it takes at least 50ms. You can't use a sleep value under 10ms, sleep won't go lower.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
algiuxas
Just now, BrewManNH said:

Actually, with a 50ms sleep in there it takes at least 50ms. You can't use a sleep value under 10ms, sleep won't go lower.

I tested it without sleep :)


42783.png

Share this post


Link to post
Share on other sites
UEZ

FYI: The function _Interrupt() is called every 30 ms.

Global $iMs = 30

 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
algiuxas
Just now, UEZ said:

FYI: The function _Interrupt() is called every 30 ms.

Thank you, didn't saw that. :)


42783.png

Share this post


Link to post
Share on other sites
algiuxas

I found a problem - if it's a big script or it took long to execute it, it will pause anyway.

Edited by algiuxas

42783.png

Share this post


Link to post
Share on other sites
algiuxas

This doesn't work...
 

#Include <Timers.au3>
#include <WindowsConstants.au3>

Global $hGUI = GUICreate("Hello world!",250,175,-1,-1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent(-3, "exit_") ; Check if closed
GUISetState()
Global $t = TimerInit()
Global $iMs = 0
GUIRegisterMsg($WM_TIMER, "_Interrupt")
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iMs, "int", 0)


While 1
ToolTip("h")
WEnd

Func exit_()
    GUIRegisterMsg($WM_TIMER, "")
    GUIDelete()
    Exit
EndFunc

Func _Interrupt()
    ToolTip(TimerDiff($t)&@CRLF)
    sleep(Random(50,1000,1)
    $t = TimerInit()
EndFunc

I need another way to avoid pausing the script while moving/resizing GUI,

because I'm not sure how much time will one loop took.

Edited by algiuxas

42783.png

Share this post


Link to post
Share on other sites
UEZ

I think you don't have understand the timer functionality.

The script will interrupt the execution every 30ms to call the _Interrupt(). When you put a sleep within that function the functionality of the timer will get obsolete.

 

You have to put the code which should run in any case to the _Interrupt() function. I don't know what is not working in your big script.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Leo1906
On 19.7.2016 at 11:14 PM, UEZ said:

The script will interrupt the execution every 30ms to call the _Interrupt(). When you put a sleep within that function the functionality of the timer will get obsolete.

If it interrupts the script execution .. what is the difference to Adlib? Why not just register the function as adlib?

 

On 19.7.2016 at 10:28 PM, BrewManNH said:

Actually, with a 50ms sleep in there it takes at least 50ms. You can't use a sleep value under 10ms, sleep won't go lower.

Isn't Sleep(1) a possibillity and below 10 ms?
i thought I read so

Share this post


Link to post
Share on other sites
UEZ
26 minutes ago, Leo1906 said:

f it interrupts the script execution .. what is the difference to Adlib? Why not just register the function as adlib?

Adlib doesn't let continue the script on GUI move.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Leo1906
1 minute ago, UEZ said:

Adlib doesn't let continue the script on GUI move.

Ok thank you for the explanation :)
Learned something new :D

Share this post


Link to post
Share on other sites
AutoBert
9 hours ago, Leo1906 said:

Isn't Sleep(1) a possibillity and below 10 ms?
i thought I read so

it's below 10 but the shortest possible sleep is 10 so sleep(1), sleep(5) and sleep(10) will effect the same.

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

  • Similar Content

    • Reziskonh
      By Reziskonh
      Hi, everybody
      I look for GUI whose behavior similar to the message of an email client or antivirus
      In other words:
          Any PC screen able to calculate the size
          To consider the Task bar size
          To find the lower corner on the right/below and to nestle on it

      Notes:
      In GUI the GUICtrlCreateEdit field (as option) - that can be received and displayed through variable information
      Thanks a lot
      PS
      I use the translator, excuse if something is not clear
       

    • VollachR
      By VollachR
      Hi,
      I'd like to show a progress bar for an operation performed by an external program my script is running silently, I want to show it in a GUI I created using the GUICtrlCreateProgress but I have no idea how to do it.
      The important thing to point out is that there's no way of knowing how long the external program will run, as it is a file splitter and it depends on the size of file it splits and the split parts size.
      Can someone point me in the right direction or give me an example how to do so?
      This is my RunWait command:
      RunWait($MYFILES1 & '\fsplit.exe -split ' & $Size & ' mb ' & $File & " -f " & $File & "." & $extension) It uses multiple variables declared and set earlier in the script, how will I got about having the progress of that command shown using GUICtrlCreateProgress ? Is it possible?
      Thank you.
    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I have an inquiry and I hope to find the answer here
      I want to create a graphical user interface
      but I want to hide the system menu
      I mean the window menu
      Is this possible?
      If is possible please give me how to do that
      Thanks in advance
    • helmar
      By helmar
      I was playing around with simple GUI creation.  I tend to like parameter driven coding (in prior life (years ago) as Clipper/FoxPro/dBase coder).  Just wanted to see what I could do with a GUI.
      #Region options, includes Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode #include <GUIConstantsEx.au3> #EndRegion options, includes Global Const $nCols = 2, $nRows = 6, $nSpacer = 10, $nBtnWidth = 150, $nBtnHeight = 30 Global $xName = 0, $xID = 0 Global $nGUIWidth = ($nCols * $nBtnWidth) + (($nCols + 1) * $nSpacer) Global $nGUIHeight = ($nRows * $nBtnHeight) + (($nRows + 1) * $nSpacer) Global $hMainGUI = GUICreate("Calculated GUI", $nGUIWidth, $nGUIHeight, -1, -1) For $xRows = 1 to $nRows ;in this arrangement, tabbing is left to right, then next row For $xCols = 1 to $nCols ;reverse the order of this line with the prior line for top to bottom tabbing, then next col $xName += 1 $xID += 1 Global $Dummy = GUICtrlCreateButton("Button" & $xName, _ ($nBtnWidth * ($xCols - 1)) + (($xCols - 1) * $nSpacer) + $nSpacer, _ ($nBtnHeight* ($xRows - 1)) + (($xRows - 1) * $nSpacer) + $nSpacer, _ $nBtnWidth, _ $nBtnHeight) GUICtrlSetOnEvent($xID+2, "Handler") Next Next GUISetOnEvent($GUI_EVENT_CLOSE, "CloseApp") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func CloseApp() Exit EndFunc Func Handler() MsgBox(0,0,"Button " & @GUI_CtrlId - 2) EndFunc  
    • Gowrisankar
      By Gowrisankar
      Dear members,
      I'm trying to move unread mails from Inbox to a different folder using OutlookEx UDF.
      But its not working for me. I'm not sure what mistake I do.
      I get the error code 6 when the following is executed. From the UDF it is observed that  "No or an invalid item has been specified".
      Note : The UDF version is 1.3.3.1. AutoIt version (v3.3.14.2).
      #include <OutlookEX.au3> Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aOL_Item = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[UnRead]=True", "", "", "Subject", "", 1) If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Could not find a task item in folder 'Outlook-UDF-Test\SourceFolder\Tasks'. @error = " & @error) _ArrayDisplay($aOL_Item, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails") _OL_ItemMove($oOutlook, $aOL_Item[1][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Error moving specified task. @error = " & @error) Any help is deeply appreciated. Thanks in advance.
      Thanks and regards,
      Gowrisankar R.
×