Jump to content

Reference DLL in C#


NvrBst
 Share

Recommended Posts

Hello!

Well, sorry if this is a silly question but maybe someone can help me anyway. I want to use a single AutoItX function (ToolTip). I can't add the dll as a reference (when I go to "Reference > Add Reference > Browse > Select the DLL" it says "could not be added. Please make sure that the file is a valid assembly or COM component." This is because I don't have AutoIt installed on my computer... I have 3 computer I work on (laptop/desktop/work) and I don't really want to install AutoIt just to use the tooltip function on all 3.

Anyway my sob story behind, Could someone tell me if its possible to add a reference to my C# program (using the AutoItX.dll) without installing AutoIt? And still have it work on computer without AutoIt installed.

Right now this is what I do (for future ref though I'd like to know how to reference without installing because this doesn't work too well if I want to do the entire class).

[system.Runtime.InteropServices.DllImport("AutoItX3.dll", EntryPoint="AU3_ToolTip")]

public static extern void ToolTip(string szTip, long nX, long nY);

Is using "string szTip" okay? In the C++ it says "char* szTip". I ask this because I ran into some problems... the tooltip (after viewing) dissapears on its own after about 30 mins. I think it has to do with the garbage cleaner. I tried wrapping it in "unsafe" and such but it still dissapears after a while. Could someone possible give me the C# repersentation for that line? if it uses "char* szTip" do I need an "out" or "ref" or something?

Lastly :D I'm not sure if this is possible but is there anyway to see how AutoIt functions work internally (a webpage, or if they are open sourced someplace)? I can't find what Windows API it uses to create the tool tip, and if possible I'd just like to pInvoke and create it myself so I don't have to transfer the AutoIt dll with my application (my application is like 50KBs, and the DLL is 92KBs :D).

Thanks,

NvrBst

Link to comment
Share on other sites

Did it occur to you to look at MSDN for a .NET Tooltip class?

Hello :D Aye, I tried that before I restored to the AutoIt DLL... The problem I had with the .NET ToolTip Class is that I must provide a control for the tooltip to be displayed. I'm using tooltip to display information in a video game using hotkeys (IE I press the ctrl-t key and then the tooltip pop's up at (0,0) and displays the current time, and keeps updating every 500ms untill I press ctrl-t again and it goes away). As a result I don't own the control and ran into some troubles.

I would love to use that though... I have the handle and everything to the window I want to display the tooltip in, is there a way to convert that handle to a control (I tried a bunch of stuff but couldn't get it to work)? Or some generic control which will just display the tooltip anywhere on the screen like the AutoIt version does (or just make it so it wont take a control)?

Sorry to be a bother :D Thanks

NvrBst

EDIT: Typo :P

Edited by NvrBst
Link to comment
Share on other sites

I don't use .NET so I can't help you if the Tooltip class doesn't do what you want.

As far as AutoIt's Tooltip function, the code is in the last publicly available source release for AutoIt so you can see how it is done there. There should be a link to the source in the Developer's forum.

Link to comment
Share on other sites

Ahh thank you kindly. I remember looking at the archive when looking for the source but I only went into the AutoItX folder which was empty :P I should of looked a bit harder.

I see how its done now... You create a window using CreateWindowEx and just display tooltips onto that. I didn't realize you could create windows using topmost that would go infront of fullscreen applications (which i thought maintained topmost even if you tried to create windows infront of it)... but I guess I was wrong.

:D Which means I can probably use the .NET ToolTip class, and just use the NativeWindow Class to create a window so I own the control to the window for the tooltips... If not I can just do it the way in the source :D

Thanks so much, I'll go play with it some.

NvrBst

Also just for future reference, is there a way to reference an entire dll (like AutoItX) in C# which would allow you to just transport the dll with the application, and have it so you can run the exe from any folder (as long as the dll is with the exe), and on computer which don't have AutoIt installed? Basically the way DllImport works except referencing it (using it) like a COM Import?

Edited by NvrBst
Link to comment
Share on other sites

No, in order to create a reference to a DLL, it must be a COM dll. Even .Net assemblies are registered as COM I think. You will have to invoke functions through extern linkage.

The .Net ToolTip class is very limited. Most of the time, it is more work than it is bonus.

Loading unmanaged controls is very weird and I would suggest against it.

Link to comment
Share on other sites

  • 7 years later...

Hi, is this question answered?

I am into same situation where in I want to show a tooltip on screen.

Now, AutoItX is coming with .NET dll directly, can we create a tooltip at a particular location on screen or say in IE window.

I am automation browser with WatiN .NET framework. Now I aim to show tooltip where on IE, I am clicking.

Please post your solution if already done.

Thanks a lot! 

Link to comment
Share on other sites

  • Moderators

rahoolm,

This thread is over 7 years old - please do not necro-post again, just open a new thread. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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