• (cs)

    Noooooooooooooooooooooooooooooooooooo!

    That's all I have to say about that!

  • (cs)

    Om my God! That is horrendous. I wonder what it would do on my system where the taskbar is at the top of the screen. Can't be good...

  • (cs)
    Alex Papadimoulis:
    Even if you're pretty certain that your way isn't the best way, sometimes it's just easier to go with what you know instead of struggling with something new. I'm pretty sure that's what the author of today's code (found in the Sidebar) was thinking. He knew that to register a OCX library, you click the Start Button, then press R (for Run), then type in -- well, you get the idea.


    Let us get tied into (knots with) the UI.

    I wonder if it occurred to him that there could be a better way.  Considering what he did know, it ought to be a reasonable conclusion that there is probably a better way that is easy.

    Sincerely,

    Gene Wirchenko

  • Wilbur (unregistered)

    I call shenanigans!

    This can't really be true?!@?#?$

    cry

    -- W

  • (cs) in reply to Wilbur

    Hey that sounds a lot like this:
    http://blogs.msdn.com/oldnewthing/archive/2005/08/16/452141.aspx

    (the story in the last paragraph)

  • (cs)

    Another quality piece of code from the VB community.

  • (cs) in reply to Wilbur

    I have two rows in my task bar (you can open lots of windows)... Therefore in my case i'd guess that he'd miss my start button! oops... too bad it doesn't error with an "Aaaarrrrrgggghhh" msg

  • (cs)

    What happens when a user moves their taskbar to the right hand side of the screen?

    I would suggest that this programmer make sweeps across the screen, examining 20x20 px squares looking for a portion of the word "Start".  This would be a much more robust solution for locating the start menu than just assuming that Screen.Height / 15 - 10 will work.

  • leo (unregistered)

    Thankfully, "run" is the only thing in the Start menu that could possibly start with an "R"... [8-)]

  • (cs) in reply to leo

    <font size="2">Holy mother of Bob.

    </font>

  • (cs)
    Alex Papadimoulis:

    Screen.Height / 15 - 10

    Anyone want to comment on what this does? is he assuming that the start menu height is 1/15th of the screen height, and that he can just subtract 10 to land in the middle? What if your screen is really big?

  • (cs) in reply to scooter

    Better yet, what do you think happens when this guy wants to call another executable?  I'll bet it goes something like this:

    1. Use Windows API calls to move the mouse to the taskbar
    2. (hope that there's nothing but blank taskbar under the mouse)
    3. Use Windows API calls to right click
    4. Use Windows API calls to move the mouse up to "Show the Desktop"
    5. (hope that the user is running XP -- earlier versions said something like "Minimize All Windows")
    6. Use Windows API calls to release the mouse
    7. Use Windows API calls to move the mouse to the default location for "My Computer"
    8. (hope that the user has not moved any desktop icons)
    9. ...... you get the picture .....
  • (cs)

    GET OUT!!!!

  • Makli (unregistered) in reply to leo
    Anonymous:

    Thankfully, "run" is the only thing in the Start menu that could possibly start with an "R"... [8-)]



    The other problem is that it's 'R' only on the english version on Windows. In my czech version it would be 'T'.
  • (cs)

    Wow,
    If you can send me the executable for this "program", I would love to run it on my machine and watch this monstrosity in action. I never cease to be amazed how people are willing to spend the time and effort to do this kind of stuff and not give up until they get the darn thing working using their WTF solution.
    I am much too lazy to get this kind of junk to work.

    All I can say is good job!

  • uncool (unregistered) in reply to Sweets

    hell yeah!

    i'm reminded of old windows and record macro thinggy ... that caused me all kinds of problems

  • (cs) in reply to Kippesoep
    Kippesoep:
    Om my God! That is horrendous. I wonder what it would do on my system where the taskbar is at the top of the screen. Can't be good...


    Ah, someone else who likes the taskbar at the top.

    I have seen a number of programs, ah, not do well, when the taskbar is at the top of the screen.  Is there a series of WTFs on assuming default setups?

    Sincerely,

    Gene Wirchenko

  • (cs) in reply to leo
    Anonymous:
    Thankfully, "run" is the only thing in the Start menu that could possibly start with an "R"... [8-)]


    I once had a finger slip on one command and so typed "ruin" for "run".

    Sincerely,

    Gene Wirchenko

  • Datheron (unregistered) in reply to Gene Wirchenko

    Since Windows NT, I believe, Windows has provided functions that

    i. return the screen resolution (e.g. 1024x768)
    ii. return a RECT of the available screen real estate minus the space taken up by the taskbar (e.g. 0, 0, 1024, 700 if your taskbar is on the bottom; 80, 0, 1024, 768 if your taskbar is on the left, etc.)

    Far too often programs assume that the upper-left corner of the screen is (0,0), so taskbar positions that mess with that cause all sorts of havoc.

  • (cs)

    Yet another shining example of the typical quality of a Visual Basic developer's code.

  • (cs)

    My favorite part is that he uses sendkeys, but the idea of using sendkeys to send the "windows" key, which pops up the start menu! (Unless you have some wicked wild key remapping going on.)

  • Franky Pelvis (unregistered)

    I'm not sure if people are joking or not with some of the responses to this WTF.  Their is no good way to do this using screen geometry.  As a hack you might be able to send WINDOWS+R to duplicate the Start->Run monstrosity. However, the correct way to do this sort of thing in VB is probably with Shell() or CreateProcess() depending on whether or not you need to capture output, and if you need to wait for the process to exit before continuing.  That's as of VB6, I haven't used VB.Net.

  • (cs)
    Alex Papadimoulis:

      SetCursorPos 32, Screen.Height / 15 - 10
      mouse_event MOUSEEVENTF_ABSOLUTE, 32, Screen.Height / 15 - 10, 1, 1
      mouse_event MOUSEEVENTF_LEFTDOWN, 32, Screen.Height / 15 - 10, 1, 1
      mouse_event MOUSEEVENTF_LEFTUP, 32, Screen.Height / 15 - 10, 1, 1

    Alright, I had to look into this as I just couldn't figure out what Screen.Height / 15 - 10 was suppose to do. Screen.Height returns the height of the screen measured in twips. After trying to figure out how this factored in, I decided to take my screen height in twips (11520) and divide it by my screen height as measured by the control panel display applet in pixels (768) and ... you guessed it ... the answer if 15. The author was apparantly trying to convert from twips to screen coordinates. I really don't see how this calculation helps, however, as the API does not take the measurement in pixels, but in normalized absolute coordinates:

     "dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, (65535,65535) maps onto the lower-right corner" (from the MSDN documentation).

    Also, he passes in a value of 1 for the parameter dwData, which only applies for wheel data or X buttons. To quote the documentation:

    "If dwFlags is not MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, or MOUSEEVENTF_XUP, then dwData should be zero. "
  • (cs) in reply to limelight

    The CORRECT way is to use LoadLibrary, then GetProcAddress (to get the address of the function DllRegisterServer) and then use that address to call DllRegisterServer. I'm still surprised the dude didn't send WindowsKey+R for the run menu.

  • (cs) in reply to Franky Pelvis
    Anonymous:
    I'm not sure if people are joking or not with some of the responses to this WTF.  Their is no good way to do this using screen geometry.


    You obviously have no sense of adventure...  Real Windows UI programmers don't rely on those flaky events like Button.Click().  If you are at all serious about quality programs, capture the Click event and use the Windows SendKey() method to hop the tab order on your form until you get to the right button.  Then you can use SendKey() to send "Return"....
  • (cs) in reply to scooter
    scooter:
    Anonymous:
    I'm not sure if people are joking or not with some of the responses to this WTF.  Their is no good way to do this using screen geometry.


    You obviously have no sense of adventure...  Real Windows UI programmers don't rely on those flaky events like Button.Click().  If you are at all serious about quality programs, capture the Click event and use the Windows SendKey() method to hop the tab order on your form until you get to the right button.  Then you can use SendKey() to send "Return"....


    Yeah, I seem to remember alot of information on UI programming spread around at about the same time those pay to browse programs started popping up... coincidence?
  • (cs)

    I'm speechless.....uuuhhhmmmm. Oh, do chickens have large talons?

  • (cs) in reply to GoatCheez

    pay to browse meaning whatever company would pay you $.02 an hour to browse the web while their adds were on the bottom/top of your screen.

  • (cs) in reply to ferrengi

    ferrengi:
    Wow,
    If you can send me the executable for this "program", I would love to run it on my machine and watch this monstrosity in action.

    You would let that run on your machine?!!  You, sir, are a brave man.  I salute you.

  • (cs) in reply to Gene Wirchenko
    Gene Wirchenko:
    Anonymous:
    Thankfully, "run" is the only thing in the Start menu that could possibly start with an "R"... [8-)]


    I once had a finger slip on one command and so typed "ruin" for "run".

    Sincerely,

    Gene Wirchenko



    Wow, that's really fascinating. Any other stories about typos you've made in the past? Please, enthrall and entertain us.

    Sincerely,
    Richard Nixon
  • (cs) in reply to Richard Nixon

    Holy bleeping bleep. I read this thing religiously.  I thought I'd seen it all, now this [:O]

  • (cs) in reply to Richard Nixon

    Yet another nixon post contributing nothing while trying to make another poster feel bad. I wonder why. I know nixon sucked... but wtf lol.

  • (cs)

    Without more context, I can't really complain too much.  I've seen lots of testing software that puts events on the event queue to simulate how a user would actually do something.  Perhaps this was a test program for an install process?

    Oh, who am I kidding.  This is horrible.

  • Nand (unregistered) in reply to RevMike

    Well, to be fair, the code comes from a bunch of kids trying to figure out programming, and the author is aware of how awful this way of registering a control is.

    http://www.youngcoders.com/thread15404.html

    It's still quite an achievement to come up with a solution this wrong though :)

  • What's a name? (unregistered)

    The more I read on this site the more I am convinced that I should get out of the programming business. I simply don't want to be associated with people who do such things and call themself "programmers".

    Used car salesman seems like a much more honest profession than programming to me now. Any job offers?

  • (cs) in reply to What's a name?

    Anonymous:
    The more I read on this site the more I am convinced that I should get out of the programming business. I simply don't want to be associated with people who do such things and call themself "programmers".

    Used car salesman seems like a much more honest profession than programming to me now. Any job offers?

    http://jobsearch.monster.com/jobsearch.asp?q=used+car+sales&fn=&lid=&re=104&cy=us

  • Axel (unregistered) in reply to jeremydwill

        With a german Windows this will even shutdown the computer Oo

  • (cs) in reply to What's a name?
    Anonymous:
    The more I read on this site the more I am convinced that I should get out of the programming business. I simply don't want to be associated with people who do such things and call themself "programmers".

    Used car salesman seems like a much more honest profession than programming to me now. Any job offers?


    I think the true problem lies in our education system. People are graduating college with computer science degrees who don't C from C#, or Java from JavaScript. Yet, they still manage to pass all of their programming classes. I really think it has to do with some college requiring professors to pass X amount of students. If a professor gets 100 kids who can't program, and never learn how to, he still has to pass some or the administrators will thing he or she cannot teach programming. If it were up to me, I would have a very strict grading structure, and am sure that most of the time only one or two people would just barely pass a test in a group of 20. I have had to tutor CS students, and some of them just cannot be tought how to program. These people still manage to get their degrees. This is THE reason why I feel that CS degrees are completely useless.
  • (cs) in reply to Richard Nixon
    Richard Nixon:
    Gene Wirchenko:
    Anonymous:
    Thankfully, "run" is the only thing in the Start menu that could possibly start with an "R"... [8-)]


    I once had a finger slip on one command and so typed "ruin" for "run".

    Sincerely,

    Gene Wirchenko



    Wow, that's really fascinating. Any other stories about typos you've made in the past? Please, enthrall and entertain us.

    Sincerely,
    Richard Nixon



    i once typed 'teh' instead of 'the'.
  • (cs) in reply to sao

    I would like to see the routine he would create to output to a text file. Let's see, first move the mouse to the Notepad icon. Issue a double-click. Send keys for the entire contents of the text file being output. Move the mouse to the File menu. Click. Move to Exit. Click. Move to "Yes" button. Click "Yes" to save. And, of course, just hard-code the locations of all these things in absolute screen coordinates because everybody's computer is set up exactly like mine and I never move the Notepad window.

  • (cs) in reply to RevMike

    A classic "WTF" in the true spirit of what this site is all about.

    Thanks, Alex !!

  • (cs) in reply to GoatCheez
    GoatCheez:
    I think the true problem lies in our education system. People are graduating college with computer science degrees who don't C from C#, or Java from JavaScript. Yet, they still manage to pass all of their programming classes. I really think it has to do with some college requiring professors to pass X amount of students. If a professor gets 100 kids who can't program, and never learn how to, he still has to pass some or the administrators will thing he or she cannot teach programming. If it were up to me, I would have a very strict grading structure, and am sure that most of the time only one or two people would just barely pass a test in a group of 20. I have had to tutor CS students, and some of them just cannot be tought how to program. These people still manage to get their degrees. This is THE reason why I feel that CS degrees are completely useless.

    I'm inclined to agree. I recently went through a webdevelopment course (not the same as a CS degree I know), but while it taught programming in javascript and php, not once was it taught how to program. While I'm quite pleased to have recieved a diploma for the course, it's not something I'd place much value in when it comes to job interviews etc. Indeed if I ever find myself in the position of hiring people and I saw someone with the same degree I'd be more inclined to be harder on them, simply because of the level of crap I saw that was allowed to pass, including some code by one of the students which rivaled much of the WTF code I've seen posted here.
  • (cs) in reply to scooter
    scooter:
    What happens when a user moves their taskbar to the right hand side of the screen?

    I would suggest that this programmer make sweeps across the screen, examining 20x20 px squares looking for a portion of the word "Start".  This would be a much more robust solution for locating the start menu than just assuming that Screen.Height / 15 - 10 will work.


    Arrgh but what about if 'auto-hide' is enabled ???

  • Runtime Error (unregistered) in reply to Quinnum
    Quinnum:
    scooter:
    What happens when a user moves their taskbar to the right hand side of the screen?

    I would suggest that this programmer make sweeps across the screen, examining 20x20 px squares looking for a portion of the word "Start".  This would be a much more robust solution for locating the start menu than just assuming that Screen.Height / 15 - 10 will work.


    Arrgh but what about if 'auto-hide' is enabled ???



    The obvious solution is to reset the user's taskbar location and other settings back to default settings when the program starts.
  • (cs) in reply to Scott

    Hey that sounds a lot like this:
    http://blogs.msdn.com/oldnewthing/archive/2005/08/16/452141.aspx

    (the story in the last paragraph)</QUOTE>

    Don't laugh. I have a driver install program that actually has to do that. It installs a device driver for some custom hardware on a 'headless' box (no keyboard, mouse, or monitor). In our case, there is no user to dismiss the message boxes for us.

  • (cs) in reply to Quinnum

    Quinnum:

    Arrgh but what about if 'auto-hide' is enabled ???

    That was going to be my question.  Since you've asked it, with toungue firmly implanted in my cheek, I submit:

    Declare Function ScreenShout Lib "user32" Alias "ScreenShout" (ByVal SayWhat As String) As Long
    lngRC = ScreenShout("Ollie, Ollie, Oxen Free")
    If lngRC <> 0 Then   'We have unhidden the task bar
    ... 'click the task bar in one of the four quadrants
    Else
    lngRC = ScreenShout("Come out. Come out, wherever you are")
    If lngRC <> 0 Then   'We have unhidden the task bar
    ... 'click the task bar in one of the four quadrants

    Else
    ... 'keep shouting in different languages
    End If
    End If 

    ====================

    Note: Be sure to programmatically turn up the speakers and unmute them before calling the ScreenShout API.

    What?!?  The ScreenShout API isn't one of the special 'hidden' APIs that Microsoft uses to maintain their Office marketshare dominance?

  • (cs) in reply to aikimark

    A long time ago I put my Start Menu at the top of the screen to test what it was like having it up amoungst the rest of the menus.  I have kept it only partially for that reason because it has proved to be a stunningly accurate (and early/fast) software worthiness filter.  It works like this; I install a piece of software and if it breaks or does something stupid because the Start Menu isn't where the code assumes it is (like the above piece of code does) I uninstall it immediately.
    You'd be surprised how many previously reputable software companies have failed this simple test.  No Adobe product will never be installed be me again - sadly, I haven't found a way to replace Flash yet, but then it hasn't been an Adobe product for as long either.

  • (cs) in reply to Xarium

    Correction: No Adobe product will EVER be installed be me again

    Meanwhile, I've just learned that the "edit feature" appears not to be...

  • (cs) in reply to sao

    sao:
    i once typed 'teh' instead of 'the'.

    I used to know a guy who's last name was Teh.  The fun he had using Word...

  • (cs)
    mouse_event MOUSEEVENTF_ABSOLUTE, 32, Screen.Height / 15 - 10, 1, 1
    mouse_event MOUSEEVENTF_LEFTDOWN, 32, Screen.Height / 15 - 10, 1, 1
    mouse_event MOUSEEVENTF_LEFTUP, 32, Screen.Height / 15 - 10, 1, 1

    Heh... the funny thing about that is that he could've called Screen.twipsPerPixelY rather than hard-coding 15.

    By entering 15 he's assuming that the user has the screen set at a particular resolution (probably 1024x768).

    So, If you run 800x600 or 1280x1024 it's probably not even gonna hit the right spot anyway. :^)

Leave a comment on “Pragmatically Registering”

Log In or post as a guest

Replying to comment #:

« Return to Article