Gammer Posted August 23, 2016 Share Posted August 23, 2016 (edited) Hi there, i'm trying to make function which will send "home" key to app, when both arrow up and left arrow are pressed, but my func is sending "home", arrow up and left arrow at the same time. Could anyone help me with this? #include <Misc.au3> #RequireAdmin ;Opt("TrayMenuMode", 3) Global $hDLL = DllOpen("user32.dll") Global $hWnd = WinGetHandle("[CLASS:Notepad]") If Not IsAdmin() Then MsgBox("", "", "You dont have admin rights.") EndIf While 1 If _IsPressed("26", $hDLL) And Not _IsPressed("25", $hDLL) Then _PostMessage_Send($hWnd, 0x26) ElseIf _IsPressed("25", $hDLL) And Not _IsPressed("26", $hDLL) Then _PostMessage_Send($hWnd, 0x25) ElseIf _IsPressed("26", $hDLL) And _IsPressed("25", $hDLL) Then _PostMessage_Send($hWnd, 0x24) EndIf WEnd Func _PostMessage_Send($hWnd, $Key, $Delay = 10) $User32 = DllOpen("User32.dll") $ret = DllCall($User32, "int", "MapVirtualKey", "int", $Key, "int", 0) If IsArray($ret) Then DllCall($User32, "bool", "PostMessage", "HWND", $hWnd, "int", $WM_KEYDOWN, "int", $Key, "long", _MakeLong(1, $ret[0])) Sleep($Delay) DllCall($User32, "bool", "PostMessage", "HWND", $hWnd, "int", $WM_KEYUP, "int", $Key, "long", _MakeLong(1, $ret[0]) + 0xC0000000) EndIf DllClose($User32) EndFunc Func _MakeLong($LoDWORD, $HiDWORD) Return BitOR($HiDWORD * 0x10000, BitAND($LoDWORD, 0xFFFF)) EndFunc As you can see, this one is sending "home" when both arrows are down, and nothing else. Just cant make it work as it should. Edited August 23, 2016 by Gammer Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 23, 2016 Moderators Share Posted August 23, 2016 Gammer, Your previous threads have all been about PostMessage_Send and game automation - is this one any different? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 23, 2016 Moderators Share Posted August 23, 2016 Gammer, I see you have looked in on this thread since I posted and have not replied - I will therefore assume that this thread is not different and take the appropriate action. If you wish to persuade me otherwise, PM me. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts