Ciantic / VirtualDesktopAccessor

DLL for accessing Windows 11/10 Virtual Desktop features from e.g. AutoHotkey
MIT License
773 stars 93 forks source link

Hey, some questions about this #1

Closed ptdev closed 9 years ago

ptdev commented 9 years ago

Hey there, I saw a reply from you on superuser.com about this project that seems to do what I want but I seem to be having some issues. So, I've created a script that's pretty much just a copy paste from your readme, with updated path for the dll location of course. Now, when I press the key combination I get some messages like this on ahk:

030: Return (6.45)
033: DllCall(GoToDesktopNumberProc, Int, 1)  
033: Return (0.55)
030: DllCall(GoToDesktopNumberProc, Int, 0)

Which appears to tell me that the shortcuts are working correctly. Unfortunately windows isn't switching to the desired desktop. This is the first time I've ever used ahk so maybe I'm doing somethng wrong or have some configuration issues. Can you give me some advice on how to fix this? Thanks.

Ciantic commented 9 years ago

Is your dll size: 20 480 bytes? You are using 64 bit Windows 10?

Add these error code checkers after each DllCall, e.g.

hVirtualDesktopAccessor := DllCall("LoadLibrary", "Str", "C:\Source\CandCPP\VirtualDesktopAccessor\x64\Release\VirtualDesktopAccessor.dll", "Ptr") 
WinErrorcode := DllCall("GetLastError")
MsgBox, `Windows' errorcode is %WinErrorcode%

Should give 0 on each (no error).

Reference codes from here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

ptdev commented 9 years ago

Hi, yes, my filesize is correct, I've downloaded your repository as is. And yes, I'm also running windows 10 64bit. However I am getting the following error after following your code checker instructions. Error 126 which according to the msdn site means "The specified module could not be found".

I'm not sure what that means, my filepaths are correct, and I've even tried to put the dll in my C:\ root to see if it was something to do with being on another drive, but I still get the same error.

Ciantic commented 9 years ago

I get 126 if I typo something in the file path. hmm. I've admin patched my AutoHotkey.exe using this instruction: http://autohotkey.com/board/topic/70449-enable-interaction-with-administrative-programs/ I wonder does it affect it?

You run the script given by Lexikos and it asks for AutoHotkey.exe it outputs AutoHotkey.exe you must save in C:\Program Files\ (other paths won't work).

Edit I remember using my DLL without that admin patch. It should work!

Ciantic commented 9 years ago

It has to be copy & paste " it sometimes screws it by changing the character to some fancy Unicode char. Do you have editor that can show the characters are ANSI?

E.g.

image

Ciantic commented 9 years ago

Btw my ahk script has UTF8-8-BOM, but when you convert it to ANSI it shows the possible magic chars. You can then convert it back.

ptdev commented 9 years ago

I've tried with the patched version and running it with the "run with ui access" that the patch creates but I get the same error. Also tried running as administrator with same results.

My script was UTF-8-without-BOM. I've since tried changing to ANSI and UTF-8-BOM but they all come up with the same error. Also tried creating an empty file in ANSI and pasting the script again. No go. Switching between encodings didn't appear to show any strange characters. I'm also using notepad++.

Anyway, I've shared my script on google drive in case you can maybe take a look or test it on your end:

https://drive.google.com/file/d/0BwoZAmP-h8zYb2JLQVkxQV9IZ0E/view?usp=sharing

Thanks again.

Ciantic commented 9 years ago

Hmm I wonder if it's a bug that works on my AutoHotkey.exe?

Try this:

hVirtualDesktopAccessor := DllCall("LoadLibrary", Str, "D:\Downloads\VirtualDesktopAccessor-master\x64\Release\VirtualDesktopAccessor.dll", "Ptr")
WinErrorcode := DllCall("GetLastError")
MsgBox, `Windows' errorcode is %WinErrorcode%

Notice that there is a bug in my script, that for some reason works on my computer anyway (AHK is weird). I had quoted "Str" even though it shouldn't be quoted but it works on my comp.

ptdev commented 9 years ago

No, still the same error. I wonder if there's any kind of runtime or lib that needs to be installed? You probably use some dev tool like visual studio or something that installs something that maybe I don't have? I don't know..

Ciantic commented 9 years ago

Is your AutoHotkey running as 64 bit?

image

Ciantic commented 9 years ago

LoadLibrary is most basic call, it exists on all computers without Visual Studio.

ptdev commented 9 years ago

Yes, it's running in 64bit. And yeah, I thought it wouldn't be that, windows 10 seems to already have most of this stuff installed and I never had any issues with missing runtimes or anything like that. I guess we'll just attribute this to yet another mysterious windows behavior? :) Thanks anyway for trying man, i wouldn't want to take any more of your time.

Ciantic commented 9 years ago

One more time, I tested this in Hyper-V virtualized pristine Windows 10, no visual studio in it or anything:

https://dl.dropboxusercontent.com/u/212719/AHKTest.zip

Drag test.ahk to AutoHotkeyU64.exe

It gives me error code 0, means no error.

Ciantic commented 9 years ago

My Windows 10 build is 10240, the stable. And virtualized Windows 10 is 10565, latest insider build.

Ciantic commented 9 years ago

facepalm I did install these https://www.microsoft.com/en-us/download/details.aspx?id=48145 both, x64 and x86 on the Hyper-V sometime ago.

Maybe it's those?

They are runtimes nothing really massive or developery thing. Stuff you get when you keep installing programs in the future.

I'm pretty sure this is it. just install vc_redist.x64.exe and vc_redist.x86.exe, it didn't even run hello world without those compiled from VS 2015 if I remember correctly.

ptdev commented 9 years ago

Ah, yes! That fixed it! Thanks a lot for your help, that's some grade A support right here! :+1: I still wonder why MS decided to make people use both hands for switching desktops or use the mouse to click that little taskview icon as that totally defeats the purpose or virtual desktops in the first place.. but hey... this totally solves that issue. Thanks again!

Ciantic commented 9 years ago

Awesome!

Pro-AHK tip:


VWMess(wParam, lParam, msg, hwnd) {
    desktopNumber := lParam + 1
    Menu, Tray, Icon, Icons/icon%desktopNumber%.ico
    // ...

Then find some good icons and put them "Icons/icon1.ico". The AHK icon gets old quickly.

ptdev commented 9 years ago

Great! i've implemented that, much better, thanks :smiley: