Sign in to follow this  
Followers 0
seife96

link a button with a hot key

9 posts in this topic

so i have been doing a programm that sends little parts of text in a active window!

this is my code

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $is_running = False

 

GuiCreate("rsbshooter",209,405,230,12)
$button1=GuiCtrlCreateButton("RSB/SAB",7,130,189,48)
$button2=GuiCtrlCreateButton("RSB/UCB-100",10,215,185,50)
$button3=GuiCtrlCreateButton("RSB/UCB-50",11,295,186,51)
$button4=GuiCtrlCreateButton("stop",76,370,27,41)
$input1=GuiCtrlCreateInput("RSB",4,6,190,20)
$input2=GuiCtrlCreateInput("SAB",4,35,190,20)
$input3=GuiCtrlCreateInput("UCB-100",5,65,188,20)
$input4=GuiCtrlCreateInput("UCB-50",6,95,187,20)
GuiSetState()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")



While 1
$msg=GuiGetMsg()
If $msg=-3 Then Exit
If $msg=$button1 Then button1()
If $msg=$button2 Then button2()
If $msg=$button3 Then button3()
If $msg=$button4 Then button4()
Wend



Func button1()
    Local $msg1, $msg2
    $msg2 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input2)
    $randum = Random(100, 900, 1)
    $randum2 = Random(10, 300, 1)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
        sleep($randum)
        send($msg2)
        sleep($randum2)
        
    WEnd
EndFunc




Func button2()
    Local $msg1, $msg2
    $msg3 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input3)
    $randum = Random(100, 900, 1)
    $randum2 = Random(10, 300, 1)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
        sleep($randum)
        send($msg3)
        sleep($randum2)
        
    WEnd
EndFunc



Func button3()
    Local $msg1, $msg2
    $msg4 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input4)
    $randum = Random(100, 900, 1)
    $randum2 = Random(10, 300, 1)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
        sleep($randum)
        send($msg4)
        sleep($randum2)
       
    WEnd
EndFunc


Func button4()
    $is_running = False
EndFunc










Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFFF) = $button4 Then $is_running = False
    Return $GUI_RUNDEFMSG
EndFunc

I am now trying to add hotkeys to every button. I tried ALLOT but it still doesent work

Share this post


Link to post
Share on other sites



GUISetAccelerators will work for when your window is active only, if you want it to work global (active or not) then HotKeySet would be what you're looking for.

With HotKeySet just call the function the button is meant to do.

Share this post


Link to post
Share on other sites

GUISetAccelerators will work for when your window is active only, if you want it to work global (active or not) then HotKeySet would be what you're looking for.

With HotKeySet just call the function the button is meant to do.

i want it to be global but the hotkey dident work

i tried this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $is_running = False



GuiCreate("rsbshooter",209,405,230,12)
$button1=GuiCtrlCreateButton("RSB/SAB",7,130,189,48)
$button2=GuiCtrlCreateButton("RSB/UCB-100",10,215,185,50)
$button3=GuiCtrlCreateButton("RSB/UCB-50",11,295,186,51)
$button4=GuiCtrlCreateButton("stop",76,370,27,41)
$input1=GuiCtrlCreateInput("RSB",4,6,190,20)
$input2=GuiCtrlCreateInput("SAB",4,35,190,20)
$input3=GuiCtrlCreateInput("UCB-100",5,65,188,20)
$input4=GuiCtrlCreateInput("UCB-50",6,95,187,20)
GuiSetState()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")


HotKeySet("{F8}","_stop")
hotKeySet("{F4}","_rsbsab")
HotKeySet("{F5}","_rsbucb100")
HotKeySet("{F6}","_rsbucb50")

Func _rsbsab()
    Local $msg1, $msg2
    $msg2 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input2)
    $randum = Random(100, 900, 1)
   $randum2 = Random(10, 300, 1)
   
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
      sleep($randum)
        send($msg2)
      sleep($randum2)

    WEnd
EndFunc




Func _rsbucb100()
    Local $msg1, $msg2
    $msg3 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input3)
   $randum = Random(100, 900, 1)
   $randum2 = Random(10, 300, 1)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
      sleep($randum)
        send($msg3)
      sleep($randum2)
        
    WEnd
EndFunc



Func _rsbucb50()
    Local $msg1, $msg2
    $msg4 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input4)
   $randum = Random(100, 900, 1)
   $randum2 = Random(10, 300, 1)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
      sleep($randum)
        send($msg4)
      sleep($randum2)
       
    WEnd
EndFunc


Func _stop()
    $is_running = False
EndFunc


While 1
$msg=GuiGetMsg()
If $msg=-3 Then Exit
If $msg=$button1 Then button1()
If $msg=$button2 Then button2()
If $msg=$button3 Then button3()
If $msg=$button4 Then button4()
Wend



Func button1()
    Local $msg1, $msg2
    $msg2 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input2)
    $randum = Random(100, 900, 1)
   $randum2 = Random(10, 300, 1)
   
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
      sleep($randum)
        send($msg2)
      sleep($randum2)
        
    WEnd
EndFunc




Func button2()
    Local $msg1, $msg2
    $msg3 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input3)
   $randum = Random(100, 900, 1)
   $randum2 = Random(10, 300, 1)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
      sleep($randum)
        send($msg3)
      sleep($randum2)
        
    WEnd
EndFunc



Func button3()
    Local $msg1, $msg2
    $msg4 = GUICtrlRead($input1)
    $msg1 = GUICtrlRead($input4)
   $randum = Random(100, 900, 1)
   $randum2 = Random(10, 300, 1)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(3000)
      sleep($randum)
        send($msg4)
      sleep($randum2)
       
    WEnd
EndFunc


Func button4()
    $is_running = False
EndFunc










Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFFF) = $button4 Then $is_running = False
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

You did read the announcement at the top of the forum ...right?

yes i did i know that game codes are not helped. I read that and i agree. to say yes it is a game thing but not for me and not for anyone else. i just use this example to help me get in to programming. I wanted a project i already did autoit hello world and then i came on this idea. i hope you understand!!!

Share this post


Link to post
Share on other sites

i hope you understand!!!

Clear as mud :x

Let me try to summarize what I believe I read: yes its for a game but you are not going to use it or anybody else for that matter so its allowed?

Let's stick to our policy.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Clear as mud :x

Let me try to summarize what I believe I read: yes its for a game but you are not going to use it or anybody else for that matter so its allowed?

Let's stick to our policy.

Jos

ok ok i want to learn it is not allowed but like i sad this is JUST FOR PRACTICE. I dont need this there are way better onece out there. Belive me if i needed this i would download it for free somewhere else everything has more options and is faster better..... This is for practice.

Share this post


Link to post
Share on other sites

Well you're not learning by arguing your case here :x

Check out the help file for hotkeyset.

Simple terms, have your buttons run functions - set the hotkey to the same function. It really is that simple. Start small, make a GUI that opens Windows calculator and adds a bunch of numbers together. Make a hot key do it.

Start with that and if you still can't get it to work - post your code :P

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0