#FEATURE by stefan
authorStefan Vogel <sv@exept.de>
Tue, 13 Aug 2019 16:58:50 +0200
changeset 8768 b6d390b45b83
parent 8767 9e9c1d77d8f8
child 8769 cf72c15576f2
#FEATURE by stefan class: WinWorkstation added: #primSetWindowTextW:to: #sendChar:at:toWindowId: #sendKeyMessageType:keyCode:at:toWindowId: #sendKeyPress:at:toWindowId: #sendKeyRelease:at:toWindowId: #setWindowText:to: comment/format in: #topWindowIdsDo: Add methods used in WindowAccessLibrary.ets
WinWorkstation.st
--- a/WinWorkstation.st	Mon Aug 12 17:28:57 2019 +0200
+++ b/WinWorkstation.st	Tue Aug 13 16:58:50 2019 +0200
@@ -13425,6 +13425,67 @@
     "get a window's title text"
 
     <apicall: int "InternalGetWindowText" (handle, pointer, int) module: "user32.dll" >
+!
+
+primSetWindowTextW:aWindowId to:aWideString
+    "set a window's title text"
+
+    <apicall: int "SetWindowTextW" (handle, pointer) module: "user32.dll" >
+!
+
+sendChar:keyCode at:aPoint toWindowId:aWindowId
+    "send a char message to a window by id (handle)"
+
+    self 
+        sendKeyMessageType:16r0102 "WM_CHAR" 
+        keyCode:keyCode 
+        at:aPoint 
+        toWindowId:aWindowId
+
+    "Modified: / 09-08-2019 / 12:00:48 / Stefan Vogel"
+!
+
+sendKeyMessageType:messageType keyCode:keyCode at:aPoint toWindowId:aWindowId
+    "send a keyboard message to a window by id (handle)"
+
+    |lParam|
+
+    (aWindowId isNil or:[aWindowId address == 0]) ifTrue:[^ self].
+
+    lParam := (aPoint x) + (aPoint y bitShift:16).
+    ^ self primSendMessage:aWindowId message:messageType wParamInt:keyCode lParamInt:lParam.
+
+    "Modified: / 09-08-2019 / 12:00:05 / Stefan Vogel"
+!
+
+sendKeyPress:keyCode at:aPoint toWindowId:aWindowId
+    "send a key press message to a window by id (handle)"
+
+    self 
+        sendKeyMessageType:16r0100 "WM_KEYDOWN" 
+        keyCode:keyCode 
+        at:aPoint 
+        toWindowId:aWindowId
+
+    "Modified: / 09-08-2019 / 11:59:33 / Stefan Vogel"
+!
+
+sendKeyRelease:keyCode at:aPoint toWindowId:aWindowId
+    "send a key release message to a window by id (handle)"
+
+    self 
+        sendKeyMessageType:16r0101 "WM_KEYUP"
+        keyCode:keyCode 
+        at:aPoint 
+        toWindowId:aWindowId
+
+    "Modified: / 09-08-2019 / 12:01:29 / Stefan Vogel"
+!
+
+setWindowText:aWindowId to:aString
+    "get a window's title text"
+
+    self primSetWindowTextW:aWindowId to:(aString asUnicode16String).
 ! !
 
 !WinWorkstation methodsFor:'font stuff'!
@@ -20121,37 +20182,33 @@
     l := OrderedCollection new.
     self primEnumWindowsInto:l.
     l do:[:eachWindowId |
-	(self getParentWindowIdOfWindowId:eachWindowId) isNil ifTrue:[
-	    "/ a topView
-	    aBlock value:eachWindowId
-	]
+        (self getParentWindowIdOfWindowId:eachWindowId) isNil ifTrue:[
+            "/ a topView
+            aBlock value:eachWindowId
+        ]
     ].
     ^ nil
 
     "
      Display topWindowIdsDo:[:id |
-	|nm|
-
-	nm := String new:100.
-	Transcript showCR:id.
-	Display primGetWindowText:id into:nm size:nm size-1.
-	Transcript showCR:nm.
+        Transcript show:id; show:': .... '; showCR:(Display getWindowText:id).
      ].
     "
 
     "
      |w|
      Display topWindowIdsDo:[:id |
-	|nm|
-
-	nm := String new:100.
-	Display primGetWindowText:id into:nm size:nm size-1.
-	(nm includesString:'Mortal') ifTrue:[
-	    w := id.
-	]
+        |nm|
+
+        nm := Display getWindowText:id.
+        (nm includesString:'Mortal') ifTrue:[
+            w := id.
+        ]
      ].
      Display resizeWindow:w width:1024 height:1024
     "
+
+    "Modified (comment): / 09-08-2019 / 11:54:25 / Stefan Vogel"
 !
 
 unmapWindow:aWindowId