Jump to content

Pricehacker

Members
  • Posts

    19
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Pricehacker's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanks man! I don't know how to @ you, but i was wondering if you know what _WinAPI_SetKeyboardState() actually does? I want it to simulate those buttonpresses that were recorded with _WinAPI_GetKeyboardState(), but when i run the code it does nothing. I have checked for errors and any wierd characters in my .macro file i created but still it does nothing. I could not find anything useful online, maybe its not used that often, and i thought i might be using it wrong or making the wrong assumptions about its usage. Please tell me if i can use it to simulate keystrokes
  2. I found out what i did wrong, here is the final code: Local $t = _WinAPI_GetKeyboardState() $h = FileOpen("kbst.bin", 18) FileWrite($h, DllStructGetData($t, 1)) FileClose($h) $hFile = FileOpen("kbst.bin") $sFileData = FileRead($hFile) FileClose($hFile) $aStructData = StringSplit($sFileData, '') $tStruct = DllStructCreate('STRUCT') For $i = 1 To 256 DllStructSetData($tStruct, $i, $aStructData[$i]) Next _WinAPI_SetKeyboardState($tStruct) Thanks for helping me
  3. Thank you, the code works as expected. However I cant find how to read the file (kbst.bin) and set a variable to the value that was saved in the file. Basically i want to do something like this: Assign the value returned from _WinAPI_GetKeyboardState() to a variable $t Save the value of $t to a file that can be accesed after the main program is closed Read the file and assign the data to a variable $t Use _WinAPI_SetKeyboardState($t) to simulate the presses recorded previously by _WinAPI_GetKeyboardState() And i guess i already did 1. and 2. with your help, here is my code Local $t = _WinAPI_GetKeyboardState() $h = FileOpen("kbst.bin", 18) FileWrite($h, DllStructGetData($t, 1)) FileClose($h) $hFile = FileOpen("kbst.bin") $tStruct = FileRead($hFile) _WinAPI_SetKeyboardState($tStruct) _WinAPI_SetKeyboardState() returns 0, with no @extended flag. I guess this has to do with the data being altered with before it was written to a file, but i could not find a fitting function to fix my issue
  4. Just found that i was using an old version of _WinAPI_GetKeyboardState, the new version uses structs. Is there any way to save a $tStruct to a file? I had no luck with _WinAPI_StructToArray, as it would usually give an error and when it didnt it would have random characters in it anyway.
  5. I just got a new mouse that has macro functionality, and i wanted to make something simmilar for my keyboard. Thing is, _WinAPI_SetKeyboardState gives me an error i cannot seem to fix. Please ask me if you have any questions, also here is the code: #include <WinAPISys.au3> #include <Array.au3> #include <File.au3> #include <GUIConstantsEx.au3> HotKeySet('{ESC}', 'Close') Global $bRecording = False Global $bStop = False Func Close() $bStop = True EndFunc ;==>Close $hGUI = GUICreate('Input recorder', 500, 200) $idStartRecording = GUICtrlCreateButton('Start recording', 80, 100) $idStopRecording = GUICtrlCreateButton('Run macro', 320, 100) GUISetState() Global $aArray[11][2] $hTimer = TimerInit() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idStartRecording $bStop = False GUICtrlSetData($idStartRecording, 'Running...') $hFile = FileOpen(@ScriptDir & '\Macro' & @YEAR & '.' & @MON & '.' & @MDAY & '-' & @HOUR & '.' & @MIN & '.' & @SEC & '.macro', 1) While $bStop = False ;$hTimer = TimerInit() For $i = 0 To 10 If $i <> 0 Then Do Sleep(10) $a = _WinAPI_GetKeyboardStateMod() Until _ArrayToString($a, '') <> $aArray[$i - 1][0] or $bStop = True ;ConsoleWrite(_ArrayToString($a, '') & ' ' & $aArray[$i - 1][0]) Else $a = _WinAPI_GetKeyboardStateMod() EndIf $aArray[$i][0] = _ArrayToString($a, '') $aArray[$i][1] = Round(TimerDiff($hTimer), 1) $hTimer = TimerInit() Next _FileWriteFromArray($hFile, $aArray, Default, Default, @CRLF) for $iO = 0 to 10 $aArray[$iO][0] = '' $aArray[$iO][1] = '' Next ;ConsoleWrite(@error) WEnd _FileWriteFromArray($hFile, $aArray, Default, Default, @CRLF) GUICtrlSetData($idStartRecording, 'Start recording') Case $idStopRecording $bStop = False $hFile = FileOpen(FileOpenDialog('Select macro file', @ScriptDir, 'Macro files (*.macro)', 1 + 2)) GUICtrlSetData($idStopRecording, 'Running...') $sFileContent = FileRead($hFile) ;ConsoleWrite($sFileContent&@CRLF&@CRLF&@CRLF) $aWholeFile = StringSplit($sFileContent, @LF) ;_ArrayDisplay($aWholeFile) For $i = 1 To $aWholeFile[0] - 1 ;ConsoleWrite(Mod($i,2)) if $bStop = True Then ExitLoop If $aWholeFile[$i] <> @CR Then If Mod($i,2) = 1 Then ConsoleWrite('Array ' & $aWholeFile[$i]) $aCharPresses = StringSplit($aWholeFile[$i], '') _WinAPI_SetKeyboardState($aCharPresses) Else ConsoleWrite('Sleep ' & $aWholeFile[$i]) Sleep(Int($aWholeFile[$i])) EndIf EndIf Next GUICtrlSetData($idStopRecording, 'Run macro') EndSwitch WEnd Func _WinAPI_GetKeyboardStateMod() Local $aDllRet, $lpKeyState = DllStructCreate("byte[256]") $aDllRet = DllCall("User32.dll", "int", "GetKeyboardState", "ptr", DllStructGetPtr($lpKeyState)) Local $aReturn[256] For $i = 1 To 256 $aReturn[$i - 1] = DllStructGetData($lpKeyState, 1, $i) Next Return $aReturn EndFunc ;==>_WinAPI_GetKeyboardStateMod
  6. Hello! Im wondering if it is possible to 'empty' the variable value to save memory, for example i often use variable as a onetime use thing and would prefer to 'forget' it after is is used Maybe it is just as easy as to setting $vVar = Null, but i wanted to make sure that this is the case
  7. Thank you Bert from the muppets, but I am having a competition with my group of friends where we try to make the most efficient cookie clicker script. As far as i am concerned pixelgetcolor is the only command that would help me to win.
  8. Hello Autoit! Today i discovered that pixelgetcolor doesn't adapt to the DPI of the system, and i want to fix this somehow as my laptop uses 120 DPI. This is what i have came up with so far: AutoItSetOption ( "CaretCoordMode" , 0) AutoItSetOption ( "MouseCoordMode" , 0) AutoItSetOption ( "PixelCoordMode" , 0) AutoItSetOption ( "GUICoordMode" , 0) #include <MsgBoxConstants.au3> #include <Misc.au3> #include <WinAPIGdi.au3> ; enum _PROCESS_DPI_AWARENESS Global Const $PROCESS_DPI_UNAWARE = 0 Global Const $PROCESS_SYSTEM_DPI_AWARE = 1 Global Const $PROCESS_PER_MONITOR_DPI_AWARE = 2 ; enum _MONITOR_DPI_TYPE Global Const $MDT_EFFECTIVE_DPI = 0 Global Const $MDT_ANGULAR_DPI = 1 Global Const $MDT_RAW_DPI = 2 Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI HotKeySet('{ESC}','Terminate') Func Terminate() Exit EndFunc $iPD = 1 while 1 $aPos = WinGetPos("[ACTIVE]") ToolTip (PixelGetColor( MouseGetPos()[0]*(96/_DPI(0)), MouseGetPos()[1]*(96/_DPI(1))) & ', ' & MouseGetPos()[0] & ', ' & MouseGetPos()[1] ) if $iPD = 1 and Not _IsPressed(22) Then $iPD = 0 Sleep(100) EndIf if $iPD = 0 And _IsPressed(22) Then ;Page down is pressed ClipPut( 'PixelGetColor($aPos[2]' & '*' & MouseGetPos(0)/$aPos[2] & ',' & '$aPos[3]' & '*' & MouseGetPos(1)/$aPos[3] & ')' & '=' & PixelGetColor( MouseGetPos()[0], MouseGetPos()[1])) $iPD = 1 EndIf WEnd ;Functions Func _DPI($iCordinate) ;0 for x and 1 for y _WinAPI_SetProcessDpiAwareness($PROCESS_SYSTEM_DPI_AWARE) $aMonitors = _WinAPI_EnumDisplayMonitors() $aDPI = _WinAPI_GetDpiForMonitor($aMonitors[1][0], $MDT_DEFAULT) Return $aDPI[$iCordinate] EndFunc Func _WinAPI_SetProcessDpiAwareness($DPIAware) DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $DPIAware) If @error Then Return SetError(1, 0, 0) EndFunc Func _WinAPI_GetDpiForMonitor($hMonitor, $dpiType) Local $X, $Y $aRet = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "long", $hMonitor, "int", $dpiType, "uint*", $X, "uint*", $Y) If @error Or Not IsArray($aRet) Then Return SetError(1, 0, 0) Local $aDPI[2] = [$aRet[3],$aRet[4]] Return $aDPI EndFunc I'm pretty sure it has to do with me using the DPI in the wrong way as i dont really understand it (even after searching around on the internet for like an hour) It would really help if anyone could help me on the right track
  9. Thank you! However im not sure how to use any of them as they have no examples in then Help file, could you please tell me how to use them kind sir?
  10. Hello again! I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation. First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported. Any help is appreciated! Thank you!
  11. Not exactly what i was looking for but that doesnt matter as encrypting the password is probably much safer anyways. Thanks to all of you for your help!
  12. Not sure what "Mod working in a thread" means but the reason i want to make exe files bigger is becouse i want to store information at a "secret place" eighter by reading from the exe file afterwards, or by looking at the file size and using that as a source of information to store a short string lika a password. Also thanks for trying to help guys!
  13. Hello! I want to make a script that changes the filesize of program files while still having them run as usual. I tried FileWrite() but then the program wouldnt be recognized as a runnable program, could you guys help me to the right path?
  14. Hello, I am making a program where the button is an image that "changes" when specific conditions are fullfilled. Problem is that these images have different dimensions and when a smaller picture is displayed over a bigger one both will be seen, therefore i would like the images to be hidden, invincible or, alternatively, deleted. I have tried using _GDIPlus_GraphicsClear() with no luck However that might just be me not using it right as im quite new to autoit Here is the code if you want to test run it: Thanks to everyone helping!
×
×
  • Create New...