johnmcloud Posted March 13, 2012 Posted March 13, 2012 (edited) Hi guys, i have this script: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Misc.au3> Opt("GUICloseOnESC", 1) Global $GUI_1 $GUIHeight = 25 $GUIWidth = 50 $GUI_1 = GUICreate("A", $GUIWidth, $GUIHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW) $Focus_GUI_1 = GUICtrlCreateLabel("", 0, 0, $GUIWidth, $GUIHeight) GUISetState() Global_Func() Func Global_Func() While 1 If _IsPressed(01) Then If WinGetTitle("A") = True Then $GUI_Pos_1 = GUIGetCursorInfo($GUI_1) If IsArray($GUI_Pos_1) Then If $GUI_Pos_1[4] = $Focus_GUI_1 Then MsgBox(0, 0, "click") EndIf EndIf EndIf EndIf WEnd EndFunc ;==>Global_Func Work, but work everytime, also if a window/software/whatever is on it, so it's a problem for me. How to make _IsPressed work only if the GUI is Active or Focus? Thanks for help Edited March 13, 2012 by johnmcloud
martin Posted March 13, 2012 Posted March 13, 2012 If you omit the parameter from GuiGetCursorInfo then @error is 1if your gui is not active, so you don't need _IsPressed or "If WInGetTitle.." 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.
somdcomputerguy Posted March 13, 2012 Posted March 13, 2012 Or the WinGetState() function could be used somehow.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
johnmcloud Posted March 13, 2012 Author Posted March 13, 2012 Thanks for answer. I need _IsPressed, i want to check with a click if the GUI is active or not. For the @error and WinGetState, can you guys post an example? Thanks
somdcomputerguy Posted March 14, 2012 Posted March 14, 2012 If IsVisible("A") Then MsgBox(0, '', 'Yay!') Func IsVisible($handle) If BitAND(WinGetState($handle), 15) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisibleSee WinGetState to learn how I came up with 15. You might need another combination there. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
johnmcloud Posted March 14, 2012 Author Posted March 14, 2012 (edited) I have tested the WinGetState, but... Like this work: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Misc.au3> Opt("GUICloseOnESC", 1) Global $GUI_1 $GUIHeight = 250 $GUIWidth = 500 $GUI_1 = GUICreate("A", $GUIWidth, $GUIHeight, 0, 0) $Focus_GUI_1 = GUICtrlCreateLabel("", 0, 0, $GUIWidth, $GUIHeight) GUISetState() Global_Func() Func Global_Func() While 1 If IsVisible("A") Then If _IsPressed(01) Then $GUI_Pos_1 = GUIGetCursorInfo($GUI_1) If IsArray($GUI_Pos_1) Then If $GUI_Pos_1[4] = $Focus_GUI_1 Then MsgBox(0, 0, "click") EndIf EndIf EndIf EndIf WEnd EndFunc ;==>Global_Func Func IsVisible($handle) If BitAND(WinGetState($handle), 8) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible But if i make the GUI with $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW not: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Misc.au3> Opt("GUICloseOnESC", 1) Global $GUI_1 $GUIHeight = 250 $GUIWidth = 500 $GUI_1 = GUICreate("A", $GUIWidth, $GUIHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW) $Focus_GUI_1 = GUICtrlCreateLabel("", 0, 0, $GUIWidth, $GUIHeight) GUISetState() Global_Func() Func Global_Func() While 1 If IsVisible("A") Then If _IsPressed(01) Then $GUI_Pos_1 = GUIGetCursorInfo($GUI_1) If IsArray($GUI_Pos_1) Then If $GUI_Pos_1[4] = $Focus_GUI_1 Then MsgBox(0, 0, "click") EndIf EndIf EndIf EndIf WEnd EndFunc ;==>Global_Func Func IsVisible($handle) If BitAND(WinGetState($handle), 8) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible What is wrong? Thanks Edited March 14, 2012 by johnmcloud
johnmcloud Posted March 14, 2012 Author Posted March 14, 2012 I have removed _IsPressed, but work everytime $GUI_Pos = GUIGetCursorInfo($GUI_1) If IsArray($GUI_Pos) Then If $GUI_Pos[2] = 1 And $GUI_Pos[4] = $Focus_GUI_1 Then MsgBox(0, 0, "click") EndIf EndIf Please a little help
johnmcloud Posted March 14, 2012 Author Posted March 14, 2012 (edited) Seem nothing work with combination of $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_LAYERED... I have try to change approach with: 1) Label like a button --> fail if GUI has $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_LAYERED 2) $GUI_EVENT_PRIMARYUP --> fail if GUI has $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_LAYERED 3) GUIGetCursorInfo --> Work everytime also if GUI is hide by another window/software #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> $GUI_1 = GUICreate("Form1", 800, 600, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_LAYERED) $Test = GUICtrlCreateLabel("",800, 600, 0, 0) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_PRIMARYUP MsgBox(0, 'Title', 'Text') Case $GUI_EVENT_CLOSE Exit Case $Test MsgBox(0, 'Title', 'Text') EndSwitch WEnd I really ran out of ideas... Wait for some volunteers Edited March 14, 2012 by johnmcloud
BrewManNH Posted March 14, 2012 Posted March 14, 2012 Your label's parameters are mixed up see the code below for the fix. I also got rid of the msgbox functions and used consolewrite instead because the MsgBox wasn't letting the script see the PrimaryUp. #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> $GUI_1 = GUICreate("Form1", 800, 600, -1, -1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED));<<<<<<< BTW, this will create an invisible GUI/Label $Test = GUICtrlCreateLabel("THIS IS A TEST LABEL", 0, 0, 800, 600) ; <<<<<<<<<<<<< You had the size set to 0,0 and the location set to 800,600 GUISetState() While 1 Switch GUIGetMsg() Case $Test ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Test = ' & $Test & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Case $GUI_EVENT_PRIMARYUP ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $GUI_EVENT_PRIMARYUP = ' & $GUI_EVENT_PRIMARYUP & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 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 GudeHow 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
johnmcloud Posted March 14, 2012 Author Posted March 14, 2012 (edited) BrewManNH work only if i remove the $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED) I know the GUI is invisible , the object is have an invisible GUI + invisible Label like button with two method ( on click and on mouse hover ) No response by Console, i have try to click everyware but nothing Edited March 14, 2012 by johnmcloud
BrewManNH Posted March 14, 2012 Posted March 14, 2012 Are you running this from SciTE? Because when I do, it works everytime I click the window where the GUI should be, I get a consolewrite for $Test and then another for $GUI_EVENT_PRIMARYUP right after it. 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 GudeHow 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
johnmcloud Posted March 14, 2012 Author Posted March 14, 2012 Sure, from Scite, click on F5 and click everywere ( on VM the resolution is 800x600, so whatever i click i need to see some response from console ) but nothing. My version is 3.3.8.0
BrewManNH Posted March 14, 2012 Posted March 14, 2012 Are you running the script on the VM? 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 GudeHow 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
johnmcloud Posted March 14, 2012 Author Posted March 14, 2012 (edited) Yeah, it's a problem? From here i can do only on a VM, but every script tested working fine. I have change ConsoleWrite with MsgBox, nothing change, no messages. Work only if i remove the exStyle Edited March 14, 2012 by johnmcloud
BrewManNH Posted March 14, 2012 Posted March 14, 2012 Try running it without the extended style parameters so that you can see if the label is there and you can then click on it to see if it's working. I haven't done any scripting on a VM but I don't see why it wouldn't work. 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 GudeHow 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
johnmcloud Posted March 14, 2012 Author Posted March 14, 2012 (edited) Without the extended style work, also my script posted before work, but i need with extended style P.S I'm on XP SP3 @@ Debug(14) : $Test = 3 >Error code: 0 @@ Debug(16) : $GUI_EVENT_PRIMARYUP = -8 >Error code: 0 EDIT: Take a look to post #6, same problem. Maybe a bug? Or this combination of extended style not work on XP? I really don't know...However, my first script post on #1 work, but work also if another window is on it like TOPMOST attribute. Edited March 14, 2012 by johnmcloud
johnmcloud Posted March 15, 2012 Author Posted March 15, 2012 No idea? It's so impossible to click on a label of a invisible GUI?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now