
DLS
Members-
Posts
9 -
Joined
-
Last visited
Everything posted by DLS
-
I got it to work. Heres the code if someone needs it. Relevant Function Func _IsWindowOnCurrentVirtualDesktop($hWnd) $CLSID = "{aa509086-5ca9-4c25-8f95-589d3c07b48a}" $IID = "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}" $TAG = "IsWindowOnCurrentVirtualDesktop hresult(hwnd;ptr*);" $IVirtualDesktopManager = ObjCreateInterface($CLSID, $IID, $TAG) $Result = False $IVirtualDesktopManager.IsWindowOnCurrentVirtualDesktop($hWnd, $Result) $IVirtualDesktopManager = 0 Return $Result EndFunc Entire Program #requireadmin #include <WinAPI.au3> #include <WinAPIProc.au3> #include <ProcessConstants.au3> $Process = ProcessList("processname.exe") For $i = 1 To $Process[0][0] $pid = $Process[$i][1] $handle = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION+$PROCESS_SET_INFORMATION, False, $pid) $hWnd = _GetWindowHandleFromPid($pid) ProcessSetPriority ($pid, 0 ) ;set cpu priority _WinAPI_SetProcessAffinityMask($handle, 0x08) ;set cpu affinity ;msgbox(0,"",$Process[$i][0] & " " & $Process[$i][1] & " " & $handle & " " & $hWnd ) ;debug ;msgbox(0, "", _IsWindowOnCurrentVirtualDesktop($hWnd)) ;debug Next Func _IsWindowOnCurrentVirtualDesktop($hWnd) $CLSID = "{aa509086-5ca9-4c25-8f95-589d3c07b48a}" $IID = "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}" $TAG = "IsWindowOnCurrentVirtualDesktop hresult(hwnd;ptr*);" $IVirtualDesktopManager = ObjCreateInterface($CLSID, $IID, $TAG) $Result = False $IVirtualDesktopManager.IsWindowOnCurrentVirtualDesktop($hWnd, $Result) $IVirtualDesktopManager = 0 Return $Result EndFunc Func _GetWindowHandleFromPid($pid) Local $aData = _WinAPI_EnumProcessWindows($pid) Return $aData[1][0] EndFunc ;~ 0x01 CPU1 binary to hex conversion reference chart with 1s for active cores and 0s for disabled ;~ 0x02 CPU2 ;~ 0x03 CPU1+2 ;~ 0x04 CPU3 ;~ 0x05 CPU1+3 ;~ 0x06 CPU2+3 ;~ 0x07 CPU1+2+3 ;~ 0x08 CPU4 ;~ 0x09 CPU1+4 ;~ 0x0A CPU2+4 ;~ 0x0B CPU1+2+4 ;~ 0x0C CPU3+4 ;~ 0x0E CPU1+3+4 ;~ 0x0F CPU1+2+3+4
- 1 reply
-
- windows 10
- windows10
-
(and 3 more)
Tagged with:
-
I have a working script that changes the core affinity and process priority of multiples of a specific application I have running. I have that part figured out. I would like to make a little modification to it. Windows10 introduced virtual desktops. I am trying to have different core affinity and priority of processes on the visible and non-visible desktops. What I need is a bool function that could be described as IsWindowOnCurrentDesktop($hWnd). I have searched the winAPI.au3 but I do not believe anything like that exists built it. I have searched multiple places before asking for help. I found a Microsoft supplied example of the function I need using C#, but I am unfamiliar with C# to a degree that I cannot port the system call over. https://blogs.msdn.microsoft.com/winsdk/2015/09/10/virtual-desktop-switching-in-windows-10/ Help is appreciated but not expected. Thanks in advanced. In the meantime I will be learning C# syntax and class structure.
- 1 reply
-
- windows 10
- windows10
-
(and 3 more)
Tagged with:
-
How to invoke option in right click menu
DLS replied to DLS's topic in AutoIt General Help and Support
Thanks for the help/ Your approach only works for the right click menu in notpad. Heres a simplified version of my actual code. #include <GuiMenu.au3> #Include <GuiListView.au3> Run("C:\Windows\System32\control.exe mmsys.cpl") $hWnd = WinWaitActive("Sound") WinActivate("[CLASS:SysListView32]") $hList = ControlGetHandle($hWnd, "", "[CLASS:SysListView32]") _GUICtrlListView_SetItemSelected($hList, 0) ;selects first item in the list Send("{APPSKEY}") ;right click menu $hMenu=_GUICtrlMenu_GetMenuBarInfo(WinGetHandle("[CLASS:#32768]"), 0, 0) $iCount = _GUICtrlMenu_GetItemCount($hMenu[4]) For $iIndex = 0 To $iCount-1 Step 1 $itemID = _GUICtrlMenu_GetItemID($hMenu[4], $iIndex, True) $itemText = _GUICtrlMenu_GetItemText($hMenu[4], $itemID, False) ConsoleWrite("Item=[" & $iIndex & "] ItemID=[" & $itemID & "] text=[" & $itemText & "]" & @CRLF) ;debug - console write all rightclick menu options If $itemText = "Disable" then ;~ For $i =0 to $iIndex step 1 ;works ;~ Send("{DOWN}") ;~ Next ;~ Send("{Enter}") ControlCommand($hWnd, "", "Edit1", "SendCommandID", $itemID) ;does not work ControlCommand($hWnd, "", "", "SendCommandID", $itemID) ;works EndIf Next The rightclick menu I am calling is not called "Edit1". It was actually called nothing. To make it more universal, is there a function I can call the returns that "Edit1" given the handle of the right click menu for furture use? -
Here's an easy to follow sample code. #include <GuiMenu.au3> Run("notepad.exe") $hWnd = WinWaitActive("[CLASS:Notepad]") Send("{APPSKEY}") If WinExists("[CLASS:#32768]") Then $hMenu = _GUICtrlMenu_GetMenuBarInfo(WinGetHandle("[CLASS:#32768]"), 0, 0) $iCount = _GUICtrlMenu_GetItemCount($hMenu[4]) For $iItem = 0 To $iCount-1 Step 1 $iID = _GUICtrlMenu_GetItemID($hMenu[4], $iItem, True) $iText = _GUICtrlMenu_GetItemText($hMenu[4], $iID, False) ConsoleWrite("Item=[" & $iItem & "] ItemID=[" & $iID & "] text=[" & $iText & "]" & @CRLF) ;console write all rightclick menu options If $iText = "&Paste" then ConsoleWrite(_GUICtrlMenu_SetItemID($hMenu,$iItem,$iID)& @CRLF) ;trying to invoke context menu item here ConsoleWrite(ControlCommand($hMenu,"","[CLASS:#32768]","SelectString",$iText) & @CRLF) ;trying to invoke context menu item here ConsoleWrite(ControlCommand($hMenu,"","[CLASS:#32768]","SendCommandID", $iID) & @CRLF) ;trying to invoke context menu item here ConsoleWrite(WinMenuSelectItem($hMenu,"",$iText)& @CRLF) ;trying to invoke context menu item here For $i =0 to $iCount-1 step 1 Send("{DOWN}") ;sucessfully invoking item, seems crude Next Send("{Enter}") EndIf Next EndIf As you can see, the only thing working is sending keyboard commands. Is there a way to get any of the other methods to work? Also is there a way to invoke the right click menu besides Send("{APPSKEY}")
-
I would like to re purpose my unused keyboard keys into useful shortcuts. HotKeySet("{BROWSER_FAVORITES}", "test") Did not work. The adjacent { BROWSER_BACK } and { BROWSER_FORWARD } do work with hotkeyset. Function _Ispressed returns 0xAB, as the key scan code. Is there a way to do HotKeySet(0xAB, "test)? I do not want to do While True If _IsPressed(0xAB) Then FuncHere EndIf Sleep(100) Wend
-
Sorry Melba I can see how that code could be repurposed into a keylogger, giving autoit a bad name. I was just using it for debugging, it wont happen again.
-
I do have a keyboard with a dedicated calculator key. I even double checked the scancode from my physical with this code below and it is registering as key 0xB7 when I press it. Note: I got the code below, to read physical keyboard scancode, off the internet. It works perfectly, I am not trying to steal someones credit. <snip> And if autoit is sending a keyboard event, why would it matter what keyboard I have. Oh well, its most likely something windows10 broke. I also have Windows10x64 updated with latest anniversary service pack.
-
I cannot seem to send the calculator key, it doesn't launch the app. Heres my code #RequireAdmin #include <WinAPISys.au3> _WinAPI_Keybd_Event ( 0xB7, $KEYEVENTF_EXTENDEDKEY ) _WinAPI_Keybd_Event ( 0xB7, $KEYEVENTF_KEYUP ) Send("{LAUNCH_APP2}") DllCall('user32.dll', 'int', 'keybd_event', 'int', 0xB7, 'int', 0, 'int', 0, 'ptr', 0) DllCall('user32.dll', 'int', 'keybd_event', 'int', 0xB7, 'int', 0, 'int', 2, 'ptr', 0) I know I can do this, but why doesn't the first method work? Run("calc.exe")
-
Hi, I was wondering if someone could tell me how I could go about or maybe even show me an example on how I would queue a macro. Lets say I have two hotkeys, 1 and 2, that are bound to two seperate macros. Lets say if I press 1211 very fast. This is what I want it to do. I want it to do macro 1, wait until it is done and then start macro 2, wait until it is done and macro 1 and so on. I've been thinking about getting key presses, storing them in an array, which would have an index variable and would rollover. But how would I run a function that has the name of the value stored in the array. ex. $queue_array = [1,2,1,1] How do I get auotit to run 1() 2() 1() 1() just by reading the function name from the array. Or is there a better way?