Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AutoHotkey v1.1.10 Alpha Release


  • This topic is locked This topic is locked
40 replies to this topic
Coco
  • Members
  • 697 posts
  • Last active: Oct 31 2015 07:26 PM
  • Joined: 27 Jul 2012
@fincs: Here's a test case, I assigned a gLabel to the control. As you can see in this script, the target label does nothing and returns immediately yet when I click on the ComboBoxEx's dropdown arrow the dropdown ListBox, slides up and down several times and it takes a double-click to a select an item. Removing the gLabel fixes its behavior though..I'm not sure if there's any bug as it acts normal if the gLabel is omitted.
Gui, +HwndhGui
Gui, Add, Custom, classComboBoxEx32 HwndhCBoxEx gTest 0x0002 w150 h120 ; CBS_DROPDOWN = 0x0002

hIL := IL_Create()
Loop, 12
	IL_Add(hIL, "imageres.dll" , A_Index+4)

SetImageList(hCBoxEx, hIL)
for a, b in ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
	InsertItem(hCBoxEx, b, a, a, a)
SetCurSel(hCBoxEx, "January", false)

Gui, Show
return
GuiClose:
ExitApp

Test:
return

SetImageList(hwnd, hIL) {
	static CBEM_SETIMAGELIST := 0x0402

	SendMessage, % CBEM_SETIMAGELIST, 0, hIL,, % "ahk_id " hwnd
	return ErrorLevel
}

InsertItem(hwnd, text, pos:="", IconNormal:="", IconSel:="") {
	static CBEM_INSERTITEMW := 0x040B , CBEM_INSERTITEMA := 0x0401
	
	pos :=  pos ? pos-1 : GetCount(hwnd) ; Append to last if pos is not specified | Zero-based index
	, IconNormal := IconNormal <> "" ? IconNormal-1 : IconNormal
	, IconSel := IconSel <> "" ? IconSel-1 : IconSel
	, cchTextMax := false ; If text information is being set, this member is ignored.
	, iOverlay := 1
	
	; SET STRUCTURE
	CBEI_STRUCT(COMBOBOXEXITEM, text, cchTextMax, pos, IconNormal, IconSel, iOverlay)
	
	SendMessage, % A_IsUnicode ? CBEM_INSERTITEMW : CBEM_INSERTITEMA, 0, &COMBOBOXEXITEM,, % "ahk_id " hwnd
}

SetCurSel(hwnd, PosOrText:=1, ByIndex:=true) {
	static CB_SETCURSEL := 0x014E , CB_FINDSTRINGEXACT := 0x0158 ;, CB_SELECTSTRING := 0x014D ; Doesn't work
	
	if ByIndex {
		SendMessage, % CB_SETCURSEL, % PosOrText-1, 0,, % "ahk_id " hwnd
		idx := ErrorLevel
	} else {
		SendMessage, % CB_FINDSTRINGEXACT, -1, &PosOrText,, % "ahk_id " hwnd
		SendMessage, % CB_SETCURSEL, % ErrorLevel, 0,, % "ahk_id " hwnd
		idx := ErrorLevel
	}
	return (idx == "FAIL" ? false : idx+1)
}

GetCurSel(hwnd, ByRef text := "") {
	static CB_GETCURSEL := 0x0147
	
	SendMessage, % CB_GETCURSEL, 0, 0,, % "ahk_id " hwnd
	idx := ErrorLevel
	text := (idx == "FAIL" ? ("" , idx := false) :  GetText(hwnd, idx+=1))
	return IsByRef(text) ? idx : text
}

GetText(hwnd, pos) {
	static CB_GETLBTEXTLEN := 0x0149 , CB_GETLBTEXT := 0x0148 , CBEM_GETITEM := 0x040D
	
	SendMessage, % CB_GETLBTEXTLEN, % pos-=1, 0,, % "ahk_id " hwnd
	szBuf := ErrorLevel * (A_IsUnicode ? 2 : 1)
	VarSetCapacity(text, szBuf)
	SendMessage, % CB_GETLBTEXT, % pos, &text,, % "ahk_id " hwnd
	return ErrorLevel == "FAIL" ? 0 : text
}

GetCount(hwnd) {
	static CB_GETCOUNT := 0x0146
	
	SendMessage, % CB_GETCOUNT, 0, 0,, % "ahk_id " hwnd
	return (ErrorLevel == "FAIL" ? false : ErrorLevel)
}

CBEI_STRUCT(ByRef COMBOBOXEXITEM, ByRef pszText, ByRef cchTextMax, ByRef iItem, ByRef iImage, ByRef iSelectedImage, ByRef iOverlay, ByRef iIndent:=0) {
	static CBEIF_TEXT := 0x00000001 , CBEIF_IMAGE := 0x00000002 , CBEIF_SELECTEDIMAGE := 0x00000004 , CBEIF_OVERLAY := 0x00000008 
			, CBEIF_INDENT := 0x00000010 , CBEIF_LPARAM := 0x00000020 , CBEIF_DI_SETITEM := 0x10000000
	
	; SET MASK
	mask := CBEIF_TEXT | (iImage <> "" ? CBEIF_IMAGE : 0) | (iSelectedImage <> "" ? CBEIF_SELECTEDIMAGE : 0)
	
	;~ CREATE STRUCTURE
	VarSetCapacity(COMBOBOXEXITEM, 36, 0)
	, NumPut(mask , COMBOBOXEXITEM , 0) ; mask
	, Numput(iItem, COMBOBOXEXITEM , 4) ; iItem
	, Numput(&pszText, COMBOBOXEXITEM , 8) ; pszText
	, Numput(cchTextMax, COMBOBOXEXITEM , 12) ; cchTextMax - If text information is being set, this member is ignored.
	, NumPut(iImage, COMBOBOXEXITEM , 16) ; iImage
	, NumPut(iSelectedImage, COMBOBOXEXITEM , 20) ; iSelectedImage
	, Numput(iOverlay, COMBOBOXEXITEM , 24) ; iOverlay
	, Numput(iIndent, COMBOBOXEXITEM , 28) ; iIndent
	;~ , NumPut(CBEIF_LPARAM , COMBOBOXEXITEM , 32) ; lParam
	
}


fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
@Coco: I successfully reproduced the bug and fixed it, I just sent Lexikos a pull. It turned out that I wasn't quite following the OnMessage() code and I forgot to update apparently important timing variables.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010

The AHKv1.1.10-alpha documentation needs your help! See a list of what's left to be done at the link below, and discuss, propose, or make changes.

 

https://trello.com/b...c442e040466599d

 

Most importantly, Gui, Custom is not documented at the moment, and someone who is familiar with the topic is needed.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

v1.1.10-alpha3 has been uploaded, including fincs' latest fix.



Coco
  • Members
  • 697 posts
  • Last active: Oct 31 2015 07:26 PM
  • Joined: 27 Jul 2012

@fincs: Thanks, it works. I'll test it with other controls.wink.png



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

v1.1.10-alpha4 has been uploaded. When used on Vista or later, SoundSetWaveVolume and SoundGetWaveVolume now have the same effect as SoundSet and SoundGet with ComponentType Wave and ControlType Volume (or omitted). Note that v2 removes these two commands.

 

Edit: I did wonder whether it would be better to use the Master ComponentType, as two of my three sound devices don't support Wave, and the third ties it directly to Master anyway (albeit with a different scalar percentage <-> decibel formula).

 

Edit: As noted in the updated online documentation, SoundSet (on Vista or later) now attempts to preserve the balance between channels when changing the volume. Previously only SoundSetWaveVolume did this.



just me
  • Members
  • 1496 posts
  • Last active: Nov 03 2015 04:32 PM
  • Joined: 28 May 2011

Well.so I can add every common control such as "ListView32" as "Custom" control to have full control about WM_COMAND and WM_NOTIFY messsages. am I right?


Prefer ahkscript.org for the time being.


fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007

Well.so I can add every common control such as "ListView32" as "Custom" control to have full control about WM_COMAND and WM_NOTIFY messsages. am I right?

Yes.

segalion
  • Members
  • 50 posts
  • Last active: Oct 16 2014 09:20 AM
  • Joined: 02 Feb 2011

Hello.

 

I have seen that you are supporting sound control for Windows Vista and upper...

 

IMHO, one of the big problem in Windows about multiple soundcards is "how to force an application to use one audiodev as default sound devide"

 

In WXP, I found that it works as getting the default dev in the time process starts, and remains for each process launched... I have few experience with W7 but seems It works in same way...

 

For WXP I found a "very rudimentary" way to force default_audiodev modifying register...

Thats the example code I am using...

default_audiodev(dev=0,fortime=2000) { ; by default change audiodev by 2 seconds
    global state
    playback_ant:=record_ant:=""
    if (dev=0) {
        if (state.playback="") {
            RegRead, playback_ant, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback
            RegRead, record_ant, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Record
            state.playback:=playback_ant
            state.record:=record_ant
            tlog(A_ThisFunc ": Playback=" playback_ant " ,Record=" record_ant)
        }
        else {
            RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, % state.playback
            RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Record, % state.record
            tlog(A_ThisFunc ": Restoring to " state.playback)
        }
    }
    else { ; dev<>0 => set dev
        if dev is integer
            if (dev>0 and dev<=state.audiodevs)
                dev:=state.audiodev[dev]
        tlog(A_ThisFunc ": Set to " dev (fortime>0? "(" fortime " msecs)":""),5)
        RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, % dev
        RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Record, % dev
        sleep 100
        if (fortime>0)
            SetTimer T_default_audiodev, % fortime*-1, -100 ; change to default in 2 seconds
        else
            state.playback:=state.record:=dev
;        Run, % "rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,2 " ; mmsys.cpl
    }
}

T_default_audiodev:
    default_audiodev() ;change to state.playback
    return

With this... I can call i.e. play a mp3 file with "madplay.exe" in two diferents audio devices at the same time (i.e. my internal laptop speakers, and other on a external USB soundcard (buetooth plantronics).

default_audiodev(0,500)
run, % """madplay.exe"" -a " ampli1 " " opt " """ songfile1_mp3 """", , hide, pid
sleep 5000
default_audiodev(1,500)
run, % """madplay.exe"" -a " ampli2 " " opt " """ songfile2_mp3 """", , hide, pid

Do you know if can be possible has similar function in W7, to in order to set the default audio device?

 

Sincerely... thanks fo all



Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009

Lexikos, just to report that I have been testing both 32-bit and 64-bit AutoHotkey 1.1.10-alpha4 Unicode on my old scripts and both are working prefectly. However, I haven't tested new features much, so I'm not sure is this report valuable to you...


My Website • Recommended: AutoHotkey Unicode 32-bit • Join DropBox, Copy


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

v1.1.10.00 is now available.  The only changes from v1.1.10-alpha4 are a couple of unrelated bug fixes.