Sign in to follow this  
Followers 0
Apples292

How can i do GUIGetMsgDuringTimePeriod()

6 posts in this topic

Hi guys i've run into a bit of a problem...

i've got a script something like this

#include <GUIConstantsEx.au3>
$GUI = GUICreate("GUI", @DesktopWidth-40, @DesktopHeight, 20, 0)
$Button = GUICtrlCreateButton("Button", 20, 40 + @DesktopWidth/4, @DesktopWidth/16, @DesktopHeight/32)
GUISetState()
$TrueOrFalse = 0
While $TrueOrFalse = 0
   $msg = GUIGetMsg()
If $msg = $GUI_EVENT_PRIMARYDOWN Then
$TrueOrFalse = 1
EndIf
;...
;...
;...
;Big script that takes about half a second to do
;...
;...
;...
WEnd

What i want to do is to check whether "$msg = $GUI_EVENT_PRIMARYDOWN" at ANY point in the "Big script that takes about half a second to do" without having to put

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_PRIMARYDOWN Then

$TrueOrFalse = 1

EndIf

after every line, so something like this would be good (returns as array, but doesn't have to, anything would be great):

While $TrueOrFalse = 0

$Record = Start GUIMsgRecord()

;Big script that takes about half a second to do

End GUIMsgRecord($Record)

While 1 ;wouldn't be 1 in real thing is just loop for checking whether any array values = $GUI_EVENT_PRIMARYDOWN

If $Record[$Counter] = $GUI_EVENT_PRIMARYDOWN

$TrueOrFalse = 1

EndIf

WEnd

I know my current script is completely wrong but i can't find a alternative ;)

Any help is greatly apprectiated

Apples292

Share this post


Link to post
Share on other sites



maybe try this:

#include <GUIConstantsEx.au3>
$GUI = GUICreate("GUI", @DesktopWidth-40, @DesktopHeight, 20, 0)
$Button = GUICtrlCreateButton("Button", 20, 40 + @DesktopWidth/4, @DesktopWidth/16, @DesktopHeight/32)
GUISetState()
$TrueOrFalse = 0
While $TrueOrFalse = 0
   $msg = GUIGetMsg()
If $msg = $GUI_EVENT_PRIMARYDOWN Then
$TrueOrFalse = 1
EndIf
;...
Check()
;...
Check()
;...
;Big script that takes about half a second to do
;...
Check()
;...
Check()
;...
WEnd


Func Check()
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_PRIMARYDOWN Then
$TrueOrFalse = 1
EndIf
EndFunc

put in some of those after every signifigant event??

or you could just put it at the end. does it matter WHEN the $TrueOrFalse gets changed??

Share this post


Link to post
Share on other sites

I'm having a problem with putting it at the end because if you click while it's doing the big script it's not recorded...

True or false change can go anywhere in the while loop

And i was hoping to avoid putting checking for every significant event, so yeah i've reached a stale mate if those are the only ways to do it...

Thanks alot

Apples292

Share this post


Link to post
Share on other sites

You should consider using GuiOnEventMode.


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

I'd look at one of the Windows messages, perhaps WM_LBUTTONDOWN would be what you'd need.


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

You should consider using GuiOnEventMode.

Thanks!!! I worked this out in the end by giving up and doing something else, so i am looking at examples on autoit help file and i discovered it.

Thanks anyway because this is where i would i have looked after

Apples292

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