Sign in to follow this  
Followers 0
Rad

Quick thing about using GUISetOnEvent mode

7 posts in this topic

If im using GUISetOnEventMode, how do I detect when someone pressed the mouse down? and releases it? prefferably without using ispressed method because usually that gets unstable with my mouse (hard to explain lol)

And, how can i detect when you click on the background on the window? This is so that i can move it around as I disable its normal border

Share this post


Link to post
Share on other sites



For question one pressed the mouse down. You can use:

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_DoFunction", $wMain)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "_DoFunction", $wMain)
GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_DoFunction", $wMain)
GUISetOnEvent($GUI_EVENT_SECONDARYUP, "_DoFunction", $wMain)
and for the second question how can i detect when you click on the background I will need to see some of the script to be able to help you.

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

it's a GUI event .. theres no GUI ..

While1 should be While 1

There's no sleep(10) in between While 1 and Wend

and so on..

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
GUICreate('')
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "test")
GUISetState()

While 1
Sleep(10)
Wend

Func Test()
    msgbox(0,"","test")
    Exit
EndFunc

I learn something new every moment , I didn't realise a function name wasn't case sensitive.

"test"

Test()

lol

Edited by smashly

Share this post


Link to post
Share on other sites

i dont think anything in autoit is case sensitive... up to handling strings and probrably some more advanced stuff I havent messed with

And AFAIK you dont need the sleep(10), none of my scripts ever had it.. it just makes things buggier for me

I got it to work though, turns out I had a function in my infinite loop that was running, that didnt do anything... somehow that caused it to not fire the function every time (it worked if u double clicked for some reason)

I already had the window to btw, my script was just long so i didnt include it all

Share this post


Link to post
Share on other sites

And AFAIK you dont need the sleep(10), none of my scripts ever had it.. it just makes things buggier for me

When you have a loop then AutoIt will try to go thru the loop as fast as possible. This puts

the CPU-usage to over 90% on my computer, but by adding a tiny Sleep() it's lowered to 0%.

It's rare that I have the need to dedicate almost the entire CPU to a script, so therefor I use

Sleep()'s in loops all the time.

Share this post


Link to post
Share on other sites

It does that for me to... but it doesnt effect the performance of anything. The CPU usage isnt very reliable except when your finding a virus or a program that froze etc

But I guess i will put it in there so people wont freak out

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