Xilibre Posted May 6, 2021 Share Posted May 6, 2021 (edited) #include <Misc.au3> Global $timer = 0 Global $timer2 = 0 Global $diff = 0 Global $diff2 = 0 While 1 If _IsPressed("31") Then Do Send("{SPACE}") if $timer = 0 Then Send("f") $timer = TimerInit() $diff = TimerDiff($timer) ElseIf $diff >= 30 Then $timer = 0 Endif if $timer2 = 0 Then Send("e") $timer2 = TimerInit() $diff2 = TimerDiff($timer2) ElseIf $diff2 >= 28 Then $timer2 = 0 Endif Until not _IsPressed("31") EndIf WEnd Working on holding the vk32 key down and it only triggering the initial 2 actions, then waiting for their respective timers to meet the desired wait time to trigger them again. Right now, it's only firing the first and then it just stops. The key no longer does anything. So I tried moving the diff's to the top as Global... just been reading and tweaking for a while. Any ideas? Edited May 6, 2021 by Xilibre Link to comment Share on other sites More sharing options...
pseakins Posted May 6, 2021 Share Posted May 6, 2021 1 hour ago, Xilibre said: Working on holding the vk32 key down What is a vk32 key? Phil Seakins Link to comment Share on other sites More sharing options...
argumentum Posted May 6, 2021 Share Posted May 6, 2021 11 minutes ago, pseakins said: What is a vk32 key? https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Xilibre Posted May 6, 2021 Author Share Posted May 6, 2021 Yep. It's just the virtual number for the key. So you can differentiate "A" from "a", etc. argumentum 1 Link to comment Share on other sites More sharing options...
argumentum Posted May 6, 2021 Share Posted May 6, 2021 Xilibre 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Xilibre Posted May 6, 2021 Author Share Posted May 6, 2021 (edited) Tried it a little differently... still failing. expandcollapse popup#include <Misc.au3> _Singleton(@ScriptName) While 1 hotkeyset("{END}","EndProgram") If _IsPressed("32") Then $timer = TimerInit() $timer2 = TimerInit() $timer3 = TimerInit() $InitialUse = false $InitialUse2 = false Do if $InitialUse = False Then Send("f") $InitialUse = True EndIf Send("{SPACE}") if TimerDiff($timer) > 30000 Then Send("f") $timer = TimerInit() EndIf if $InitialUse2 = False Then Send("e") $InitialUse2 = True EndIf Send("{SPACE}") if TimerDiff($timer2) > 30000 Then Send("e") $timer2 = TimerInit() EndIf Sleep(200) if TimerDiff($timer3) > 10000 Then $InitialUse = False $InitialUse2 = False $timer3 = TimerInit() EndIf Until not _IsPressed("32") EndIf WEnd ;Exit program Func EndProgram() Exit EndFunc Edited May 6, 2021 by Xilibre Link to comment Share on other sites More sharing options...
JockoDundee Posted May 6, 2021 Share Posted May 6, 2021 4 hours ago, Xilibre said: ...just been ...tweaking for a while. Maybe that’s the problem? Danp2 and Xilibre 2 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Xilibre Posted May 6, 2021 Author Share Posted May 6, 2021 lol, well, even if no one knows the answer to this question I can tell the community is good and friendly. Link to comment Share on other sites More sharing options...
argumentum Posted May 6, 2021 Share Posted May 6, 2021 (edited) 12 hours ago, Xilibre said: lol, well, even if no one knows the answer to this question expandcollapse popup#include <WinAPISys.au3> ; for _WinAPI_Keybd_Event(), _WinAPI_GetKeyState() #include <WinAPIvkeysConstants.au3> ; for $VK_* #Region examples for Shortcut Guide ; https://docs.microsoft.com/en-us/windows/powertoys/ _Send_VirtualKey($VK_LWIN, Default, 2000) ; VK_LWIN ; press, hold 2000 ms., release key Sleep(1000) #EndRegion examples for Shortcut Guide ; https://docs.microsoft.com/en-us/windows/powertoys/ _Send_VirtualKey($VK_LWIN, 1) ; VK_LWIN ; key down ; Left Windows key (Natural keyboard) _Send_VirtualKey($VK_1) ; 1 key ; send key 1 ; run first icon in the Taskbar _Send_VirtualKey($VK_LWIN, 2) ; VK_LWIN ; key up ; Left Windows key (Natural keyboard) Sleep(1000) _Send_VirtualKey($VK_LWIN) ; VK_LWIN ; load Start menu ; Left Windows key (Natural keyboard) Sleep(1000) SetNumLock() ; look at the keyboard light ToolTip("") Func _Send_VirtualKey($iVkey, $bPressDownUp = Default, $iSleep = Default) ; $iSleep in ms. If Not IsInt($iVkey) Then Return ; https://www.autoitscript.com/forum/index.php?showtopic=205790&view=findpost&p=1481401 $bPressDownUp = Int($bPressDownUp) ; https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes Switch $bPressDownUp ; Case 1, 2, 3 ; all good ; 1=down ; 2=up ; 3=1+2 Case Else $bPressDownUp = BitOR(1, 2) EndSwitch $iSleep = Int($iSleep) ; Default = 0 If BitAND($bPressDownUp, 1) Then _WinAPI_Keybd_Event($iVkey, 0) If $iSleep Then Sleep($iSleep) If BitAND($bPressDownUp, 2) Then _WinAPI_Keybd_Event($iVkey, $KEYEVENTF_KEYUP) EndFunc ;==>_Send_VirtualKey Func SetNumLock($bState = Default) ; $bState: True=ON , False=OFF, Default=toggle If $bState <> Default Then ; example from https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-keybd_event Local $iKeyState = _WinAPI_GetKeyState($VK_NUMLOCK) ; 0 or 1 ; false or true If Int($bState) = $iKeyState Then Return SetError(0, $iKeyState, 1) EndIf _WinAPI_Keybd_Event($VK_NUMLOCK, $KEYEVENTF_EXTENDEDKEY) _WinAPI_Keybd_Event($VK_NUMLOCK, $KEYEVENTF_EXTENDEDKEY + $KEYEVENTF_KEYUP) EndFunc ;==>SetNumLock so, ..... friendly AND gave you the right path in your quest. The rest you'll have to research on your own Edited May 7, 2021 by argumentum better code example Xilibre 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Xilibre Posted May 7, 2021 Author Share Posted May 7, 2021 Right on, man. Thanks. That's obviously more advanced then the route I thought it would be. Seemed like a smaller project, lol. I'm going to do some reading on this and will touch back. argumentum 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now