Sign in to follow this  
Followers 0
MadBoy

HotKeySet problem

5 posts in this topic

#1 ·  Posted (edited)

Hello again,

I've implemented HotKeySet feature in my script. I would like it to be active only when script is in Do/Until loop. Is that possible to achive? As the problem i am having is that When information is displayed in Tooltip and i press Hotkey once it sends packet to my server and everything is fine here.

TrayTip("Information:", $udp_receive_data, 8,1)
         $time = TimerInit(); start timer
         Do
             Switch @HotKeyPressed
                 Case '4'
                     If $udp_pci_password = "" Then
                         $status = UDPSend($socket_outgoing, $udp_command & " " & $udp_receive_data)
                     Else
                         $status = UDPSend($socket_outgoing, $udp_pci_password & " " & $udp_command & " " & $udp_receive_data)
                     EndIf
                     TrayTip("Clean Tip", "", 1)
                     ExitLoop
             EndSwitch
      
     Until TimerDiff($time) > 8000; check timeout
 oÝ÷ Øz0z÷«Z§±Êâ¦Ø¬¢ëlר~ØZ¶Z(¥©ÝÞ²Ç(º^¡ûbë&Ê-짢ØbZ¦§²éíV§¢Ø^®)ߢ¹¶*'¶îP3Ü¢g¬v§vØ^+lyé¬)¶¬r¸©¶·¦zg®ËajØ©­ë,yÙ²d{'(º^¡ûbëØ­±éݱ@Ï¥§$zÖÚrKh±êïz»az{¦mêè~ئzÈ¡j÷©­ë,yÛaz-졧-¹©eÊ+]¡ë"µ«­¢f Æ¥,".µëÞ«$x&+¥êæȨ   ݶ­ßÛ'¢Ü!jØ°j{G¢¢·lrW­©Ý²¢wjx^Â+a¶¬jëh×6

HotKeySet('4', 'SendPacket')

UDPStartup()
$socket_incoming = UDPBind($listening_udp_ip, $listening_udp_port)
If @error <> 0 Then Exit
$socket_outgoing = UDPOpen($udp_pci_ip, $udp_pci_port)
If @error <> 0 Then Exit

While 1
    $udp_receive_data = UDPRecv($socket_incoming, 2046)
    If $udp_receive_data <> "" Then
        $macro_start = TimerInit()
        $udp_receive_data = StringStripWS ( $udp_receive_data, 8 )
        $macro_time = TimerDiff($macro_start)
        TrayTip("Information:", $udp_receive_data, 8,1)
        $time = TimerInit(); start timer
        Do
            Switch @HotKeyPressed
                Case '4'
                    If $udp_pci_password = "" Then
                        $status = UDPSend($socket_outgoing, $udp_command & " " & $udp_receive_data)
                    Else
                        $status = UDPSend($socket_outgoing, $udp_pci_password & " " & $udp_command & " " & $udp_receive_data)
                    EndIf
                    TrayTip("Clean Tip", "", 1)
                    ExitLoop
            EndSwitch
     
    Until TimerDiff($time) > 8000; check timeout
    sleep(100)
WEnd

UDPCloseSocket($socket_incoming)
UDPCloseSocket($socket_outgoing)
UDPShutdown()

Func SendPacket()

EndFunc
Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

use _IsPressed() instead!

#include <Misc.au3>
$dll = DllOpen("user32.dll")


; REST OF YOUR CODE
Do
    sleep(50)
    If _IsPressed(34) Then; 34 == key "4", see help file for other keys!!
        If $udp_pci_password = "" Then
            $status = UDPSend($socket_outgoing, $udp_command & " " & $udp_receive_data)
        Else
            $status = UDPSend($socket_outgoing, $udp_pci_password & " " & $udp_command & " " & $udp_receive_data)
        EndIf
        TrayTip("Clean Tip", "", 1)
        ExitLoop
    EndIf

Until TimerDiff($time) > 8000; check timeout

; REST OF YOUR CODE

DllClose($dll)

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Ah great!!! The only problem I am missing now is that if i lets say mark it under '4' or whatever letter and then i press it, right information is sent to server but i also get that '4' in my text document i am actually writting ;)

Any way to fix that?


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Ah great!!! The only problem I am missing now is that if i lets say mark it under '4' or whatever letter and then i press it, right information is sent to server but i also get that '4' in my text document i am actually writting ;)

Any way to fix that?

Not with _IsPressed. Then better o back to HotkeySet().

HotKeySet('4', 'SendPacket')
global $glb_send_packet

;REST OF YOUR CODE
    $glb_send_packet = 0
    Do
        If ($glb_send_packet = 1) Then
            MsgBox(0,"SENDING","UDP Sending....",2); <== REPLACE THIS WITH YOUR CODE
            TrayTip("Clean Tip", "", 1)
            ExitLoop
        EndIf
    Until TimerDiff($time) > 8000; check timeout

;REST OF YOUR CODE

Func SendPacket()
    $glb_send_packet = 1
EndFunc

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Tnx works perfect ;)


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
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
Sign in to follow this  
Followers 0