 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
LiL Shinta
Joined: 12 May 2008 Posts: 3
|
Posted: Mon May 12, 2008 4:32 am Post subject: Au3 to AHK.Help please.. |
|
|
hi to all..
im not good in ahk coz im a newbie..
can I request to you guys to translate my code of au3 here to ahk.. here's my code:
| Code: |
;Assigning GLobal Functions
Global $ConfigFile = @ScriptDir & "\bpm.ini"
Global $Init = IniRead($ConfigFile, "Main Prefs", "bpm", 122)
;my hotkeys
Global $HK1 = "{F8}"
Global $HK2 = "{F11}"
Global $HK5 = "{F9}"
Global $HK6 = "{F10}"
Global $HK8 = "{F4}"
Global $HK9 = "{F5}"
;bool value for pausing the scripts.
Global $bool = False
Global $skip = False
;setting my hotkeys to a given function
HotKeySet($HK1, "start") ;F8 will run the start function
HotKeySet($HK2, "quit") ;F11 will run quit function
HotKeySet($HK8, "add") ;F4 will run add function
HotKeySet($HK9, "less")
HotKeySet($HK5,"pause")
HotKeySet($HK6,"endloops")
; the while waiting statement
While 1
Sleep(100)
IniWrite($ConfigFile, "Main Prefs", "bpm", 122) ;making .ini file
FileSetAttrib(@ScriptDir & "/bpm.ini", "-R+AHO") ;setting attribute to the file
WEnd
Func add()
Opt("SendKeyDelay", 10) ;the sending delay
$Init += 1
IniWrite($ConfigFile, "Main Prefs", "bpm", $Init)
$Ini1 = IniReadSection($ConfigFile, "Main Prefs")
$var = $Ini1[1][1]
$var2 = $var
Send("{Enter}") ;sending {Enter}
Send($var2)
Send("{Enter}")
EndFunc
Func less() ;my less function
Opt("SendKeyDelay", 10) ;the sending delay
$Init -= 1
IniWrite($ConfigFile, "Main Prefs", "bpm", $Init)
$Ini1 = IniReadSection($ConfigFile, "Main Prefs")
$var = $Ini1[1][1]
$var2 = $var
Send("{Enter}") ;sending {Enter}
Send($var2)
Send("{Enter}")
EndFunc
Func endloops()
Opt("SendKeyDelay", 10) ;the sending delay
$bool = False
$skip = True
IniWrite($ConfigFile, "Main Prefs", "bpm", 122)
while $skip ;making the function start to pause
sleep(10)
ConsoleWrite("Paused!"&@CRLF)
WEnd
EndFunc
Func pause()
$bool= Not $bool ;bool function which will pause my script
while $bool
sleep(10)
ConsoleWrite("Paused!"&@CRLF)
WEnd
EndFunc
Func quit()
FileDelete(@ScriptDir & "/bpm.ini")
Exit
EndFunc
Func start()
Local $Ini1 = IniReadSection($ConfigFile, "Main Prefs")
Local $var = $Ini1[1][1]
Local $skip = False
Local $beat1 = $var / 60
Local $beat2 = ( 1 / $beat1) * 4 * 1000
Opt("SendKeyDelay", $beat2) ;setting the sending delay
$i = 0
Do ;my loop statement
Send("{SPACE}")
Until $i = 60 Or $skip = True; changed
EndFunc
|
that's my code... ahmm... also i want to know how to make this works on a game which is using the "dinput8.dll"...those game use this dll file to prevent such pseudo keyboard event from entering the game... I switch to autohotkey coz i find out that AHK can make it work for that case.. any help is much appreciated. |
|
| Back to top |
|
 |
Guest
|
Posted: Mon May 12, 2008 4:50 am Post subject: |
|
|
really ugly code it makes me dizzy
i mean.. au3's way
things like that can be done much simple in autohotkey
| Code: | ;AU3
Global $HK2 = "{F11}"
HotKeySet($HK2, "quit") ;F11 will run quit function
Func quit()
FileDelete(@ScriptDir & "/bpm.ini")
Exit
EndFunc |
| Code: | ;AutoHotkey
F11::FileDelete, bpm.ini |
 |
|
| Back to top |
|
 |
LiL Shinta
Joined: 12 May 2008 Posts: 3
|
Posted: Mon May 12, 2008 5:09 am Post subject: |
|
|
| but will that exit the script? ehm.. how to set a hotkey for every function eh? |
|
| Back to top |
|
 |
Guest
|
Posted: Mon May 12, 2008 5:15 am Post subject: |
|
|
you don't have to use Functions to react on a hotkey
| Code: | F12:: ;assigning hotkey
Run, notepad.exe ;put commands from here
WinWait, ahk_class Notepad
WinMaximize
Send, Hi There
Return ;closing hotkey commands |
|
|
| Back to top |
|
 |
LiL Shinta
Joined: 12 May 2008 Posts: 3
|
Posted: Mon May 12, 2008 6:22 am Post subject: |
|
|
| ehmm... how about on sending a Keystroke on a game using dllcall with dinput8.dll? how do i know if i got the correct working array for my sending inputs..? |
|
| Back to top |
|
 |
Elesar
Joined: 28 Jun 2007 Posts: 69
|
Posted: Mon May 12, 2008 5:10 pm Post subject: |
|
|
Just read about the SendMode command that you can specify at the begining of your script. SendMode Input is common, but some games (maybe the ones using that DLL) require SendMode Play (Or simply SendPlay) or maybe even SendMode Raw.
| Code: |
#SingleInstance Force ; This allows only one instance of the script to run at a time
SendPlay ; Used to input commands to a broad variety of games
F11::
FileDelete, bpm.ini ; Delete the bpm.ini file, assumed to be in the same directory as the script
ExitApp ; Exit the script
Return ; Not really needed after exiting the script, but for all other hotkeys, you would need to inlude this so that you don't spam all your hotkeys sequentially after activating one.
|
I would help more, but I have no interest in learning the Au3 language, so I don't really understand most of the script you posted. Please use the help file and Wiki to learn more about the commands that I demonstrated, and learn the commands to replace your Au3 script. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|