AutoIT Geek Posted November 27, 2005 Share Posted November 27, 2005 $Handle = WinGetHandle( WindowTitle ) MsgBox( 0, "Handle", $Handle ) MsgBox( 0, "int", IsInt( $Handle ) ) ; this one return 0 MsgBox( 0, "num", IsNumber( $Handle ) ) ; this one return 0 MsgBox( 0, "str", IsString( $Handle ) ) ; this one return 0 MsgBox( 0, "a", StringIsInt( $Handle ) ) ;but this return 1 in v3.1.1 and 0 in v3.1.1.90 MsgBox( 0, "b", StringIsXDigit( $Handle ) ) ; and this return 1 in v3.1.1 and 0 in v3.1.1.90 how autoit stores $Handle ? Link to comment Share on other sites More sharing options...
GaryFrost Posted November 27, 2005 Share Posted November 27, 2005 Might try IsHWnd SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
AutoIT Geek Posted November 27, 2005 Author Share Posted November 27, 2005 (edited) thanx, but i dont want to check if it an HWND, i just want to know how it is stored. i have this problem --------------------------------------------------- $Handle = GetWindowHandle( WindowTitle ) if $Handle == 0x00000000 do somthing <--- this give me LOTS of troubles, in v3.1.1 and v3.1.1.90 if $Handle == 0 do somthing <--- this give me LOTS of troubles too, in v3.1.1 and v3.1.1.90 if $Handle == Hex( 0, 8 ) do somthing <--- this works in v3.1.1 but not in v3.1.1.90 if Dec( $Handle ) == 0 do somthing <--- this somtimes works in v3.1.1 and in v3.1.1.90 --------------------------------------------------- so, how are handles stored in autoit ? Edited November 27, 2005 by AutoIT Geek Link to comment Share on other sites More sharing options...
w0uter Posted November 27, 2005 Share Posted November 27, 2005 its stored as 0x00000000 AFAIK My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
GaryFrost Posted November 27, 2005 Share Posted November 27, 2005 (edited) I think IsHWnd is what you'll need when using betafrom the help fileIsHWnd Checks if a variable's base type is HWND.IsHWnd ( variable ) Parametersvariable The variable/expression to check. Return ValueSuccess: Returns 1.Failure: Returns 0 if expression is not HWND type. Edited November 27, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Valik Posted November 28, 2005 Share Posted November 28, 2005 thanx, but i dont want to check if it an HWND, i just want to know how it is stored.Unimaginatively, it's stored as an HWND. Funny how that works, no? You would do well to actually listen to (read) the responses people are giving you. You've been told IsHWND() is the function you need when using the beta. Also, in another thread, I've told you that HWND's changed between versions 3.1.1.65 and 3.1.1.66 so obviously there is going to be a difference in behavior between versions of AutoIt prior to that and after that. In other words, put two and two together and try to come up with four this time. Link to comment Share on other sites More sharing options...
AutoIT Geek Posted November 28, 2005 Author Share Posted November 28, 2005 VALIK, you are a wiseass, DONT YOU ? did you understand the problem i posted ? " ==, Tests if two values are equal (case sensitive if used with strings)" $Handle = WinGetHandle( WindowTitle ) IF $Handle == 0 do somthing <-- this dont work IF $Handle == 00000000 do somthing <-- this dont work IF $Handle == 0x0 do somthing <-- this dont work IF $Handle == 0x00000000 do somthing <-- this dont work IF $Handle == "00000000" do somthing <-- this dont work IF $Handle == "0x00000000" do somthing <-- this dont work IF $Handle == Hex( 0, 8 ) do somthing <--- this works in v3.1.1 but not in v3.1.1.90 IF Dec( $Handle ) == 0 do somthing <--- this somtimes works in v3.1.1 and in v3.1.1.90 I DONT WANT TO KNOW IF A VARIANT IS AN "HWND" SINCE I USED A FUNCTION TO GET AN "HWND" --> WinGetHandle() IE, I DONT WANT TO USE IsHWND() CAN YOU UNDERSTAND THIS SIMPLE THING ?? NO ?? ?? your answer tells NOTHING to NO ONE --> HWNS IS HWND ---> AN APPLE IS AN APPLE since you can NOT read between the lines, i'll make it easier for YOU, what DATA TYPE is hwnd in auto it ? if it is different in LATEST betas, then IN WHAT FORM AUTOIT STORES IT ? A STRING ? --> "ABCDEFGH" OR "0x1234ABCD" A NUMBER ? --> 123 OR HEX 00000123 OR HEX 0x00000123 A DIFFERENT DATA TYPE ? IF YOU DONT UNDERSTAND THIS, DONT ANSWER ME, BUT DO ( IF YOU CAN ) SUPPLY THE SOURCE CODE FOR IsHWND() SO I CAN COMPARE IT TO WinGetHandle() AND SEE WHAT ARE THE DIFFRENCES. IF IM WRONG OR MISSING SOMTHING OR JUST PLAIN IDIOT ( which might be ), BE KIND YOU ALL MIGHTY DEVELOPER LORD, AND POINT ME TO MY MISTAKE, THANK YOU. Link to comment Share on other sites More sharing options...
LxP Posted November 28, 2005 Share Posted November 28, 2005 (edited) There is no need to post in all-caps. It is rude, annoying and immature. People have been very patient with you so far. $Handle = WinGetHandle( WindowTitle ) IF $Handle == 0 do somthing <-- this dont work IF $Handle == 00000000 do somthing <-- this dont work IF $Handle == 0x0 do somthing <-- this dont work IF $Handle == 0x00000000 do somthing <-- this dont work IF $Handle == "00000000" do somthing <-- this dont work IF $Handle == "0x00000000" do somthing <-- this dont workWhy on Earth are you comparing a handle to 0? If you want to know if WinGetHandle() was successful then check @Error: $Handle = WinGetHandle('My window') If @Error Then MsgBox(0x30, 'Error', 'Window not found.') what DATA TYPE is hwnd in auto it ? if it is different in LATEST betas, then IN WHAT FORM AUTOIT STORES IT ?In the latest betas, handles are stored in their own data type called HWnds. This is why an IsHWnd() function exists, just like IsNumber() and IsString() exist for numbers and strings. Perhaps the HWnd data type is similar to the number data type because an HWnd can be viewed as a number, but they are different. This has already been mentioned. If this doesn't answer your (very unclear) question then take a deep breath and try again. Give examples of code; explain what you're trying to achieve; show some more courtesy and we'll do our best to help you. Edited November 28, 2005 by LxP Link to comment Share on other sites More sharing options...
CyberSlug Posted November 28, 2005 Share Posted November 28, 2005 Could you give a complete code example that shows the issue? I'm not exactly sure what the problem is. In other words, it seems that there should already be a workaround for most HWND-related programming problems in AutoIt..... Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
AutoIT Geek Posted November 28, 2005 Author Share Posted November 28, 2005 @ERROR works only in internal AutoIT functions, i wrote some UDF's of my own to manipulate handles and that is why i check if handle is zero since handles are stored differently in autoit, i get errors in my code and that is why i want to know how handles are stored, in what form, so i can interface my code with that IsHWND() is an internal BOOLEAN autoit function which check an internal autoit data type in Win API, handles are represented as hex numbers of "unsigned int" in autoit, handles are not strings nor numbers,fine, so what are thay ? how are thay stored ? Link to comment Share on other sites More sharing options...
LxP Posted November 28, 2005 Share Posted November 28, 2005 $Handle = WinGetHandle( WindowTitle )IF $Handle == 0 do somthing <-- this dont workIF $Handle == 00000000 do somthing <-- this dont workIF $Handle == 0x0 do somthing <-- this dont workIF $Handle == 0x00000000 do somthing <-- this dont workIF $Handle == "00000000" do somthing <-- this dont workIF $Handle == "0x00000000" do somthing <-- this dont workYou are comparing $Handle to numbers and strings, neither of which are HWnds. That is why they don't evaluate to true.Perhaps you're looking for a way to write a hard-coded value in a script and have it treated as an HWnd. You would use the HWnd() function for this. I don't understand why you'd want to hard-code an HWnd value though, considering that they are volatile values.IF $Handle == Hex( 0, 8 ) do somthing <--- this works in v3.1.1 but not in v3.1.1.90In v3.1.1 handles were stored as plain numbers; in v3.1.1.90 they are not.IF Dec( $Handle ) == 0 do somthing <--- this somtimes works in v3.1.1 and in v3.1.1.90When WinGetHandle() fails, it returns an empty string. Dec('') gives 0. This is why this sometimes works -- it will work whenever a valid handle isn't returned by WinGetHandle().I hope I've been somewhat useful to you; don't break my heart now and flame me with all-caps. Link to comment Share on other sites More sharing options...
LxP Posted November 28, 2005 Share Posted November 28, 2005 (edited) @ERROR works only in internal AutoIT functions, i wrote some UDF's of my own to manipulate handlesand that is why i check if handle is zeroYou can write UDFs that set @Error. Please refer to SetError() in the help file.since handles are stored differently in autoit, i get errors in my code and that is why i want to know how handles are stored, in what form, so i can interface my code with thatPlease show a complete code segment as an example, otherwise no one will be able to help you.in autoit, handles are not strings nor numbers,fine, so what are thay ? how are thay stored ?I thought that this has been answered already but I'll try another approach.My guess is that internally they are stored as numbers, however they have an extra flag added to them that tells AutoIt not to treat them like a standard number, or to let the script see them as a standard number. As a non-developer I cannot tell you why things are done this way; as a heavy AutoIt scripter however, I can (and am more than happy to) tell you how to work around it if you supply me with the right information. Edited November 28, 2005 by LxP Link to comment Share on other sites More sharing options...
AutoIT Geek Posted November 28, 2005 Author Share Posted November 28, 2005 Sure, heres a code ----------------------------------------------------------------- $GW_CHILD = 5 $Result = DllCall( "USER32.DLL", "hwnd", "GetWindow", "hwnd", $Handle, "int", $GW_CHILD ) If $Result[ 0 ] == ( what ever i put here gives me crap ) ----------------------------------------------------------------- i want to check directly if i got a valid result, Link to comment Share on other sites More sharing options...
AutoIT Geek Posted November 28, 2005 Author Share Posted November 28, 2005 :"> :"> LxP, thankx, i already know well what are the dowsides of the function i use, i checked. NOT like VALIK, you do try to assist and pinpoint the problem Link to comment Share on other sites More sharing options...
LxP Posted November 28, 2005 Share Posted November 28, 2005 (edited) Okay, IsHWnd() is indeed useless for you because even if GetWindow returns NULL, AutoIt typecasts it to an HWnd because of the second argument to DLLCall().I am able to do this with no problems under v3.1.1.91:Local Const $GW_CHILD = 5 Local $Handle = WinGetHandle('Calculator') Local $Ret = DLLCall('User32', 'HWnd', 'GetWindow', 'HWnd', $Handle, 'Int', $GW_CHILD) MsgBox(0x40, 'Was a handle returned?', $Ret[0] <> 0); Displays True/1 or False/0This code also works for v3.1.1 if you change the first 'HWnd' in DLLCall() to 'Int'. (Edit: That's a lie; you don't need to change it.)I understand that you claimed to have problems with this in your first post; please try it again and let us know of any cases where the above code fails. Edited November 28, 2005 by LxP Link to comment Share on other sites More sharing options...
AutoIT Geek Posted November 28, 2005 Author Share Posted November 28, 2005 ------------------------- Local Const $GW_CHILD = 5 Local $Handle = WinGetHandle('Calculator') Local $Ret = DLLCall('User32', 'HWnd', 'GetWindow', 'HWnd', $Handle, 'Int', $GW_CHILD) MsgBox(0x40, 'Was a handle returned?', $Ret[0] <> 0); Displays True/1 or False/0 --------------------------- works in 3.1.1 EVEN if i dont change 'HWnd' to 'int' , BUT, since in autoit, handles are NOT numbers, and you check against a ZERO which IS a number, how can you do this ? Link to comment Share on other sites More sharing options...
LxP Posted November 28, 2005 Share Posted November 28, 2005 I suppose that since you are asking to compare it with a number (0), AutoIt is forced to also treat the HWnd as a number during the comparison. I can't really say any more than that as an end-user with no understanding of AutoIt's internals.I've just discovered that you can do this with the beta, which makes sense if you think about it:MsgBox(0x40, 'True = 0', True = 0) MsgBox(0x40, 'False = 0', False = 0) MsgBox(0x40, 'True = 1', True = 1) MsgBox(0x40, 'False = 1', False = 1)The help file states however that if you attempt to compare a string with a number, the string will be treated as 0. Link to comment Share on other sites More sharing options...
AutoIT Geek Posted November 28, 2005 Author Share Posted November 28, 2005 (edited) LxP, you brainstormed me, ok, hers a new discovery, maybe I AM an idiot or this is a flaw in AutoIT ---------------------------------------------------------------------------------- Local $Handle = WinGetHandle('Calculator') MsgBox( 0, '', $Handle ) <-- in 3.1.1 you get 1234ABCD, in 3.1.1.91 you get 0x1234ABCD now, copy the string you got and put it here insted of "040e0912" and run it again If $Handle == "040e0912" Then MsgBox( 0, "", "Lower Case" ) <-- this dont work If $Handle == "040E0912" Then MsgBox( 0, "", "Upper Case" ) <-- this works this suggests that handles are stored as strings, no ? now do this MsgBox( 0, '', IsString( $Handle ) ) <--- in both 3.1.1 and 3.1.1.9 you get 0, WTF ? now, if you close 'Calculator' and do this If $Handle == "" Then MsgBox( 0, "", "Empty String" ) this works -------------------------------------------------------------------------------------------- isnt this confusing ? Edited November 28, 2005 by AutoIT Geek Link to comment Share on other sites More sharing options...
LxP Posted November 28, 2005 Share Posted November 28, 2005 (edited) I'll try to explain what (I believe) is happening here. Local $Handle = WinGetHandle('Calculator')In v3.1.1, WinGetHandle() returns a string representing the handle (note that it uses uppercase letters when letters are needed). In v3.1.1.91, an actual HWnd data type is returned (which appears to really just be a number). Local $Handle = MsgBox( 0, '', $Handle ) <-- in 3.1.1 you get 1234ABCD, in 3.1.1.91 you get 0x1234ABCDHere AutoIt is being requested to display the content of the variable. For v3.1.1 this is a string, so there is no trouble. For v3.1.1.91, a representation must be chosen to display the data; the developers have decided that hexadecimal is best for this. now, copy the string you got and put it here insted of "040e0912" and run it again If $Handle == "040e0912" Then MsgBox( 0, "", "Lower Case" ) <-- this dont work If $Handle == "040E0912" Then MsgBox( 0, "", "Upper Case" ) <-- this works this suggests that handles are stored as strings, no ?Yes; for v3.1.1 this is definitely the case as stated in the help file. I found that the code below will work in the beta, which I didn't expect: Local $Handle = WinGetHandle('Calculator') If $Handle = '0x00B204CA' Then MsgBox(0, '', $Handle) now do this MsgBox( 0, '', IsString( $Handle ) ) <--- in both 3.1.1 and 3.1.1.9 you get 0, WTF ?This is the expected result for v3.1.1.91, however I don't understand why this happens for v3.1.1. The help file claims that WinGetHandle() will always return a string. Perhaps this was a v3.1.1 bug. now, if you close 'Calculator' and do this If $Handle == "" Then MsgBox( 0, "", "Empty String" ) this worksThis is expected behaviour for both v3.1.1 and v3.1.1.91 as WinGetHandle() returns an empty string when it cannot find a matching window. Edited November 28, 2005 by LxP Link to comment Share on other sites More sharing options...
AutoIT Geek Posted November 28, 2005 Author Share Posted November 28, 2005 OK, LxB, HWND's are stored as strings since this is the way autoit treats them in v3.1.1, thay are in this format --> '1234ABCD' <-- all upper case in v3.1.1.91, thay are in this format --> '0x1234ABCD' <-- all upper case in case of failure, thay are stored as empty string, ie, "" a DLLCALL that returns an HWND, returns a string in the above format, BUT, in case of failure, it is not an empty string, ie, "00000000" in v3.1.1 and "0x00000000" in 3.1.1.91 mystery SOLVED, now, the question is, why to make a special container for HWND's ? why not treat HWND's as plain hex numbers ? life would be much simpler that way, no ? Link to comment Share on other sites More sharing options...
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