Windows 8.1 AHK High CPU Usage (VMWare Workstation)
-
- Posts: 9
- Joined: 30 Jul 2022, 03:43
Windows 8.1 AHK High CPU Usage (VMWare Workstation)
Hello.
There is a long script that I wrote myself. This script works normally in Windows 7 and Windows 10 with VMWare Workstation, but in Windows 8 and Windows 8.1 it freezes after a while and starts to consume a lot of CPU.
A script I wrote for a game, after the game starts, AHK starts to load too much on the CPU.
Windows 8.1 Windows 7 (It's usually around 1%-4%, it's very normal) I've tried many versions of Windows 8.1 but they're all the same.
In some versions of Windows 10 and Windows 7, I had the same problems as in Windows 8.1, but I could not find the cause of the problem.
Any ideas?
There is a long script that I wrote myself. This script works normally in Windows 7 and Windows 10 with VMWare Workstation, but in Windows 8 and Windows 8.1 it freezes after a while and starts to consume a lot of CPU.
A script I wrote for a game, after the game starts, AHK starts to load too much on the CPU.
Windows 8.1 Windows 7 (It's usually around 1%-4%, it's very normal) I've tried many versions of Windows 8.1 but they're all the same.
In some versions of Windows 10 and Windows 7, I had the same problems as in Windows 8.1, but I could not find the cause of the problem.
Any ideas?
-
- Posts: 9
- Joined: 30 Jul 2022, 03:43
Re: Windows 8.1 AHK High CPU Usage (VMWare Workstation)
Okey, i found the problem... It happens when I try to get data with API, I have no idea how to fix the problem...
Any help?
Any help?
Re: Windows 8.1 AHK High CPU Usage (VMWare Workstation)
u may have allocated a different number of cores to the win8.1 vm, skewing the results. other that that there wont be any ideas without seeing the code
-
- Posts: 9
- Joined: 30 Jul 2022, 03:43
Re: Windows 8.1 AHK High CPU Usage (VMWare Workstation)
Hey, i found the problem but idk how to fix.
I have this problem when I try to get data using API.
I'm using this
Code: Select all
StdOutToVar(cmd)
{
DllCall("CreatePipe", "PtrP", hReadPipe, "PtrP", hWritePipe, "Ptr", 0, "UInt", 0)
DllCall("SetHandleInformation", "Ptr", hWritePipe, "UInt", 1, "UInt", 1)
VarSetCapacity(PROCESS_INFORMATION, (A_PtrSize == 4 ? 16 : 24), 0) ; http://goo.gl/dymEhJ
cbSize := VarSetCapacity(STARTUPINFO, (A_PtrSize == 4 ? 68 : 104), 0) ; http://goo.gl/QiHqq9
NumPut(cbSize, STARTUPINFO, 0, "UInt") ; cbSize
NumPut(0x100, STARTUPINFO, (A_PtrSize == 4 ? 44 : 60), "UInt") ; dwFlags
NumPut(hWritePipe, STARTUPINFO, (A_PtrSize == 4 ? 60 : 88), "Ptr") ; hStdOutput
NumPut(hWritePipe, STARTUPINFO, (A_PtrSize == 4 ? 64 : 96), "Ptr") ; hStdError
if !DllCall(
(Join Q C
"CreateProcess", ; http://goo.gl/9y0gw
"Ptr", 0, ; lpApplicationName
"Ptr", &cmd, ; lpCommandLine
"Ptr", 0, ; lpProcessAttributes
"Ptr", 0, ; lpThreadAttributes
"UInt", true, ; bInheritHandles
"UInt", 0x08000000, ; dwCreationFlags
"Ptr", 0, ; lpEnvironment
"Ptr", 0, ; lpCurrentDirectory
"Ptr", &STARTUPINFO, ; lpStartupInfo
"Ptr", &PROCESS_INFORMATION ; lpProcessInformation
)) {
DllCall("CloseHandle", "Ptr", hWritePipe)
DllCall("CloseHandle", "Ptr", hReadPipe)
return ""
}
DllCall("CloseHandle", "Ptr", hWritePipe)
VarSetCapacity(buffer, 4096, 0)
while DllCall("ReadFile", "Ptr", hReadPipe, "Ptr", &buffer, "UInt", 4096, "UIntP", dwRead, "Ptr", 0)
sOutput .= StrGet(&buffer, dwRead, "CP0")
DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION, 0)) ; hProcess
DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION, A_PtrSize)) ; hThread
DllCall("CloseHandle", "Ptr", hReadPipe)
return sOutput
}
Re: Windows 8.1 AHK High CPU Usage (VMWare Workstation)
doubt thats the issue
-
- Posts: 9
- Joined: 30 Jul 2022, 03:43
Re: Windows 8.1 AHK High CPU Usage (VMWare Workstation)
Code: Select all
GoldCheck()
{
strStdOut:=StdOutToVar("curl --insecure https://127.0.0.1:2999/liveclientdata/activeplayer")
goldPos := InStr(strStdOut, "currentGold" , CaseSensitive := true, StartingPos := 1, Occurrence := 1)
offset:=0
while (char!=".")
{
offset:=offset+1
char:=SubStr(strStdOut, goldPos+12+offset, 1)
}
goldEndPos:=goldPos+offset-2
lenght:=(goldEndPos-goldPos)
currentGold := SubStr(strStdOut, goldPos+14, lenght)
return %currentGold%
}
OS without issue also gives this output, there is no problem but OS with issue also gives blank output
There is absolutely no problem with the codes, as long as I use While properly, it gives the output it should like this But when I use while properly, the script gets stuck on the problematic OS and the CPU rises...
For example, I installed two different modified Windows 7 operating systems on the same computer via VMWare, but the script works fine in one and does not work in the other.
In Windows 8 or 8.1, it does not work properly in either of them.
Do not be misunderstood when I say it is problematic, there is no problem in any operating system, but it happens as I described and idk why
Re: Windows 8.1 AHK High CPU Usage (VMWare Workstation)
if StdOutToVar returns an empty string(a possibility which u arent accounting for), ull enter an infinite while-loop
StdOutToVar returns an empty string if the CreateProcess dllcall fails. to find out why it might be failing u need to check the dllcall's return value, ErrorLevel and A_LastError and compare the reported error values against the microsoft documentation
another possibility is that ur curl command returns an empty string
StdOutToVar returns an empty string if the CreateProcess dllcall fails. to find out why it might be failing u need to check the dllcall's return value, ErrorLevel and A_LastError and compare the reported error values against the microsoft documentation
another possibility is that ur curl command returns an empty string
-
- Posts: 9
- Joined: 30 Jul 2022, 03:43
Re: Windows 8.1 AHK High CPU Usage (VMWare Workstation)
Hello again, I'm sorry to disturb you. I took a video and recorded all the codes and outputs.swagfag wrote: ↑02 Feb 2023, 08:28if StdOutToVar returns an empty string(a possibility which u arent accounting for), ull enter an infinite while-loop
StdOutToVar returns an empty string if the CreateProcess dllcall fails. to find out why it might be failing u need to check the dllcall's return value, ErrorLevel and A_LastError and compare the reported error values against the microsoft documentation
another possibility is that ur curl command returns an empty string
I have no idea how the StdOutToVar part works, I got it from someone else.
So I have no idea how I should arrange them, but I don't think there is a mistake.
You can see everything in the video, same codes, different results.
https://www.youtube.com/watch?v=cZkTcJl2ciE
Re: Windows 8.1 AHK High CPU Usage (VMWare Workstation)
dont change the while-loop, because it's pointless to do so and it won't fix anything. this isn't where the problem is.
it is as i said. either CreateProcess fails or the curl command is returning an empty string. u need to troubleshoot that first
it is as i said. either CreateProcess fails or the curl command is returning an empty string. u need to troubleshoot that first