Jump to content

Handle Data Type


stoobe
 Share

Recommended Posts

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

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

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

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..."

:o

I'm curious why you want to set the handle as an entered constant instead of getting it from the window itself?

:geek:

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

Just my usual thought... "I have no idea, sure will be interesting when one of the experts steps in and tells both of us..."

:o

I'm curious why you want to set the handle as an entered constant instead of getting it from the window itself?

:geek:

Don't know of any AsInt, AsString or AsHandle

but look at IsInt, IsString and IsHwnd

Also look at Hwnd function

Edited 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

Don't know of any AsInt, AsString or AsHandle

but look at IsInt, IsString and IsHwnd

Also look at Hwnd function

HWnd 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? :o

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

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

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 by stoobe
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...