Jump to content

Using Send to do a hotkey not working


 Share

Go to solution Solved by pixelsearch,

Recommended Posts

I have a script that starts HWinfo in sensor logging mode and I want to use a hotkey to stop logging. I configured the HWinfo to use a key to toggle logging on/off. When I send the key in AutoIT it doesn't toggle the logging. I have configured different key combinations for the hotkey in HWinfo and none of them work with autoit. They work fine when I press them on my keyboard. The HWinfo window doesn't even need focus for it to work when I press hotkey on keyboard. I have done hotkeys before with autoit without an issue. Is there something else I need to do?

Local $cmd = "C:\Windows\System32\cmd.exe"
Local $pid = Run('"' & $cmd & '"')
Sleep(2000)
Send("%comspec% /k " & '"' & "hwinfo64.exe -lTestLog2.csv" & '"' )
Send("{ENTER}")
Sleep(4000)
WinWaitActive("HWiNFO64")
Local $hWnd = WinGetHandle("HWiNFO64")
WinClose($cmd)
Sleep(5000)
WinActivate($hWnd)
Sleep(2000)
Send("Q")
Sleep(2000)
WinClose($hWnd)

 

Link to comment
Share on other sites

Think about this : there are several GUI's in this program and you got to make sure the "Sensors status" is active when the "q" is sent

Because apart from the immediate initial small GUI (which should be hidden when unticked settings) there are at least 2 important GUI's to manage : a main one and the "Sensors status" one which contains the button you wanna work on. Here are the 2 GUI's :

HWinFO.png.547841be0c38e0ec2dbf1a47422bb78d.png

So I had some other changes in the script to manage the 2 GUI's of the program, most important lines being :

;~ Opt("WinTitleMatchMode", 1) ; 1=start (default), 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinTitleMatchMode", -2)  ; -2 matches any substring in the title (case insensitive)
...
WinActivate(" - sensors status")
WinWaitActive(" - sensors status")
Sleep(1000)
Send("q")
...

If you keep checking only on WinWaitActive("HWiNFO64") then it could be messed up because both windows start with this title on your computer (on mine it's "HWiNFO32" as seen in the pic above)

Hope this helps

Edited by pixelsearch
Link to comment
Share on other sites

Thanks @pixelsearch for the suggestions about making sure I am getting the sensor status window. When I load it from the command prompt using the command in my script I only get the sensor status window.

Send("%comspec% /k " & '"' & "hwinfo64.exe -lTestLog2.csv" & '"' )

It's weird that it doesn't accept the hotkey when the window has focus but I can work around that.

Link to comment
Share on other sites

  • Solution

There's definitely an issue with the hotkey management in HWiNFO, as read on many posts in their Forum.
For example a post I just read where one guy got the "Qq" issue, then other posts like here or there.

All I can say is I can't use at all the hotkey "Q" in any other program while the "sensors status" window is opened, which is not normal. HWiNFO "steals" the key to toggle on/off as soon as you press the "Q" key in any windows program. It's like you press a dead key that doesn't display "Q" anymore anywhere !

The guy who wrote that program (Martin) writes in one of his answers :

"The hotkey defined is a system-wide one, it's not possible to define a hot key that would work in a certain application only."

The freeware version I downloaded doesn't accept any command-line params and throws immediately this error window when I try to launch the program like you do : "hwinfo32.exe -l..."

853190934_nocommand-lineparamsinfreeHWiNFO32.png.397b482e6f6d6cd185a3ff33a1e92375.png
As you certainly got a paid version (SDK) which accepts the command-line parameters, then I suggest you open a thread on their Forum to explain your issue with the hotkey. Martin seems to answer actively there and he may find a solution.

Good luck :)

Edited by pixelsearch
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...