[BUG] ComboBox parameter is invalid

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
arcticir
Posts: 657
Joined: 17 Nov 2013, 11:32

[BUG] ComboBox parameter is invalid

Post by arcticir » 11 Apr 2021, 23:32

When calling ahkdll from other languages ​​(rust), the ComboBox parameter is invalid。
use 64-latest-version, and 64-v-105.

Rust Example:

Code: Select all

extern "system" {
	fn LoadLibraryExW(lpLibFileName: *const u16, hFile: *const u16, dwFlags: u32) -> *const u16;
	fn GetProcAddress(hModule: *const u16, lpProcName: *const u8) -> *const u16;
}

fn main() {
	unsafe {
		let lib = LoadLibraryExW(encode("AutoHotkey.dll").as_ptr(), std::ptr::null(), 2048);
		let new = std::mem::transmute::<_, extern "C" fn(*const u16, *const u16, *const u16) -> u32,>(GetProcAddress(lib, "ahktextdll\0".as_ptr()));
		new(encode(r#"
				G1 := Gui.New()
				G1.Add("ComboBox", "vColorChoice", ["Red","Green","Blue","Black","White"])
				G1.Show()
			"#,).as_ptr(), std::ptr::null_mut(), std::ptr::null_mut());
	}
	loop {};
}

fn encode(source: &str) -> Vec<u16> {
	source.encode_utf16().chain(Some(0)).collect()
}
rust-call and ahk.exe-call:
Image

Return to “AutoHotkey_H”