Jump to content

Send "Home" when left arrow and arrow up is down


 Share

Recommended Posts

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 by Gammer
Link to comment
Share on other sites

  • Moderators

Gammer,

Your previous threads have all been about PostMessage_Send and game automation - is this one any different?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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