コード例 #1
0
ファイル: __init__.py プロジェクト: josephsl/stationPlaylist
	def script_pause(self, gesture):
		playingNow = sendMessage(SPLWin, 1024, 0, SPL_TrackPlaybackStatus)
		# Translators: Presented when no track is playing in Station Playlist Studio.
		if not playingNow: ui.message(_("There is no track playing. Try pausing while a track is playing."))
		elif playingNow == 3: sendMessage(SPLWin, 1024, 0, SPLPause)
		else: sendMessage(SPLWin, 1024, 1, SPLPause)
		self.finish()
コード例 #2
0
	def _getWordOffsets(self,offset):
		start=winUser.sendMessage(self.obj.windowHandle,SCI_WORDSTARTPOSITION,offset,0)
		end=winUser.sendMessage(self.obj.windowHandle,SCI_WORDENDPOSITION,start,0)
		if end<=offset:
			start=end
			end=winUser.sendMessage(self.obj.windowHandle,SCI_WORDENDPOSITION,offset,0)
		return [start,end]
コード例 #3
0
	def _get_role(self):
		hItem=winUser.sendMessage(self.windowHandle,CLM_GETSELECTION,0,0)
		iType=winUser.sendMessage(self.windowHandle,CLM_GETITEMTYPE,hItem,0)
		if iType==CLCIT_DIVIDER or iType==CLCIT_INVALID: #some clists treat invalid as divider
			return controlTypes.ROLE_SEPARATOR
		else:
			return controlTypes.ROLE_TREEVIEWITEM
コード例 #4
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getWordOffsets(self,offset):
		if self.obj.editAPIVersion>=2:
			start=winUser.sendMessage(self.obj.windowHandle,EM_FINDWORDBREAK,WB_MOVEWORDLEFT,offset)
			end=winUser.sendMessage(self.obj.windowHandle,EM_FINDWORDBREAK,WB_MOVEWORDRIGHT,start)
			if end<=offset:
				start=end
				end=winUser.sendMessage(self.obj.windowHandle,EM_FINDWORDBREAK,WB_MOVEWORDRIGHT,offset)
			return (start,end)
		else: #Implementation of standard edit field wordbreak behaviour (only breaks on space)
			text=self.obj.windowText
			#cariage returns are always treeted as a word by themselves
			if text[offset]=='\r':
				return offset,offset+1
			#Find the start of the word (possibly moving through space to get to the word first)
			tempOffset=offset
			while offset>=0 and text[tempOffset].isspace():
				tempOffset-=1
			while tempOffset>=0 and not text[tempOffset].isspace():
				tempOffset-=1
			start=tempOffset+1
			#Find the end of the word and trailing space
			tempOffset=offset
			textLen=len(text)
			while tempOffset<textLen and not text[tempOffset].isspace():
				tempOffset+=1
			while tempOffset<textLen and text[tempOffset].isspace():
				tempOffset+=1
			end=tempOffset
			return start,end
コード例 #5
0
ファイル: akelEdit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getStoryLength(self):
		ciChar=AECHARINDEX()
		processHandle=self.obj.processHandle
		internalCiChar=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(ciChar),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winUser.sendMessage(self.obj.windowHandle,AEM_GETINDEX,AEGI_LASTCHAR,internalCiChar)
		end=winUser.sendMessage(self.obj.windowHandle,AEM_INDEXTORICHOFFSET,0,internalCiChar)
		winKernel.virtualFreeEx(processHandle,internalCiChar,0,winKernel.MEM_RELEASE)
		return end+1
コード例 #6
0
ファイル: akelEdit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getLineNumFromOffset(self,offset):
		ciChar=AECHARINDEX()
		processHandle=self.obj.processHandle
		internalCiChar=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(ciChar),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winUser.sendMessage(self.obj.windowHandle,AEM_RICHOFFSETTOINDEX,offset,internalCiChar)
		winKernel.readProcessMemory(processHandle,internalCiChar,ctypes.byref(ciChar),ctypes.sizeof(ciChar),None)
		winKernel.virtualFreeEx(processHandle,internalCiChar,0,winKernel.MEM_RELEASE)
		return ciChar.nLine
コード例 #7
0
ファイル: __init__.py プロジェクト: josephsl/stationPlaylist
	def script_libraryScanProgress(self, gesture):
		scanned = sendMessage(SPLWin, 1024, 1, SPLLibraryScanCount)
		if scanned >= 0:
			# Translators: Announces number of items in the Studio's track library (example: 1000 items scanned).
			ui.message(_("Scan in progress with {itemCount} items scanned").format(itemCount = scanned))
		else:
			# Translators: Announces number of items in the Studio's track library (example: 1000 items scanned).
			ui.message(_("Scan complete with {itemCount} items scanned").format(itemCount = sendMessage(SPLWin, 1024, 0, SPLLibraryScanCount)))
		self.finish()
コード例 #8
0
 def script_middleVolume(self, gesture):
     if not self.inMainWindow():
         gesture.send()
         return
     obj = findWindowNVDAObject("volume")
     if obj is None:
         return
     sendMessage(obj.windowHandle, 1029, False, 47)
     modifyVolume(VK_UP)
コード例 #9
0
	def _get_states(self):
		newStates=super(mirandaIMContactList,self)._get_states()
		hItem=winUser.sendMessage(self.windowHandle,CLM_GETSELECTION,0,0)
		state=winUser.sendMessage(self.windowHandle,CLM_GETEXPAND,hItem,0)
		if state==CLE_EXPAND:
			newStates.add(controlTypes.STATE_EXPANDED)
		elif state==CLE_COLLAPSE:
			newStates.add(controlTypes.STATE_COLLAPSED)
		return newStates
コード例 #10
0
	def _getPointFromOffset(self,offset):
		point=textInfos.Point(
		winUser.sendMessage(self.obj.windowHandle,SCI_POINTXFROMPOSITION,None,offset),
		winUser.sendMessage(self.obj.windowHandle,SCI_POINTYFROMPOSITION,None,offset)
		)
		if point.x and point.y:
			return point
		else:
			raise NotImplementedError
コード例 #11
0
ファイル: akelEdit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getLineOffsets(self,offset):
		(start,end)=super(AkelEditTextInfo,self)._getLineOffsets(offset)
		if end == self._getStoryLength():
			return (start,end)
		ciChar=AECHARINDEX()
		processHandle=self.obj.processHandle
		internalCiChar=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(ciChar),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winUser.sendMessage(self.obj.windowHandle,AEM_RICHOFFSETTOINDEX,offset,internalCiChar)
		winUser.sendMessage(self.obj.windowHandle,AEM_GETINDEX,AEGI_NEXTLINE,internalCiChar)
		end=winUser.sendMessage(self.obj.windowHandle,AEM_INDEXTORICHOFFSET,0,internalCiChar)
		winKernel.virtualFreeEx(processHandle,internalCiChar,0,winKernel.MEM_RELEASE)
		return (start,end)
コード例 #12
0
	def _get_childCount(self):
		hItem=self.treeview_hItem
		if not hItem:
			return 0
		childItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_CHILD,hItem)
		if childItem<=0:
			return 0
		numItems=0
		while childItem>0:
			numItems+=1
			childItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_NEXT,childItem)
		return numItems
コード例 #13
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getOffsetFromPoint(self,x,y):
		(left,top,width,height)=self.obj.location
		if self.obj.editAPIVersion>=1:
			processHandle=self.obj.processHandle
			internalP=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(PointLStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
			p=PointLStruct(x-left,y-top)
			winKernel.writeProcessMemory(processHandle,internalP,ctypes.byref(p),ctypes.sizeof(p),None)
			offset=winUser.sendMessage(self.obj.windowHandle,EM_CHARFROMPOS,0,internalP)
			winKernel.virtualFreeEx(processHandle,internalP,0,winKernel.MEM_RELEASE)
		else:
			p=(x-left)+((y-top)<<16)
			offset=winUser.sendMessage(self.obj.windowHandle,EM_CHARFROMPOS,0,p)&0xffff
		return offset
コード例 #14
0
 def reportConnectionStatus(self, connecting=False):
     # Same routine as SAM encoder: use a thread to prevent blocking NVDA commands.
     SPLWin = user32.FindWindowA("SPLStudio", None)
     attempt = 0
     messageCache = ""
     # Status flags.
     connected = False
     while True:
         time.sleep(0.001)
         try:
             # An inner try block is required because statChild may say the base class is gone.
             try:
                 statChild = self.children[1]
             except NotImplementedError:
                 return  # Only seen when the encoder dies.
         except IndexError:
             return  # Don't leave zombie objects around.
         if messageCache != statChild.name:
             messageCache = statChild.name
             if not messageCache: return
             if "Kbps" not in messageCache:
                 self.encoderStatusMessage(messageCache,
                                           self.IAccessibleChildID)
         if messageCache == "Disconnected":
             connected = False
             if connecting: continue
         elif messageCache == "Connected":
             connecting = False
             # We're on air, so exit.
             if not connected: tones.beep(1000, 150)
             if self.focusToStudio and not connected:
                 user32.SetForegroundWindow(
                     user32.FindWindowA("TStudioForm", None))
             if self.playAfterConnecting and not connected:
                 if winUser.sendMessage(SPLWin, 1024, 0,
                                        SPL_TrackPlaybackStatus) == 0:
                     winUser.sendMessage(SPLWin, 1024, 0, SPLPlay)
             if not connected: connected = True
         elif "Unable to connect" in messageCache or "Failed" in messageCache or statChild.name == "AutoConnect stopped.":
             if connected: connected = False
         else:
             if connected: connected = False
             if not "Kbps" in messageCache:
                 attempt += 1
                 if attempt % 250 == 0 and self.connectionTone:
                     tones.beep(500, 50)
                     if attempt >= 500 and statChild.name == "Disconnected":
                         tones.beep(250, 250)
             if connecting: continue
         if not self.backgroundMonitor: return
コード例 #15
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getSelectionOffsets(self):
		if self.obj.editAPIVersion>=1:
			charRange=CharRangeStruct()
			processHandle=self.obj.processHandle
			internalCharRange=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(charRange),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
			winUser.sendMessage(self.obj.windowHandle,EM_EXGETSEL,0, internalCharRange)
			winKernel.readProcessMemory(processHandle,internalCharRange,ctypes.byref(charRange),ctypes.sizeof(charRange),None)
			winKernel.virtualFreeEx(processHandle,internalCharRange,0,winKernel.MEM_RELEASE)
			return (charRange.cpMin,charRange.cpMax)
		else:
			start=ctypes.c_uint()
			end=ctypes.c_uint()
			res=winUser.sendMessage(self.obj.windowHandle,EM_GETSEL,ctypes.byref(start),ctypes.byref(end))
			return start.value,end.value
コード例 #16
0
	def _get_parent(self):
		if self.IAccessibleChildID==0:
			return super(TreeViewItem,self)._get_parent()
		hItem=self.treeview_hItem
		if not hItem:
			return super(TreeViewItem,self)._get_parent()
		parentItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_PARENT,hItem)
		if parentItem<=0:
			return super(TreeViewItem,self)._get_parent()
		newID=winUser.sendMessage(self.windowHandle,TVM_MAPHTREEITEMTOACCID,parentItem,0)
		if not newID:
			# Tree views from comctl < 6.0 use the hItem as the child ID.
			newID=parentItem
		return IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=newID)
コード例 #17
0
	def _get_name(self):
		hItem=winUser.sendMessage(self.windowHandle,CLM_GETSELECTION,0,0)
		internalBuf=winKernel.virtualAllocEx(self.processHandle,None,MAXITEMTEXTLEN,winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winUser.sendMessage(self.windowHandle,CLM_GETITEMTEXT,hItem,internalBuf)
		buf=create_unicode_buffer(MAXITEMTEXTLEN)
		winKernel.readProcessMemory(self.processHandle,internalBuf,buf,MAXITEMTEXTLEN,None)
		text=buf.value
		statusMsgPtr=winUser.sendMessage(self.windowHandle,CLM_GETSTATUSMSG,hItem,0)
		if statusMsgPtr>0:
			buf2=create_unicode_buffer(MAXSTATUSMSGLEN)
			winKernel.readProcessMemory(self.processHandle,statusMsgPtr,buf2,MAXSTATUSMSGLEN,None)
			text="%s %s"%(text,buf2.value)
		winKernel.virtualFreeEx(self.processHandle,internalBuf,0,winKernel.MEM_RELEASE)
		return text
コード例 #18
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getStoryLength(self):
		if self.obj.editAPIVersion>=2:
			info=getTextLengthExStruct()
			info.flags=GTL_NUMCHARS
			if self.obj.isWindowUnicode:
				info.codepage=1200
			else:
				info.codepage=0
			processHandle=self.obj.processHandle
			internalInfo=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(info),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
			winKernel.writeProcessMemory(processHandle,internalInfo,ctypes.byref(info),ctypes.sizeof(info),None)
			textLen=winUser.sendMessage(self.obj.windowHandle,EM_GETTEXTLENGTHEX,internalInfo,0)
			winKernel.virtualFreeEx(processHandle,internalInfo,0,winKernel.MEM_RELEASE)
			return textLen+1
		else:
			return winUser.sendMessage(self.obj.windowHandle,winUser.WM_GETTEXTLENGTH,0,0)+1
コード例 #19
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getTextRange(self,start,end):
		if self.obj.editAPIVersion>=2:
			bufLen=((end-start)+1)*2
			if self.obj.isWindowUnicode:
				textRange=TextRangeUStruct()
			else:
				textRange=TextRangeAStruct()
			textRange.chrg.cpMin=start
			textRange.chrg.cpMax=end
			processHandle=self.obj.processHandle
			internalBuf=winKernel.virtualAllocEx(processHandle,None,bufLen,winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
			textRange.lpstrText=internalBuf
			internalTextRange=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(textRange),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
			winKernel.writeProcessMemory(processHandle,internalTextRange,ctypes.byref(textRange),ctypes.sizeof(textRange),None)
			res=winUser.sendMessage(self.obj.windowHandle,EM_GETTEXTRANGE,0,internalTextRange)
			winKernel.virtualFreeEx(processHandle,internalTextRange,0,winKernel.MEM_RELEASE)
			buf=(ctypes.c_byte*bufLen)()
			winKernel.readProcessMemory(processHandle,internalBuf,buf,bufLen,None)
			winKernel.virtualFreeEx(processHandle,internalBuf,0,winKernel.MEM_RELEASE)
			if self.obj.isWindowUnicode or (res>1 and (buf[res]!=0 or buf[res+1]!=0)): 
				return ctypes.cast(buf,ctypes.c_wchar_p).value
			else:
				return unicode(ctypes.cast(buf,ctypes.c_char_p).value, errors="replace", encoding=locale.getlocale()[1])
		else:
			return self._getStoryText()[start:end]
コード例 #20
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getLineOffsets(self,offset):
		lineNum=self._getLineNumFromOffset(offset)
		start=winUser.sendMessage(self.obj.windowHandle,EM_LINEINDEX,lineNum,0)
		length=winUser.sendMessage(self.obj.windowHandle,EM_LINELENGTH,offset,0)
		end=start+length
		#If we just seem to get invalid line info, calculate manually
		if start<=0 and end<=0 and lineNum<=0 and self._getLineCount()<=0 and self._getStoryLength()>0:
			return super(EditTextInfo,self)._getLineOffsets(offset)
		#Some edit controls that show both line feed and carage return can give a length not including the line feed
		if end<=offset:
			end=offset+1
		#edit controls lye about their line length
		limit=self._getStoryLength()
		while self._getLineNumFromOffset(end)==lineNum and end<limit:
			end+=1
		return (start,end)
コード例 #21
0
	def _get_treeview_hItem(self):
		if not hasattr(self,'_treeview_hItem'):
			self._treeview_hItem=winUser.sendMessage(self.windowHandle,TVM_MAPACCIDTOHTREEITEM,self.IAccessibleChildID,0)
			if not self._treeview_hItem:
				# Tree views from comctl < 6.0 use the hItem as the child ID.
				self._treeview_hItem=self.IAccessibleChildID
		return self._treeview_hItem
コード例 #22
0
ファイル: splbase.py プロジェクト: josephsl/stationPlaylist
def studioAPI(arg, command):
	if not studioIsRunning(justChecking=True):
		return
	debugOutput("Studio API wParem is %s, lParem is %s"%(arg, command))
	val = sendMessage(_SPLWin, 1024, arg, command)
	debugOutput("Studio API result is %s"%val)
	return val
コード例 #23
0
ファイル: encoders.py プロジェクト: josephsl/stationPlaylist
	def reportConnectionStatus(self, connecting=False):
		# Same routine as SAM encoder: use a thread to prevent blocking NVDA commands.
		SPLWin = user32.FindWindowW(u"SPLStudio", None)
		attempt = 0
		messageCache = ""
		# Status flags.
		connected = False
		while True:
			time.sleep(0.001)
			try:
				# An inner try block is required because statChild may say the base class is gone.
				try:
					statChild = self.children[1]
				except NotImplementedError:
					return # Only seen when the encoder dies.
			except IndexError:
				return # Don't leave zombie objects around.
			if messageCache != statChild.name:
				messageCache = statChild.name
				if not messageCache: return
				if "Kbps" not in messageCache:
					self.encoderStatusMessage(messageCache, self.IAccessibleChildID)
			if messageCache == "Disconnected":
				connected = False
				if connecting: continue
			elif messageCache == "Connected":
				connecting = False
				# We're on air, so exit.
				if not connected: tones.beep(1000, 150)
				if self.focusToStudio and not connected:
					user32.SetForegroundWindow(user32.FindWindowW(u"TStudioForm", None))
				if self.playAfterConnecting and not connected:
					if sendMessage(SPLWin, 1024, 0, SPL_TrackPlaybackStatus) == 0:
						sendMessage(SPLWin, 1024, 0, SPLPlay)
				if not connected: connected = True
			elif "Unable to connect" in messageCache or "Failed" in messageCache or statChild.name == "AutoConnect stopped.":
				if connected: connected = False
			else:
				if connected: connected = False
				if not "Kbps" in messageCache:
					attempt += 1
					if attempt%250 == 0 and self.connectionTone:
						tones.beep(500, 50)
						if attempt>= 500 and statChild.name == "Disconnected":
							tones.beep(250, 250)
				if connecting: continue
			if not self.backgroundMonitor: return
コード例 #24
0
ファイル: __init__.py プロジェクト: josephsl/stationPlaylist
	def script_cartsWithoutBorders(self, gesture):
		try:
			modifier, cart = gesture.displayName.split("+")
		except ValueError:
			modifier, cart = None, gesture.displayName
		# Pull in modifier values from the following list.
		modifier = (None, "shift", "ctrl", "alt").index(modifier)
		# #85 (18.11.1/18.09.5-LTS): Cart index formula has changed in Studio 5.30.
		# Both start with the following.
		cart = (self.fnCartKeys+self.numCartKeys).index(cart)+1
		# Studio 5.20 and earlier requires setting high (cart) and low (modifier) words (multiplying by 64K+1).
		if sendMessage(SPLWin, 1024, 0, SPLVersion) < 530:
			cart = (cart * 0x00010000) + modifier+1
		# Whereas simplified to cart bank setup in Studio 5.30 and later.
		else: cart += (modifier * 24)
		sendMessage(SPLWin,1024,cart,SPLCartPlayer)
		self.finish()
コード例 #25
0
ファイル: splbase.py プロジェクト: nvda-es/stationPlaylist
def studioAPI(arg, command):
    if _SPLWin is None:
        if not user32.FindWindowW(u"SPLStudio", None):
            debugOutput("Studio handle not found")
            return
    debugOutput("Studio API wParem is %s, lParem is %s" % (arg, command))
    val = sendMessage(_SPLWin, 1024, arg, command)
    debugOutput("Studio API result is %s" % val)
    return val
コード例 #26
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getCharFormat(self,offset):
		oldSel=self._getSelectionOffsets()
		if oldSel!=(offset,offset+1):
			self._setSelectionOffsets(offset,offset+1)
		if self.obj.isWindowUnicode:
			charFormatStruct=CharFormat2WStruct
		else:
			charFormatStruct=CharFormat2AStruct
		charFormat=charFormatStruct()
		charFormat.cbSize=ctypes.sizeof(charFormatStruct)
		processHandle=self.obj.processHandle
		internalCharFormat=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(charFormat),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winKernel.writeProcessMemory(processHandle,internalCharFormat,ctypes.byref(charFormat),ctypes.sizeof(charFormat),None)
		winUser.sendMessage(self.obj.windowHandle,EM_GETCHARFORMAT,SCF_SELECTION, internalCharFormat)
		winKernel.readProcessMemory(processHandle,internalCharFormat,ctypes.byref(charFormat),ctypes.sizeof(charFormat),None)
		winKernel.virtualFreeEx(processHandle,internalCharFormat,0,winKernel.MEM_RELEASE)
		if oldSel!=(offset,offset+1):
			self._setSelectionOffsets(oldSel[0],oldSel[1])
		return charFormat
コード例 #27
0
	def _get_lvAppImageID(self):
		item=LVItemStruct(iItem=self.IAccessibleChildID-1,mask=LVIF_IMAGE)
		(processID,threadID)=winUser.getWindowThreadProcessID(self.windowHandle)
		processHandle=self.processHandle
		internalItem=winKernel.virtualAllocEx(processHandle,None,sizeof(LVItemStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winKernel.writeProcessMemory(processHandle,internalItem,byref(item),sizeof(LVItemStruct),None)
		winUser.sendMessage(self.windowHandle,LVM_GETITEM,0,internalItem)
		dispInfo=NMLVDispInfoStruct()
		dispInfo.item=internalItem
		dispInfo.hdr.hwndFrom=self.windowHandle
		dispInfo.hdr.idFrom=self.windowControlID
		dispInfo.hdr.code=LVN_GETDISPINFO
		internalDispInfo=winKernel.virtualAllocEx(processHandle,None,sizeof(NMLVDispInfoStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winKernel.writeProcessMemory(processHandle,internalDispInfo,byref(dispInfo),sizeof(NMLVDispInfoStruct),None)
		winUser.sendMessage(self.parent.parent.windowHandle,winUser.WM_NOTIFY,LVN_GETDISPINFO,internalDispInfo)
		winKernel.virtualFreeEx(processHandle,internalDispInfo,0,winKernel.MEM_RELEASE)
		winKernel.readProcessMemory(processHandle,internalItem,byref(item),sizeof(LVItemStruct),None)
		winKernel.virtualFreeEx(processHandle,internalItem,0,winKernel.MEM_RELEASE)
		return item.iImage
コード例 #28
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getPointFromOffset(self,offset):
		if self.obj.editAPIVersion==1:
			processHandle=self.obj.processHandle
			internalP=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(PointLStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
			p=PointLStruct(0,0)
			winKernel.writeProcessMemory(processHandle,internalP,ctypes.byref(p),ctypes.sizeof(p),None)
			winUser.sendMessage(self.obj.windowHandle,EM_POSFROMCHAR,internalP,offset)
			winKernel.readProcessMemory(processHandle,internalP,ctypes.byref(p),ctypes.sizeof(p),None)
			winKernel.virtualFreeEx(processHandle,internalP,0,winKernel.MEM_RELEASE)
			point=textInfos.Point(p.x,p.y)
		else:
			res=winUser.sendMessage(self.obj.windowHandle,EM_POSFROMCHAR,offset,None)
			point=textInfos.Point(winUser.LOWORD(res),winUser.HIWORD(res))
		(left,top,width,height)=self.obj.location
		if point.x and point.y:
			point.x=point.x+left
			point.y=point.y+top
			return point
		else:
			raise NotImplementedError
コード例 #29
0
	def _getTextRange(self,start,end):
		bufLen=(end-start)+1
		textRange=TextRangeStruct()
		textRange.chrg.cpMin=start
		textRange.chrg.cpMax=end
		processHandle=self.obj.processHandle
		internalBuf=winKernel.virtualAllocEx(processHandle,None,bufLen,winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		textRange.lpstrText=internalBuf
		internalTextRange=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(textRange),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winKernel.writeProcessMemory(processHandle,internalTextRange,ctypes.byref(textRange),ctypes.sizeof(textRange),None)
		winUser.sendMessage(self.obj.windowHandle,SCI_GETTEXTRANGE,0,internalTextRange)
		winKernel.virtualFreeEx(processHandle,internalTextRange,0,winKernel.MEM_RELEASE)
		buf=ctypes.create_string_buffer(bufLen)
		winKernel.readProcessMemory(processHandle,internalBuf,buf,bufLen,None)
		winKernel.virtualFreeEx(processHandle,internalBuf,0,winKernel.MEM_RELEASE)
		cp=winUser.sendMessage(self.obj.windowHandle,SCI_GETCODEPAGE,0,0)
		if cp==SC_CP_UTF8:
			return unicode(buf.value, errors="replace", encoding="utf-8")
		else:
			return unicode(buf.value, errors="replace", encoding=locale.getlocale()[1])
コード例 #30
0
	def _get_states(self):
		states=super(TreeViewItem,self)._get_states()
		hItem=self.treeview_hItem
		itemStates=winUser.sendMessage(self.windowHandle,TVM_GETITEMSTATE,hItem,TVIS_STATEIMAGEMASK)
		ch=(itemStates>>12)&3
		if ch>0:
			states.add(controlTypes.STATE_CHECKABLE)
		if ch==2:
			states.add(controlTypes.STATE_CHECKED)
		elif ch==3:
			states.add(controlTypes.STATE_HALFCHECKED)
		return states
コード例 #31
0
ファイル: edit.py プロジェクト: atsuoishimoto/tweetitloud
	def _getCharFormat(self,range):
		oldSel=self.obj.ITextSelectionObject.duplicate
		if not (oldSel.start==range.start and oldSel.end==range.end):
			self.obj.ITextSelectionObject.start=range.start
			self.obj.ITextSelectionObject.end=range.end
		if self.obj.isWindowUnicode:
			charFormatStruct=CharFormat2WStruct
		else:
			charFormatStruct=CharFormat2AStruct
		charFormat=charFormatStruct()
		charFormat.cbSize=ctypes.sizeof(charFormatStruct)
		processHandle=self.obj.processHandle
		internalCharFormat=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(charFormat),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		winKernel.writeProcessMemory(processHandle,internalCharFormat,ctypes.byref(charFormat),ctypes.sizeof(charFormat),None)
		winUser.sendMessage(self.obj.windowHandle,EM_GETCHARFORMAT,SCF_SELECTION, internalCharFormat)
		winKernel.readProcessMemory(processHandle,internalCharFormat,ctypes.byref(charFormat),ctypes.sizeof(charFormat),None)
		winKernel.virtualFreeEx(processHandle,internalCharFormat,0,winKernel.MEM_RELEASE)
		if not (oldSel.start==range.start and oldSel.end==range.end):
			self.obj.ITextSelectionObject.start=oldSel.start
			self.obj.ITextSelectionObject.end=oldSel.end
		return charFormat
コード例 #32
0
	def _get_positionInfo(self):
		if self.IAccessibleChildID==0:
			return super(TreeViewItem,self)._get_positionInfo()
		info={}
		info['level']=self.treeview_level
		hItem=self.treeview_hItem
		if not hItem:
			return info
		newItem=hItem
		index=0
		while newItem>0:
			index+=1
			newItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_PREVIOUS,newItem)
		newItem=hItem
		numItems=index-1
		while newItem>0:
			numItems+=1
			newItem=winUser.sendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_NEXT,newItem)
		info['indexInGroup']=index
		info['similarItemsInGroup']=numItems
		return info
コード例 #33
0
 def _get_name(self):
     curIndex = winUser.sendMessage(self.appModule.hwndWinamp, WM_WA_IPC,
                                    -1, IPC_PLAYLIST_GET_NEXT_SELECTED)
     if curIndex < 0:
         return None
     info = fileinfo2W()
     info.fileindex = curIndex
     internalInfo = winKernel.virtualAllocEx(self.processHandle, None,
                                             sizeof(info),
                                             winKernel.MEM_COMMIT,
                                             winKernel.PAGE_READWRITE)
     winKernel.writeProcessMemory(self.processHandle, internalInfo,
                                  byref(info), sizeof(info), None)
     winUser.sendMessage(self.windowHandle, WM_WA_IPC, IPC_PE_GETINDEXTITLE,
                         internalInfo)
     winKernel.readProcessMemory(self.processHandle, internalInfo,
                                 byref(info), sizeof(info), None)
     winKernel.virtualFreeEx(self.processHandle, internalInfo, 0,
                             winKernel.MEM_RELEASE)
     return str("%d.\t%s\t%s" %
                (curIndex + 1, info.filetitle, info.filelength))
コード例 #34
0
	def event_gainFocus(self):
		#See if this object is the focus and the focus is on a group item.
		#if so, then morph this object to a groupingItem object
		if self is api.getFocusObject():
			groupIndex=winUser.sendMessage(self.windowHandle,LVM_GETFOCUSEDGROUP,0,0)
			if groupIndex>=0:
				info=getListGroupInfo(self.windowHandle,groupIndex)
				if info is not None:
					ancestors=api.getFocusAncestors()
					if api.getFocusDifferenceLevel()==len(ancestors)-1:
						self.event_focusEntered()
					groupingObj=GroupingItem(windowHandle=self.windowHandle,parentNVDAObject=self,groupInfo=info)
					return eventHandler.queueEvent("gainFocus",groupingObj)
		return super(List,self).event_gainFocus()
コード例 #35
0
ファイル: splmisc.py プロジェクト: Austinsmom/stationPlaylist
def _getColumnContent(obj, col):
	import winKernel
	from NVDAObjects.IAccessible import sysListView32
	# Borrowed from SysListView32 implementation.
	buffer=None
	processHandle=obj.processHandle
	sizeofLVITEM = ctypes.sizeof(sysListView32.LVITEM)
	internalItem=winKernel.virtualAllocEx(processHandle,None,sizeofLVITEM,winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
	try:
		internalText=winKernel.virtualAllocEx(processHandle,None,520,winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
		try:
			item=sysListView32.LVITEM(iItem=obj.IAccessibleChildID-1,mask=sysListView32.LVIF_TEXT|sysListView32.LVIF_COLUMNS,iSubItem=col,pszText=internalText,cchTextMax=260)
			winKernel.writeProcessMemory(processHandle,internalItem,ctypes.byref(item),sizeofLVITEM,None)
			len = sendMessage(obj.windowHandle,sysListView32.LVM_GETITEMTEXTW, (obj.IAccessibleChildID-1), internalItem)
			if len:
				winKernel.readProcessMemory(processHandle,internalItem,ctypes.byref(item),sizeofLVITEM,None)
				buffer=ctypes.create_unicode_buffer(len)
				winKernel.readProcessMemory(processHandle,item.pszText,buffer,ctypes.sizeof(buffer),None)
		finally:
			winKernel.virtualFreeEx(processHandle,internalText,0,winKernel.MEM_RELEASE)
	finally:
		winKernel.virtualFreeEx(processHandle,internalItem,0,winKernel.MEM_RELEASE)
	return buffer.value if buffer else None
コード例 #36
0
 def getOutputTime(self, mode):
     return winUser.sendMessage(self.hwndWinamp, WM_WA_IPC, mode,
                                IPC_GETOUTPUTTIME)
コード例 #37
0
 def reportConnectionStatus(self, connecting=False):
     # Keep an eye on the stream's description field for connection changes.
     # In order to not block NVDA commands, this will be done using a different thread.
     SPLWin = user32.FindWindowA("SPLStudio", None)
     toneCounter = 0
     messageCache = ""
     # Status message flags.
     idle = False
     error = False
     encoding = False
     alreadyEncoding = False
     while True:
         time.sleep(0.001)
         try:
             if messageCache != self.description[self.description.
                                                 find("Status") + 8:]:
                 messageCache = self.description[self.description.
                                                 find("Status") + 8:]
                 if not messageCache.startswith("Encoding"):
                     self.encoderStatusMessage(messageCache,
                                               self.IAccessibleChildID)
         except AttributeError:
             return
         if messageCache.startswith("Idle"):
             if alreadyEncoding: alreadyEncoding = False
             if encoding: encoding = False
             if not idle:
                 tones.beep(250, 250)
                 idle = True
                 toneCounter = 0
         elif messageCache.startswith("Error"):
             # Announce the description of the error.
             if connecting: connecting = False
             if not error:
                 error = True
                 toneCounter = 0
             if alreadyEncoding: alreadyEncoding = False
         elif messageCache.startswith("Encoding"):
             if connecting: connecting = False
             # We're on air, so exit unless told to monitor for connection changes.
             if not encoding:
                 tones.beep(1000, 150)
                 self.encoderStatusMessage(messageCache,
                                           self.IAccessibleChildID)
             if self.focusToStudio and not encoding:
                 if api.getFocusObject().appModule == "splstudio":
                     continue
                 user32.SetForegroundWindow(
                     user32.FindWindowA("TStudioForm", None))
             # #37 (17.08.1): if run from another function, the message will not be sent, so must be done here.
             if self.playAfterConnecting and not encoding:
                 # Do not interupt the currently playing track.
                 if winUser.sendMessage(SPLWin, 1024, 0,
                                        SPL_TrackPlaybackStatus) == 0:
                     winUser.sendMessage(SPLWin, 1024, 0, SPLPlay)
             if not encoding: encoding = True
         else:
             if alreadyEncoding: alreadyEncoding = False
             if encoding: encoding = False
             elif "Error" not in self.description and error: error = False
             toneCounter += 1
             if toneCounter % 250 == 0 and self.connectionTone:
                 tones.beep(500, 50)
         if connecting: continue
         if not self.backgroundMonitor: return
コード例 #38
0
	def replaceWord(self, before, after):
		self.textInfo.updateSelection()
		for char in after:
			winUser.sendMessage(self.object.windowHandle, win32con.WM_CHAR, ord(char), 0)
コード例 #39
0
 def getVolume(self):
     return winUser.sendMessage(self.hwndWinamp, WM_WA_IPC, -666,
                                IPC_SETVOLUME)
コード例 #40
0
 def getRepeat(self):
     return winUser.sendMessage(self.hwndWinamp, WM_WA_IPC, 0,
                                IPC_GET_REPEAT)
コード例 #41
0
 def getShuffle(self):
     return winUser.sendMessage(self.hwndWinamp, WM_WA_IPC, 0,
                                IPC_GET_SHUFFLE)
コード例 #42
0
 def jumpToTime(self, ms):
     return winUser.sendMessage(self.hwndWinamp, WM_WA_IPC, ms,
                                IPC_JUMPTOTIME)
コード例 #43
0
 def setVolume(self, vol):
     return winUser.sendMessage(self.hwndWinamp, WM_WA_IPC, vol,
                                IPC_SETVOLUME)
コード例 #44
0
 def setPanning(self, pan):
     return winUser.sendMessage(self.hwndWinamp, WM_WA_IPC, pan,
                                IPC_SETPANNING)
コード例 #45
0
 def getPanning(self):
     return winUser.sendMessage(self.hwndWinamp, WM_WA_IPC, -666,
                                IPC_SETPANNING)
コード例 #46
0
def maximizeWindow(hWnd):
    winUser.sendMessage(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
コード例 #47
0
def modifyVolume(vkKey):
    h = findWindowNVDAObject("volume").windowHandle
    sendMessage(h, WM_KEYDOWN, vkKey, 0)
    sendMessage(h, WM_KEYUP, vkKey, 0)
    ui.message(_("%s percent") % getVolume())