Jump to content

Don't you just love it when it hits you like a ton of bricks....

Recommended Posts

I'm getting kinda serious about building a halfways decent dll for use with autoit.  things are going pretty smoothly HA so far.  I've had more successes than failures so not off to a bad start.

So in a nutshell I need to make the dll open a handle to the calling process console so i can print out     aaaa chicken nuggets well that was a setback... anyways you live and learn.  To the point of this thread.  I had previously attempted to wrap my brain around how to convert a hex number into a string that displays itself in hex.  Theres some operator overloads that take care of this in the streaming classes.  I had done this with base 10 numbers and converted them to a string which I thought was pretty cool that I figured out how to do that relatively pain free (been awhile i forget about the pain) but wouldn't you believe it i played around with this function for an hr ...had to shut my eyes and zen for a few min bc i couldn't believe it wasn't working.  I starting thinking about the numbers and their sizes, why hex is a thing and....it was like a slap in the face.  Its honestly so simple.  Its less complicated than doing a base 10 number to a string

void  handletostring (HANDLE msg) {
    int a = (int)msg;
    string s{};
    while (a) {
        int i = a % 16;
        s.push_back(i < 10 ? i + 48 : i + 65);
        a >>= 4;

like duh right.  Regardless a good learning experience.  Happy new year.

Link to post
Share on other sites

Are you making your 2022 life harder than it should or is it me?

$h  = GUICreate("My GUI")
ConsoleWrite($h & @LF)
ConsoleWrite(_UintToString($h, 16) & @LF)

Func _UintToString($i, $base)
    Return DllCall("msvcrt.dll", "wstr:cdecl", "_ui64tow", "uint64", $i, "wstr", "", "int", $base)[0]
EndFunc   ;==>_UintToString

; Func _StringToUint($s, $base)
;       Return DllCall("msvcrt.dll", "uint64:cdecl", "_wcstoui64", "wstr", $s, "ptr*", 0, "int", $base)[0]
; EndFunc   ;==>_StringToUint


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
17 hours ago, jchd said:

Are you making your 2022 life harder than it should or is it me?


This is a far cry from the point of the project that i'm working on.  I was having problems writing to the autoit console and for some reason I was trying to get debug information to print to the autoit console and long story short I started down the rabbit hole of converting an int to hex.  when playing around in c and c++ doing conversions like this from numbers to strings and back happen somewhat regularly bc (especially c) theres not always a built in function to deal with it the way you want to and writing little utility functions does happen somewhat often.  Its also good practice and its alot more efficient that importing entire libraries everytime you want to convert and int to a char or something along those lines.  

I'm just happy to have figured out the logic.  I like building things that already exist from the ground up bc you learn alot about how things work and answers to why certain things are the way they are.  I was tired when I did this If i wanted to do it and easier way I could read the handle bit by bit from most significant end to the least and avoid reversing the string and other messing around.  I've since deleted this bc its unnecessary but i'm still happy I figured it out.

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...