algiuxas

Dragging GUI makes script pause

16 posts in this topic

#1 ·  Posted (edited)

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



@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

#3 ·  Posted (edited)

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

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

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

#8 ·  Posted (edited)

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

#10 ·  Posted (edited)

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

#11 ·  Posted (edited)

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

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

    • IAMK
      By IAMK
      Hello,
       
      I have a script which uses a GUI with two buttons. It gets shown and hidden., and pressing the buttons (including their hotkeys) highlights the button, making you able to press enter the next time.
      However, I don't want that.
       
      I've tried using WinActivate() to make enter do things on another program, but the enter is still tied to the AutoIT GUI (which still has the button highlighted).
       
      Here's the important part of my code:
      $MY_GUI = GUICreate("Check.exe", 400, 300, ((@DesktopWidth / 2) - 200), -500) WinSetOnTop($MY_GUI, "", 1) ;Keeps the window on the top. $Button1 = GUICtrlCreateButton("Pass (Ctrl+P)", 40, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Fail (Ctrl+F)", 240, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $GUIText = GUICtrlCreateLabel("", 20, 10, 360, 230) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") GUICtrlSetData($GUIText, Execute($stepMessage[$step])) $showGUI = "True" GUISetState(@SW_SHOW) While($showGUI = "True") $buttonPressed = GUIGetMsg() Switch $buttonPressed Case $Button1 ;Pass $pass = "True" $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) Case $Button2 ;Fail $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) While($message = "") $message = InputBox("Check.exe", "Please enter the reason the step failed." & @CRLF, "", "", 300, 200, ((@DesktopWidth / 2) - 150), -400) WEnd Return $message EndSwitch WEnd Local $pass = "False" ;Whether "Pass" or "Fail" was pressed. Local $failLog = xxxfunc($pass) ;Returns a message to log if the step failed. ##THIS CALLS THE CODE SNIPPET ABOVE## FileWrite($file, _Now() & ": Step " & $step & getStatus($pass) & "and took " & Ceiling(TimerDiff($timer) / 1000) & " seconds." & @CRLF) If($failLog <> "") Then FileWrite($file, "Logged comment: " & $failLog & @CRLF) EndIf WinActivate("[TITLE:ProgramName]") ;Hotkeys: HotKeySet("^{p}", "pressPass") HotKeySet("^{f}", "pressFail") Func pressPass() $buttonPressed = $Button1 EndFunc Func pressFail() $buttonPressed = $Button2 EndFunc  
      The GUI's button/hotkey pressing works correctly.
      The same WinActivate code works in another script of mine.
      Together, WinActivate is not take "Active" away from the GUI's last-pressed button. How do I fix this?
       
      Thank you in advance.
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys this is my gui and i need the numeric value typed in the highlighted  inputbox. if this value is greater than 1 i need to perform some operations
      \
       
      Here is the summary about that field which i got from wininfo tool

      i tried writing the code as shown below.. but the msgbox is popping up empty value..when the same code is pasted under some button action i am able to access the value present in the field..but when placed alone as written in the attached script i am unable to fetch it... 

      here i am using the valu present in the field

      can you guys tell me what's wrong??? or how can i get that value?
       
      My_GUI.au3

    • Neonovaz
      By Neonovaz
      Hello
       
      Is there anyway to store word documents in Autoit GUI? For example I have a instruction sheet that I want to bundle up with the exe.

      So a user simply clicks the icon and the stored document will launch  (Something like how you can add objects like excel sheets in word documents )

      (I Know we can launch word files from script directory)

       
    • hemichallenger
      By hemichallenger
      Not sure if this is possible or if someone has already tackled this. Is it possible to embed PowerShell into a GUI? Autoit is great for quick function but sometime I need to run a command thru PowerShell. It be great to have PowerShell console embedded into the gui.