Announcement

Collapse
No announcement yet.

GetKeyState needs a diffrent call for 64 bit?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GetKeyState needs a diffrent call for 64 bit?

    Trying to make the transition to 64 bit, to get more registry access. It has mostly worked.

    The only holdback I've come across is code originally obtained from



    Code:
    if (e_MsgID == MSGID_ONTIMER) then
      local nKeyState = DLL.CallFunction(_SystemFolder.."\\user32.dll", "GetKeyState", 0x74, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
      if (String.ToNumber(nKeyState) < 0) then
        -- Do things
      end
    end
    the 32 bit build responds to F5 as expected, but there's no signs the 64 bit build is doing anything - but it is giving no errors.

    Reading up, perhaps I should be using a different user32.dll at a different path? Or is there a different method for responding to key presses these days?

  • #2
    Seems that I had a small error in the solution I posted years ago, which did not cause an issue then somehow. The third parameter of DLL.CallFunction() should be a string, not a number. Please try this, it worked here correctly with both 32- and 64-bit setups, on a 64-bit operating system.

    Code:
    local nKeyState = DLL.CallFunction(_SystemFolder.."\\user32.dll", "GetKeyState", "116", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
    if (String.ToNumber(nKeyState) > 0) then
    Dialog.Message("F5", "key pressed");
    else
    Dialog.Message("F5", "key not pressed");
    end
    Ulrich

    Comment


    • #3
      Switched to the base-10 string, flipped the String.ToNumber test, and it's working. Thank you.

      Comment

      Working...
      X