stoobe Posted February 11, 2006 Share Posted February 11, 2006 Hi,I have the value of a window's handle that I want to use within AutoIt but I can't store it as a handle data type. I've tried using strings and ints, but neither of those work as handle identifiers.To gerenate integers theres Int(expression) and to generate strings there's String(expression). Is there something like that for handles? Thanks! Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 11, 2006 Share Posted February 11, 2006 Hi, I have the value of a window's handle that I want to use within AutoIt but I can't store it as a handle data type. I've tried using strings and ints, but neither of those work as handle identifiers. To gerenate integers theres Int(expression) and to generate strings there's String(expression). Is there something like that for handles? Thanks! What do you get when you do something like: MsgBox(64, "GUI Handle", "GUI handle is: " & $GuiHandle) Substitute your variable for the handle you've got. In the cases I looked at they were 32-bit hex numbers, without the '0x' in front of them. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
stoobe Posted February 13, 2006 Author Share Posted February 13, 2006 What do you get when you do something like: MsgBox(64, "GUI Handle", "GUI handle is: " & $GuiHandle) Substitute your variable for the handle you've got. In the cases I looked at they were 32-bit hex numbers, without the '0x' in front of them. Hi, I gave this code a try: $handle1 = 0x0056078C MsgBox(64, "GUI Handle", "GUI handle is: " & $handle1) MsgBox(64, 'text2', WinGetText($handle1)) $handle2 = WinGEtHandle("Untitled - Notepad"); MsgBox(64, "GUI Handle", "GUI handle is: " & $handle2) MsgBox(64, 'text2', WinGetText($handle2)) The first handle is technically the right value but didn't work. It was interpreted as text, and AutoIt looked for a window with title 0x0056078C. The second part worked to grab the text from Notpad. The message box printed "GUI handle is: 0056078C" I tried different variations for handle1 too, such as using it as a string, but WinGetText always interprets $handle1 as a text value to search a title for, rather than a window handle to use directly. I read that handles are a special type, but i dont know how to "bless" my variable as a handle. (This is where I read about handle types: auto it data types) I was hoping for a "AsHandle" function, kind of like "AsInt" or "AsString" Any thoughts? Thanks! Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 13, 2006 Share Posted February 13, 2006 I was hoping for a "AsHandle" function, kind of like "AsInt" or "AsString"Any thoughts?Just my usual thought... "I have no idea, sure will be interesting when one of the experts steps in and tells both of us..." I'm curious why you want to set the handle as an entered constant instead of getting it from the window itself? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GaryFrost Posted February 13, 2006 Share Posted February 13, 2006 (edited) Just my usual thought... "I have no idea, sure will be interesting when one of the experts steps in and tells both of us..." I'm curious why you want to set the handle as an entered constant instead of getting it from the window itself? Don't know of any AsInt, AsString or AsHandlebut look at IsInt, IsString and IsHwndAlso look at Hwnd function Edited February 13, 2006 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...
PsaltyDS Posted February 13, 2006 Share Posted February 13, 2006 Don't know of any AsInt, AsString or AsHandlebut look at IsInt, IsString and IsHwndAlso look at Hwnd functionHWnd looks like what Stoobe was looking for, but what good is doing that? Where would it be a good idea or necesary to set a window handle directly? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
tonedeaf Posted February 13, 2006 Share Posted February 13, 2006 Window Handles are long integers. But in AutoIt you don't need to declare the variable "type". I remember a script here in the boards somewhere which stored the window handles in a text file and later retrieved them by converting the strings from the text file back to integers to get a valid window handle. You can also use the IsHwnd() function to check if your variable is a valid handle "type". Sorry, not enough info, but this is a situation which I have never run into. Link to comment Share on other sites More sharing options...
stoobe Posted February 13, 2006 Author Share Posted February 13, 2006 (edited) Window Handles are long integers. But in AutoIt you don't need to declare the variable "type". I remember a script here in the boards somewhere which stored the window handles in a text file and later retrieved them by converting the strings from the text file back to integers to get a valid window handle. You can also use the IsHwnd() function to check if your variable is a valid handle "type". Sorry, not enough info, but this is a situation which I have never run into. Thanks PsaltyDS, gafrost and tonedeaf for your posts, Hwnd(...) or IsHwnd(...) would be perfect. My version of AutoIt (V3, downloaded w/in the last month) doesn't recognize Hwnd or IsHwnd as functions though. Are you using a more advanced or beta version? Also, I couldn't find those on the function list: list. Do I need some special download or configuration to use Hwnd(..)? I tried this but it failed to pass a synatx check on IsHwnd: $h = IsHwnd(0x000D07B4) MsgBox(64, "GUI Handle", "GUI handle is: " & WinGetTitle($h)) To answer you question PsaltyDS, I'm calling AutoIt programatically. My other program has identified a window and wants AutoIt to then operate on that window. The hwnd is the most reliable and un-ambiguous way for me to identify the window, since titles may change or can be repeated. I'd like to pass in the handle as a command line argument eventually, so that I wont have to hard code the hwnd in a script. Edited February 13, 2006 by stoobe Link to comment Share on other sites More sharing options...
GaryFrost Posted February 13, 2006 Share Posted February 13, 2006 Using the beta 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...
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